From patchwork Mon Oct 24 15:32:08 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 101624 Delivered-To: patch@linaro.org Received: by 10.140.97.247 with SMTP id m110csp2641022qge; Mon, 24 Oct 2016 08:32:29 -0700 (PDT) X-Received: by 10.36.80.205 with SMTP id m196mr2648241itb.58.1477323149899; Mon, 24 Oct 2016 08:32:29 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id hp7si13272746pac.299.2016.10.24.08.32.29; Mon, 24 Oct 2016 08:32:29 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-input-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-input-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-input-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S938959AbcJXPc2 (ORCPT + 1 other); Mon, 24 Oct 2016 11:32:28 -0400 Received: from mout.kundenserver.de ([212.227.126.187]:49876 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935768AbcJXPc1 (ORCPT ); Mon, 24 Oct 2016 11:32:27 -0400 Received: from wuerfel.lan. ([78.43.20.153]) by mrelayeu.kundenserver.de (mreue003) with ESMTPA (Nemesis) id 0M21dP-1cnDUS1Jxz-00u0Nk; Mon, 24 Oct 2016 17:32:23 +0200 From: Arnd Bergmann To: Dmitry Torokhov Cc: Arnd Bergmann , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] Input: tca8418_keypad: hide gcc-4.9 -Wmaybe-uninitialized warning Date: Mon, 24 Oct 2016 17:32:08 +0200 Message-Id: <20161024153222.2738294-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 MIME-Version: 1.0 X-Provags-ID: V03:K0:4a2Zgfj4OkGB6UuPZ6USnfHrJdljtox+OTbY511bj0OXfby7f6e hSQtmtcfMv7m0Iz2rhy5tsANCHZhwK/Q52XXcuD1XqOa8pOrXqory1tC5k3dzQvDcmJp/Is 3d1PljINj6fzPPFvuUYvn0I3/lkZJpzxqalWBTXJzlmdsFVkfzBa1CzmjICNa9OlPiYVsQ7 gG9xEMVqoS7+eZgl1zG1w== X-UI-Out-Filterresults: notjunk:1; V01:K0:Sg8VwHhTzIg=:6U5XwxwuOc6QwsJCea3x3a k/DIDGB3YLPdpvQ56bycLtXuFZxAaZnzinKCNsUatgyZK6ccoO6UZ9d12+mmAgT3vezvsExzA DybZv0qYX7J/fmYU6w/+hyr3aqLEMVkzDCeZoZ0OfGP7I/Q+de/BvzF5kJAOuHL2ugvxymwhg w6OyyOJWnWg41f7BvyrjGJRihK4pQDS8kdTmU6E3QYYuNnusV+xiDCVlA6uUO6m0iUOs/YWNe BdinXy5W3hZfn4MyGydZnnnUu5C/fngf94nJaDzYOx+e0z6kljAmXFUcp/vzJuwpFVy7tPC/x 5JBV7MbmEXPEk7QKKVLZ/H8nZNmaYjmXg33qKho8wPDYiJrP5pLg9vTmevbduqb6UbAYzVv4g ngvqVgAgNI2qM++0aBy5fRN+mW+E+bKFoewVsycdiUbGsmmP8PylKlVOgg5DRKgDAVmDnOH/i TEUzTL9dNy4pCQrLQUMjHIeJg9zZvjYoHmR2mFifr9bif8d9d+dxOKfj+LQufQjJvAXFW7JMZ 67owpqzK/x0YuusdLIDTzuoWdVvHxRhJRYshry6gT3ckruuI5RhRHVWhZvboxNiT2uXQeISJH NUqxggDm04xbAs6u8/7EpOJU9KJ28WvRDgSy1qZHidV8/ueTP51mgvZeWJiSgA35g6vDHmjo4 9jMNa6ekHYDLMlVfPrHmPkqkmlCnyuYnvyrKzouHnGLckAmdk4u2QbHtr5gkP90e0ve7Wd3JC jXJ/iwRDa2p9VA0Z Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Older versions of gcc warn about the tca8418_irq_handler function as they can't keep track of the variable assignment inside of the loop when using the -Wmaybe-unintialized flag: drivers/input/keyboard/tca8418_keypad.c: In function ‘tca8418_irq_handler’: drivers/input/keyboard/tca8418_keypad.c:172:9: error: ‘reg’ may be used uninitialized in this function [-Werror=maybe-uninitialized] drivers/input/keyboard/tca8418_keypad.c:165:5: note: ‘reg’ was declared here This is fixed in gcc-6, but it's possible to rearrange the code in a way that avoids the warning on older compilers as well. Signed-off-by: Arnd Bergmann --- drivers/input/keyboard/tca8418_keypad.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) -- 2.9.0 -- To unsubscribe from this list: send the line "unsubscribe linux-input" 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/drivers/input/keyboard/tca8418_keypad.c b/drivers/input/keyboard/tca8418_keypad.c index 9002298698fc..3048ef3e3e16 100644 --- a/drivers/input/keyboard/tca8418_keypad.c +++ b/drivers/input/keyboard/tca8418_keypad.c @@ -164,11 +164,18 @@ static void tca8418_read_keypad(struct tca8418_keypad *keypad_data) int error, col, row; u8 reg, state, code; - /* Initial read of the key event FIFO */ - error = tca8418_read_byte(keypad_data, REG_KEY_EVENT_A, ®); + do { + error = tca8418_read_byte(keypad_data, REG_KEY_EVENT_A, ®); + if (error < 0) { + dev_err(&keypad_data->client->dev, + "unable to read REG_KEY_EVENT_A\n"); + break; + } + + /* Assume that key code 0 signifies empty FIFO */ + if (reg <= 0) + break; - /* Assume that key code 0 signifies empty FIFO */ - while (error >= 0 && reg > 0) { state = reg & KEY_EVENT_VALUE; code = reg & KEY_EVENT_CODE; @@ -184,11 +191,7 @@ static void tca8418_read_keypad(struct tca8418_keypad *keypad_data) /* Read for next loop */ error = tca8418_read_byte(keypad_data, REG_KEY_EVENT_A, ®); - } - - if (error < 0) - dev_err(&keypad_data->client->dev, - "unable to read REG_KEY_EVENT_A\n"); + } while (1); input_sync(input); }