pinctrl: amd: fix compilation warning
authorLinus Walleij <linus.walleij@linaro.org>
Tue, 3 Jan 2017 08:18:58 +0000 (09:18 +0100)
committerLinus Walleij <linus.walleij@linaro.org>
Tue, 3 Jan 2017 08:26:21 +0000 (09:26 +0100)
3bfd44306c65 ("pinctrl: amd: Add support for additional GPIO")
created the following warning:

drivers/pinctrl/pinctrl-amd.c: In function 'amd_gpio_dbg_show':
drivers/pinctrl/pinctrl-amd.c:210:3: warning: 'pin_num' may be used uninitialized in this function [-Wmaybe-uninitialized]
   for (; i < pin_num; i++) {
   ^
drivers/pinctrl/pinctrl-amd.c:172:21: warning: 'i' may be used uninitialized in this function [-Wmaybe-uninitialized]
  unsigned int bank, i, pin_num;
                     ^
Fix this by adding a guarding default case for illegal
bank numbers.

Cc: S-k Shyam-sundar <Shyam-sundar.S-k@amd.com>
Cc: Nehal Shah <Nehal-bakulchandra.Shah@amd.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/pinctrl/pinctrl-amd.c

index 47b17100410ee4701748aa85848fdaa99ebc9131..c2203699f1ab32e51fb7058b04dcafb177cb9cb6 100644 (file)
@@ -206,6 +206,9 @@ static void amd_gpio_dbg_show(struct seq_file *s, struct gpio_chip *gc)
                        i = 192;
                        pin_num = AMD_GPIO_PINS_BANK3 + i;
                        break;
+               default:
+                       /* Illegal bank number, ignore */
+                       continue;
                }
                for (; i < pin_num; i++) {
                        seq_printf(s, "pin%d\t", i);