Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1477339 > unrolled thread

Re: [PATCH] pwm: meson: handle unknown ID values

Started byNeil Armstrong <narmstrong@baylibre.com>
First post2016-09-06 15:00 +0200
Last post2016-09-06 15:00 +0200
Articles 1 — 1 participant

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [PATCH] pwm: meson: handle unknown ID values Neil Armstrong <narmstrong@baylibre.com> - 2016-09-06 15:00 +0200

#1477339 — Re: [PATCH] pwm: meson: handle unknown ID values

FromNeil Armstrong <narmstrong@baylibre.com>
Date2016-09-06 15:00 +0200
SubjectRe: [PATCH] pwm: meson: handle unknown ID values
Message-ID<seo8S-29v-13@gated-at.bofh.it>
On 09/06/2016 02:50 PM, Arnd Bergmann wrote:
> When building with -Wmaybe-uninitialized, we get a couple of harmless
> warnings about three functions in this new driver that don't look
> safe to the compiler:
> 
> drivers/pwm/pwm-meson.c: In function 'meson_pwm_get_state':
> drivers/pwm/pwm-meson.c:355:26: error: 'mask' may be used uninitialized in this function [-Werror=maybe-uninitialized]
> drivers/pwm/pwm-meson.c: In function 'meson_pwm_disable':
> drivers/pwm/pwm-meson.c:263:13: error: 'enable' may be used uninitialized in this function [-Werror=maybe-uninitialized]
> drivers/pwm/pwm-meson.c: In function 'meson_pwm_apply':
> drivers/pwm/pwm-meson.c:231:13: error: 'clk_shift' may be used uninitialized in this function [-Werror=maybe-uninitialized]
> drivers/pwm/pwm-meson.c:231:36: error: 'enable' may be used uninitialized in this function [-Werror=maybe-uninitialized]
> drivers/pwm/pwm-meson.c:231:24: error: 'clk_enable' may be used uninitialized in this function [-Werror=maybe-uninitialized]
> 
> Specifically, if we have a device with an id other than 0 or 1,
> this would result in undefined behavior. This is currently not
> possible, but the compiler cannot be expected to know this.
> 
> This patch adds a 'default' clause to let the compiler know
> what to do instead, which shuts up the warning and makes the
> code slightly more resiliant in case it gets extended to other
> identifiers.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>  drivers/pwm/pwm-meson.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/drivers/pwm/pwm-meson.c b/drivers/pwm/pwm-meson.c
> index 566f5cb81021..25abd95dcc7b 100644
> --- a/drivers/pwm/pwm-meson.c
> +++ b/drivers/pwm/pwm-meson.c
> @@ -242,6 +242,9 @@ static void meson_pwm_enable(struct meson_pwm *meson,
>  		clk_enable = MISC_B_CLK_EN;
>  		enable = MISC_B_EN;
>  		break;
> +
> +	default:
> +		return;
>  	}
>  
>  	value = readl(meson->base + REG_MISC_AB);
> @@ -270,6 +273,9 @@ static void meson_pwm_disable(struct meson_pwm *meson, unsigned int id)
>  	case 1:
>  		enable = MISC_B_EN;
>  		break;
> +
> +	default:
> +		return;
>  	}
>  
>  	value = readl(meson->base + REG_MISC_AB);
> @@ -349,6 +355,10 @@ static void meson_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm,
>  	case 1:
>  		mask = MISC_B_EN;
>  		break;
> +
> +	default:
> +		state->enabled = 0;
> +		return;
>  	}
>  
>  	value = readl(meson->base + REG_MISC_AB);
> 

Acked-by: Neil Armstrong <narmstrong@baylibre.com>

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web