From patchwork Fri Jan 1 22:40:46 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 101218 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp4164033lbb; Fri, 1 Jan 2016 14:41:17 -0800 (PST) X-Received: by 10.98.11.209 with SMTP id 78mr84614036pfl.64.1451688077416; Fri, 01 Jan 2016 14:41:17 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ff7si9953136pab.184.2016.01.01.14.41.17; Fri, 01 Jan 2016 14:41:17 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-gpio-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-gpio-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-gpio-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752435AbcAAWlQ (ORCPT + 4 others); Fri, 1 Jan 2016 17:41:16 -0500 Received: from mout.kundenserver.de ([212.227.126.135]:56526 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752364AbcAAWlP (ORCPT ); Fri, 1 Jan 2016 17:41:15 -0500 Received: from wuerfel.localnet ([134.3.118.24]) by mrelayeu.kundenserver.de (mreue001) with ESMTPSA (Nemesis) id 0M9S0c-1aOX5d2fhm-00CiG1; Fri, 01 Jan 2016 23:40:47 +0100 From: Arnd Bergmann To: linus.walleij@linaro.org Cc: devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, Alexandre Courbot Subject: [PATCH] gpiolib: always initialize *flags from of_get_named_gpio_flags Date: Fri, 01 Jan 2016 23:40:46 +0100 Message-ID: <6037371.CvRA1dDj1l@wuerfel> User-Agent: KMail/4.11.5 (Linux/3.16.0-10-generic; KDE/4.11.5; x86_64; ; ) MIME-Version: 1.0 X-Provags-ID: V03:K0:Kjr3o3Ydwnpp62mR43Tt11kvYa0+1oaWqgThWaawADb6e3DjEYp Nn8xxwhKNq+W6/mQtzm+SGSF4HCabZv9UTRZtggKtdeRkopZPUH/M4AdojrhAUr8HvU7Vtg Auh1vktXSc5mxbr/Rb8NlRbDKj+acj/FMYvaU/O3EohIKDGBWr2oJ96OpqJDCXEnthni91D NafEAOR/vrzjiv8B+8FGA== X-UI-Out-Filterresults: notjunk:1; V01:K0:Fvu89o33ZXA=:Mzb8N5BBOCwcoC00bsYc2u 3aDjvLyIvh0yEVrizET+fKF2noPKASJJ7c9dhLpTN1VAiGvVQXUmCzvbmqCjkGTo+i5VN/9F+ FfaOmq9PHybgpLJarDPIEvczftq/LsfKFKzsbws+Wh9nDXCoN/HsQBehV0NqDBxB1ftmTcfRg TapLeCpgZM90qGZyL5UTZFXtp4VjIrk2Pfx13Gqs+wNmapS5huxSQg+TA81O6BBdXOtXG9hLT g1N2aOEA18OQuDfT5gYtml5bf7We7Azf27y5/OR7pbVrdTkeiu5UNAZKTDze3XyqAdX5p7AKI uQJF0LilBpH9GNpil7xl3rYZdReRQwWP5uox5lwXlTtDPGYRLbILtE1cFeNwuc7tplaRA0wNA +G9hrdZxjkds9wG1zZGUhMWD4ilSSHIqZOFANNpah7Yld5xd0hrRcaw5J6oT0TIwjxzaI6Ijm FiroJN11wX/4lzE0bAdNVr04qlm+dk7NInWlEdDxCtfHJg/hwYQVkbA1Jk+t1LkWNWkxrmIvW hwNjglg7Hv+LQLuQoY9dGk56zJBAmxE3WdWsE03NWTBeHdm065ONOAUE4234Jb9Kl4d+lvl7d W3c9h/kZEvBjmH9l5jGNGYBzlfKap0gyf7x1eA+EnJWAq5qB8Z+DIzIyUIG2tHBKTU6Q594rf G+teMDiDVea3fM2RheLvBkbJpkkl2QZmTySdDDxO0ibsVPlgvxbr5rP/cVSki/omgc8pucmH/ 4S1VuiXYUXZP3PLo Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org The of_get_named_gpio_flags() function does nothing other than returning an error when CONFIG_OF_GPIO is disabled, but that causes spurious warnings about possible use of uninitialized variables in any code that does not check the of_get_named_gpio_flags() return value before trying to use the flags: drivers/input/misc/rotary_encoder.c: In function 'rotary_encoder_probe': drivers/input/misc/rotary_encoder.c:223:28: warning: 'flags' may be used uninitialized in this function [-Wmaybe-uninitialized] drivers/power/bq24735-charger.c: In function 'bq24735_charger_probe': drivers/power/bq24735-charger.c:227:12: warning: 'flags' may be used uninitialized in this function [-Wmaybe-uninitialized] drivers/power/sbs-battery.c: In function 'sbs_probe': drivers/power/sbs-battery.c:782:17: warning: 'gpio_flags' may be used uninitialized in this function [-Wmaybe-uninitialized] This changes the behavior of the inline helper to set the flags to zero when OF_GPIO is disabled, to avoid the warnings. In all cases I've encountered, we don't actually get to the place that uses the flags if CONFIG_OF is disabled because we won't enter the DT parser code. Signed-off-by: Arnd Bergmann -- To unsubscribe from this list: send the line "unsubscribe linux-gpio" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/include/linux/of_gpio.h b/include/linux/of_gpio.h index 87d6d1632dd4..bb85a8eeba6a 100644 --- a/include/linux/of_gpio.h +++ b/include/linux/of_gpio.h @@ -67,6 +67,9 @@ extern int of_gpio_simple_xlate(struct gpio_chip *gc, static inline int of_get_named_gpio_flags(struct device_node *np, const char *list_name, int index, enum of_gpio_flags *flags) { + if (flags) + *flags = 0; + return -ENOSYS; }