From patchwork Tue Nov 8 13:40:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 692312 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3tCrLQ0tLCz9t2D for ; Wed, 9 Nov 2016 00:50:54 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751420AbcKHNux (ORCPT ); Tue, 8 Nov 2016 08:50:53 -0500 Received: from mout.kundenserver.de ([217.72.192.75]:52379 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751099AbcKHNuw (ORCPT ); Tue, 8 Nov 2016 08:50:52 -0500 Received: from wuerfel.lan. ([78.43.20.153]) by mrelayeu.kundenserver.de (mreue104) with ESMTPA (Nemesis) id 0Lecww-1ccdiL1inu-00qVYE; Tue, 08 Nov 2016 14:40:39 +0100 From: Arnd Bergmann To: Linus Walleij Cc: Arnd Bergmann , Alexandre Courbot , Mika Westerberg , "Rafael J. Wysocki" , Dmitry Torokhov , Wei Yongjun , Christophe Ricard , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] ACPI / gpio: avoid warning for gpio hogging code Date: Tue, 8 Nov 2016 14:40:06 +0100 Message-Id: <20161108134035.1764500-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 MIME-Version: 1.0 X-Provags-ID: V03:K0:2dDVVOP6288DixKle8dmYEYXvYWU7uPCiSh7uGtMMTuXNOmdqXl oAlA8uSTTJoNgJk2KHkXFOoldsqGwEosYzJsBTieXdKzymq2WEG3A+iXUy24TiPAS4XDTGx xkXu50sXK3x1nNXXeeFm17eA6mWV8bc5XT+T125DUm5+SbW0eFtrvUou14imiByFUOcewbo VIDrvtsBpZWnemdMssDDg== X-UI-Out-Filterresults: notjunk:1; V01:K0:VBCgKdOT8fU=:3lhhxBXrP8292jVkrAlN91 RbDlkvzYxrvvWjiKmIhS7LrmHjolD26cJpyDCw0u5imt15+lOMIfu824sPenIUdWKwub5iUsx mgkpMeUu8veYm7EnJ9sPzjJGUnM51fZDyIjYO4MeUYGq37GQCBHbO85Y+w7kt1EKwleOh7OOR m7c3xL/Ufjaj6fwdUA7RDWwwlXHct7jlrqMUo9khcQVvayQxCcyGcAqy7OmqLX0j4ptWzl6Xe aY0eW2jCfBz4o8zyaGqzhXyXtXWIHUpOkCw9XFbxEZtamV/dtRBmNa/NLhTckL4TW5MOhYEWT HacxUzZU6uNJlCSclWp7ER/BVTiegVYpZbfNt9eD/sl5DCdT2GCD1N+Bzl9CnSCTvvljQebx+ ex7yB18aVrG5Qf5Onk8cJY2odFSatM5aAwsroDEEIaHg+j0KuXBVOeh0GZGr1KptdhaPbKh/J rw1bG0vpZyEpl35CGySstlS9vB7K7k2g2sh+YATQEXQx0DkL4efFbAJ3VA+uaeh++sPHVverw 4gDpXyUGKyAqcYB+70nAO2PKTLpCKKnNQUvkvdOwnq4caNl3lZyVI3cw2JG1OXNn9eqt0YEBW IaSyxsrZLwbAZeWYwNKPkqVxx3/yezGxbpEi4KJ++vO5HwyAbLx2fiTt2ClAnVzKOhGP4RmS9 hTcsLVtHB54EfOd5PwjInT/b41Pm0jxB0ATcQTgv5VQkS24kbhCf8JucOG8j6g8zafUUa+MkR w2K7gDUlvumL9Gu7 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org The newly added acpi_gpiochip_scan_gpios function produces a few harmless warnings: drivers/gpio/gpiolib-acpi.c: In function ‘acpi_gpiochip_add’: drivers/gpio/gpiolib-acpi.c:925:7: error: ‘dflags’ may be used uninitialized in this function [-Werror=maybe-uninitialized] drivers/gpio/gpiolib-acpi.c:925:9: error: ‘lflags’ may be used uninitialized in this function [-Werror=maybe-uninitialized] The problem is that he compiler cannot know that a negative return value from fwnode_property_read_u32_array() or acpi_gpiochip_pin_to_gpio_offset() implies that the IS_ERR(gpio_desc) is true, as the value could in theory be below -MAX_ERRNO. The function already initializes its output values to zero, and moving that intialization a little higher up ensures that we can never have uninitialized data in the caller. Fixes: c80f1ba75df2 ("ACPI / gpio: Add hogging support") Signed-off-by: Arnd Bergmann Acked-by: Mika Westerberg --- drivers/gpio/gpiolib-acpi.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c index 265e0fad518e..a3faefa44f68 100644 --- a/drivers/gpio/gpiolib-acpi.c +++ b/drivers/gpio/gpiolib-acpi.c @@ -869,6 +869,10 @@ static struct gpio_desc *acpi_gpiochip_parse_own_gpio( u32 gpios[2]; int ret; + *lflags = 0; + *dflags = 0; + *name = NULL; + ret = fwnode_property_read_u32_array(fwnode, "gpios", gpios, ARRAY_SIZE(gpios)); if (ret < 0) @@ -882,10 +886,6 @@ static struct gpio_desc *acpi_gpiochip_parse_own_gpio( if (IS_ERR(desc)) return desc; - *lflags = 0; - *dflags = 0; - *name = NULL; - if (gpios[1]) *lflags |= GPIO_ACTIVE_LOW;