From patchwork Sat Mar 10 03:36:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gustavo A. R. Silva" X-Patchwork-Id: 10273173 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 EB0B1605CE for ; Sat, 10 Mar 2018 04:00:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D150F29F61 for ; Sat, 10 Mar 2018 04:00:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C3E6C29F66; Sat, 10 Mar 2018 04:00:51 +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.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable 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 53E4E29F61 for ; Sat, 10 Mar 2018 04:00:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932589AbeCJEAu (ORCPT ); Fri, 9 Mar 2018 23:00:50 -0500 Received: from gateway30.websitewelcome.com ([192.185.194.16]:34700 "EHLO gateway30.websitewelcome.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932299AbeCJEAu (ORCPT ); Fri, 9 Mar 2018 23:00:50 -0500 X-Greylist: delayed 1476 seconds by postgrey-1.27 at vger.kernel.org; Fri, 09 Mar 2018 23:00:50 EST Received: from cm10.websitewelcome.com (cm10.websitewelcome.com [100.42.49.4]) by gateway30.websitewelcome.com (Postfix) with ESMTP id 8ACD32997 for ; Fri, 9 Mar 2018 21:36:13 -0600 (CST) Received: from gator4166.hostgator.com ([108.167.133.22]) by cmsmtp with SMTP id uVIreOY8RcGlpuVIreGmym; Fri, 09 Mar 2018 21:36:13 -0600 Received: from [189.175.117.58] (port=39616 helo=embeddedgus) by gator4166.hostgator.com with esmtpa (Exim 4.89_1) (envelope-from ) id 1euVIr-003LvZ-6U; Fri, 09 Mar 2018 21:36:13 -0600 Date: Fri, 9 Mar 2018 21:36:12 -0600 From: "Gustavo A. R. Silva" To: Dmitry Torokhov Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" Subject: [PATCH v2] Input: stmpe-keypad - remove VLA usage Message-ID: <20180310033612.GA8010@embeddedgus> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator4166.hostgator.com X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - embeddedor.com X-BWhitelist: no X-Source-IP: 189.175.117.58 X-Source-L: No X-Exim-ID: 1euVIr-003LvZ-6U X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: (embeddedgus) [189.175.117.58]:39616 X-Source-Auth: gustavo@embeddedor.com X-Email-Count: 9 X-Source-Cap: Z3V6aWRpbmU7Z3V6aWRpbmU7Z2F0b3I0MTY2Lmhvc3RnYXRvci5jb20= X-Local-Domain: yes 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 In preparation to enabling -Wvla, remove VLA and replace it with a fixed-length array instead. Fixed as part of the directive to remove all VLAs from the kernel: https://lkml.org/lkml/2018/3/7/621 Signed-off-by: Gustavo A. R. Silva --- Changes in v2: - Update the code based on Dmitry Torokhov comments. Thanks Dmitry. drivers/input/keyboard/stmpe-keypad.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/input/keyboard/stmpe-keypad.c b/drivers/input/keyboard/stmpe-keypad.c index 8c6c0b9..d69e631 100644 --- a/drivers/input/keyboard/stmpe-keypad.c +++ b/drivers/input/keyboard/stmpe-keypad.c @@ -48,6 +48,14 @@ #define STMPE_KEYPAD_KEYMAP_MAX_SIZE \ (STMPE_KEYPAD_MAX_ROWS * STMPE_KEYPAD_MAX_COLS) + +#define STMPE1601_NUM_DATA 5 +#define STMPE2401_NUM_DATA 3 +#define STMPE2403_NUM_DATA 5 + +/* Make sure it covers all cases above */ +#define MAX_NUM_DATA 5 + /** * struct stmpe_keypad_variant - model-specific attributes * @auto_increment: whether the KPC_DATA_BYTE register address @@ -74,7 +82,7 @@ struct stmpe_keypad_variant { static const struct stmpe_keypad_variant stmpe_keypad_variants[] = { [STMPE1601] = { .auto_increment = true, - .num_data = 5, + .num_data = STMPE1601_NUM_DATA, .num_normal_data = 3, .max_cols = 8, .max_rows = 8, @@ -84,7 +92,7 @@ static const struct stmpe_keypad_variant stmpe_keypad_variants[] = { [STMPE2401] = { .auto_increment = false, .set_pullup = true, - .num_data = 3, + .num_data = STMPE2401_NUM_DATA, .num_normal_data = 2, .max_cols = 8, .max_rows = 12, @@ -94,7 +102,7 @@ static const struct stmpe_keypad_variant stmpe_keypad_variants[] = { [STMPE2403] = { .auto_increment = true, .set_pullup = true, - .num_data = 5, + .num_data = STMPE2403_NUM_DATA, .num_normal_data = 3, .max_cols = 8, .max_rows = 12, @@ -156,7 +164,7 @@ static irqreturn_t stmpe_keypad_irq(int irq, void *dev) struct stmpe_keypad *keypad = dev; struct input_dev *input = keypad->input; const struct stmpe_keypad_variant *variant = keypad->variant; - u8 fifo[variant->num_data]; + u8 fifo[MAX_NUM_DATA]; int ret; int i;