aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2016-09-06 08:50:47 -0400
committerThierry Reding <thierry.reding@gmail.com>2016-09-08 04:58:33 -0400
commit2fbc487df6e6927bc0a0092f86d4d15961e070de (patch)
tree7ba46283b48de8cddfdce4d7d234e2b2da148448
parent7d8a600c916cab347662de212340d3eaf0e93db2 (diff)
pwm: meson: Handle unknown ID values
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> Acked-by: Neil Armstrong <narmstrong@baylibre.com> Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
-rw-r--r--drivers/pwm/pwm-meson.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/drivers/pwm/pwm-meson.c b/drivers/pwm/pwm-meson.c
index bfbbe7f3cdc1..381871b2bb46 100644
--- a/drivers/pwm/pwm-meson.c
+++ b/drivers/pwm/pwm-meson.c
@@ -245,6 +245,9 @@ static void meson_pwm_enable(struct meson_pwm *meson,
245 enable = MISC_B_EN; 245 enable = MISC_B_EN;
246 offset = REG_PWM_B; 246 offset = REG_PWM_B;
247 break; 247 break;
248
249 default:
250 return;
248 } 251 }
249 252
250 value = readl(meson->base + REG_MISC_AB); 253 value = readl(meson->base + REG_MISC_AB);
@@ -273,6 +276,9 @@ static void meson_pwm_disable(struct meson_pwm *meson, unsigned int id)
273 case 1: 276 case 1:
274 enable = MISC_B_EN; 277 enable = MISC_B_EN;
275 break; 278 break;
279
280 default:
281 return;
276 } 282 }
277 283
278 value = readl(meson->base + REG_MISC_AB); 284 value = readl(meson->base + REG_MISC_AB);
@@ -352,6 +358,9 @@ static void meson_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm,
352 case 1: 358 case 1:
353 mask = MISC_B_EN; 359 mask = MISC_B_EN;
354 break; 360 break;
361
362 default:
363 return;
355 } 364 }
356 365
357 value = readl(meson->base + REG_MISC_AB); 366 value = readl(meson->base + REG_MISC_AB);