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: 9392355 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D521C6077A for ; Mon, 24 Oct 2016 15:32:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C466729094 for ; Mon, 24 Oct 2016 15:32:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B75DD29164; Mon, 24 Oct 2016 15:32:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.4 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 980A929094 for ; Mon, 24 Oct 2016 15:32:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S938959AbcJXPc2 (ORCPT ); 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 X-Virus-Scanned: ClamAV using ClamSMTP 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(-) 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); }