From patchwork Fri Mar 27 16:47:44 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 6109561 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 1AAFCBF90F for ; Fri, 27 Mar 2015 16:52:10 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 18C11203C3 for ; Fri, 27 Mar 2015 16:52:09 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 15B23203AD for ; Fri, 27 Mar 2015 16:52:08 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1YbXQj-00013V-Ml; Fri, 27 Mar 2015 16:48:21 +0000 Received: from mail-ig0-x236.google.com ([2607:f8b0:4001:c05::236]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YbXQZ-0000s0-BP for linux-arm-kernel@lists.infradead.org; Fri, 27 Mar 2015 16:48:12 +0000 Received: by igbqf9 with SMTP id qf9so24955254igb.1 for ; Fri, 27 Mar 2015 09:47:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=Vm9skUHcrZX6oy9JI7wqxwfkTjPI7UwTnTYpaI720to=; b=PWiysmUikQi3wZjv/6lJ8i5qhwneoJCfRmIFN7wxpj5fAviUmw2JJvL9lRc+Q49e14 tN25+GwPBXTr7ATTBskJrtzQTvtHq/SwiPVGLnUg8uE+MsjYx4KxhfTGA/QlAoqdB7Ys /uNzWkiJ+8ufiIEJx15tHp8BlkLsmCmKIRNIu0UhwhrBZITsE4rq8W9UkKtiTc/YxtNw uZZNOFrl+lWFPgjtC6NuS8BGu8ErsM5LFPKUK1MPQUjNJrujWThKccjD+NN+cTIMtuCT ksNJPATS3qRM0iQ+jrY/RMtQPIzV8Mr3JkC/DUe6EnT7ENZ2AKGzkx9zXdNkBtoFqA7U ru+A== X-Received: by 10.107.134.219 with SMTP id q88mr29883345ioi.27.1427474868631; Fri, 27 Mar 2015 09:47:48 -0700 (PDT) Received: from dtor-ws ([2620:0:1000:1301:bc88:f86d:ed77:84eb]) by mx.google.com with ESMTPSA id c41sm1645440ioj.2.2015.03.27.09.47.46 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 27 Mar 2015 09:47:47 -0700 (PDT) Date: Fri, 27 Mar 2015 09:47:44 -0700 From: Dmitry Torokhov To: Linus Walleij Subject: Re: [PATCH 1/2] input: keypad: tc3589x: localize platform data Message-ID: <20150327164744.GA17364@dtor-ws> References: <1426776765-18812-1-git-send-email-linus.walleij@linaro.org> <1426776765-18812-2-git-send-email-linus.walleij@linaro.org> <20150319163856.GF30732@dtor-ws> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20150319163856.GF30732@dtor-ws> User-Agent: Mutt/1.5.21 (2010-09-15) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150327_094811_457988_C4C01C31 X-CRM114-Status: GOOD ( 28.85 ) X-Spam-Score: 1.7 (+) Cc: linux-input@vger.kernel.org, Lee Jones , Samuel Ortiz , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-1.6 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, SUSPICIOUS_RECIPS, T_DKIM_INVALID, T_RP_MATCHES_RCVD,UNPARSEABLE_RELAY autolearn=no version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Thu, Mar 19, 2015 at 09:38:56AM -0700, Dmitry Torokhov wrote: > Hi Linus, > > On Thu, Mar 19, 2015 at 03:52:44PM +0100, Linus Walleij wrote: > > This driver can only get its platform data from the device tree, > > and all platforms using it does that. Localize the platform data > > for the keypad. A later patch will enforce the device tree / OF > > dependence. > > > > Cc: Dmitry Torokhov > > Cc: Lee Jones > > Signed-off-by: Linus Walleij > > --- > > Dmitry it would be great if you could ACK this patch so Lee can > > take it with the other patch through MFD. > > It looks like if you are making this OF-only you can get rid of pdata > altogether and parse the OF data directly into the keypad. But that can > be done later. > > Acked-by: Dmitry Torokhov Hmm, just noticed an issue: > > > > keypad = kzalloc(sizeof(struct tc_keypad), GFP_KERNEL); > > + keypad->board = tc3589x_keypad_of_probe(&pdev->dev); > > + if (IS_ERR(keypad->board)) { > > + dev_err(&pdev->dev, "invalid keypad platform data\n"); > > + return PTR_ERR(keypad->board); > > + } > > + > > input = input_allocate_device(); > > if (!keypad || !input) { > > dev_err(&pdev->dev, "failed to allocate keypad memory\n"); You slid of prasing right in between memory allocation and checking if it succeeded, so there is a potential oops and memory leak now. I want to commit the version of the patch below, holler if you disagree. Note that I reverted much of plat -> board renames to keep the patch small. Thanks. Acked-by: Lee Jones diff --git a/drivers/input/keyboard/tc3589x-keypad.c b/drivers/input/keyboard/tc3589x-keypad.c index 5639325..ae90df3 100644 --- a/drivers/input/keyboard/tc3589x-keypad.c +++ b/drivers/input/keyboard/tc3589x-keypad.c @@ -70,6 +70,28 @@ #define TC3589x_KBD_INT_CLR 0x1 /** + * struct tc35893_keypad_platform_data - platform specific keypad data + * @keymap_data: matrix scan code table for keycodes + * @krow: mask for available rows, value is 0xFF + * @kcol: mask for available columns, value is 0xFF + * @debounce_period: platform specific debounce time + * @settle_time: platform specific settle down time + * @irqtype: type of interrupt, falling or rising edge + * @enable_wakeup: specifies if keypad event can wake up system from sleep + * @no_autorepeat: flag for auto repetition + */ +struct tc3589x_keypad_platform_data { + const struct matrix_keymap_data *keymap_data; + u8 krow; + u8 kcol; + u8 debounce_period; + u8 settle_time; + unsigned long irqtype; + bool enable_wakeup; + bool no_autorepeat; +}; + +/** * struct tc_keypad - data structure used by keypad driver * @tc3589x: pointer to tc35893 * @input: pointer to input device object @@ -363,13 +385,10 @@ static int tc3589x_keypad_probe(struct platform_device *pdev) const struct tc3589x_keypad_platform_data *plat; int error, irq; - plat = tc3589x->pdata->keypad; - if (!plat) { - plat = tc3589x_keypad_of_probe(&pdev->dev); - if (IS_ERR(plat)) { - dev_err(&pdev->dev, "invalid keypad platform data\n"); - return PTR_ERR(plat); - } + plat = tc3589x_keypad_of_probe(&pdev->dev); + if (IS_ERR(plat)) { + dev_err(&pdev->dev, "invalid keypad platform data\n"); + return PTR_ERR(plat); } irq = platform_get_irq(pdev, 0); diff --git a/include/linux/mfd/tc3589x.h b/include/linux/mfd/tc3589x.h index c203c9c..468c31a 100644 --- a/include/linux/mfd/tc3589x.h +++ b/include/linux/mfd/tc3589x.h @@ -140,36 +140,13 @@ extern int tc3589x_set_bits(struct tc3589x *tc3589x, u8 reg, u8 mask, u8 val); #define TC_KPD_DEBOUNCE_PERIOD 0xA3 #define TC_KPD_SETTLE_TIME 0xA3 -/** - * struct tc35893_platform_data - data structure for platform specific data - * @keymap_data: matrix scan code table for keycodes - * @krow: mask for available rows, value is 0xFF - * @kcol: mask for available columns, value is 0xFF - * @debounce_period: platform specific debounce time - * @settle_time: platform specific settle down time - * @irqtype: type of interrupt, falling or rising edge - * @enable_wakeup: specifies if keypad event can wake up system from sleep - * @no_autorepeat: flag for auto repetition - */ -struct tc3589x_keypad_platform_data { - const struct matrix_keymap_data *keymap_data; - u8 krow; - u8 kcol; - u8 debounce_period; - u8 settle_time; - unsigned long irqtype; - bool enable_wakeup; - bool no_autorepeat; -}; /** * struct tc3589x_platform_data - TC3589x platform data * @block: bitmask of blocks to enable (use TC3589x_BLOCK_*) - * @keypad: keypad-specific platform data */ struct tc3589x_platform_data { unsigned int block; - const struct tc3589x_keypad_platform_data *keypad; }; #endif