From patchwork Sat Sep 14 19:52:23 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manish Badarkhe X-Patchwork-Id: 2893751 Return-Path: X-Original-To: patchwork-linux-samsung-soc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 488179F1C0 for ; Sat, 14 Sep 2013 19:52:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 716B3202C7 for ; Sat, 14 Sep 2013 19:52:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 82C7F202C0 for ; Sat, 14 Sep 2013 19:52:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932371Ab3INTwY (ORCPT ); Sat, 14 Sep 2013 15:52:24 -0400 Received: from mail-pa0-f46.google.com ([209.85.220.46]:44927 "EHLO mail-pa0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932242Ab3INTwY (ORCPT ); Sat, 14 Sep 2013 15:52:24 -0400 Received: by mail-pa0-f46.google.com with SMTP id fa1so3850772pad.33 for ; Sat, 14 Sep 2013 12:52:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=onqw78b5uQEAshEnIuAk64eS45gE7Zj3aVCx5W+asB4=; b=KdXYdf9PhSrcJwgWS6ILQkit138FDzji/PxOOScaK2UhtJQ5xukXyESjFItyPY8DGL qAvSpRz4K/O74j4dV8aFWhoc1OmTxR9fLUA9F9WyWPEeWMxVtp5dXkai7vYKB7jgVXS0 mrjwYGLbF5YFS2L3Evx4LIA2EAVJacu62Cf59h3JQZ1U+g+rp/AhZR6eZ4aI5ERdAMiJ imZjSlVBIKtJ2VqHS9mqFj9srGy101RUbVHWAHgakh+PlhHjTntElpnU2wbTlhoGl1Dv GvRM0Sav7G2NOFZU0rJj5lqoPR1qisn7dbUw6+TOQvwq95IWpDJvSIhY3GlyESk2f7oL /4lg== X-Received: by 10.68.87.98 with SMTP id w2mr13220050pbz.109.1379188343670; Sat, 14 Sep 2013 12:52:23 -0700 (PDT) Received: from localhost.localdomain ([113.193.149.80]) by mx.google.com with ESMTPSA id cx4sm20099993pbc.24.1969.12.31.16.00.00 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 14 Sep 2013 12:52:23 -0700 (PDT) From: Manish Badarkhe To: linux-tegra@vger.kernel.org, linux-samsung-soc@vger.kernel.org Cc: dmitry.torokhov@gmail.com Subject: [PATCH] Input: gpio-keys - update to devm_* API Date: Sun, 15 Sep 2013 01:22:23 +0530 Message-Id: <1379188343-18904-1-git-send-email-badarkhe.manish@gmail.com> X-Mailer: git-send-email 1.7.10.4 Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham 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 Update the code to use devm_* API so that driver core will manage resources. Signed-off-by: Manish Badarkhe --- :100644 100644 440ce32... b4db721... M drivers/input/keyboard/gpio_keys.c drivers/input/keyboard/gpio_keys.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c index 440ce32..b4db721 100644 --- a/drivers/input/keyboard/gpio_keys.c +++ b/drivers/input/keyboard/gpio_keys.c @@ -588,7 +588,7 @@ gpio_keys_get_devtree_pdata(struct device *dev) goto err_out; } - pdata = kzalloc(sizeof(*pdata) + nbuttons * (sizeof *button), + pdata = devm_kzalloc(dev, sizeof(*pdata) + nbuttons * (sizeof(*button)), GFP_KERNEL); if (!pdata) { error = -ENOMEM; @@ -618,7 +618,7 @@ gpio_keys_get_devtree_pdata(struct device *dev) dev_err(dev, "Failed to get gpio flags, error: %d\n", error); - goto err_free_pdata; + goto err_out; } button = &pdata->buttons[i++]; @@ -630,7 +630,7 @@ gpio_keys_get_devtree_pdata(struct device *dev) dev_err(dev, "Button without keycode: 0x%x\n", button->gpio); error = -EINVAL; - goto err_free_pdata; + goto err_out; } button->desc = of_get_property(pp, "label", NULL); @@ -647,13 +647,11 @@ gpio_keys_get_devtree_pdata(struct device *dev) if (pdata->nbuttons == 0) { error = -EINVAL; - goto err_free_pdata; + goto err_out; } return pdata; -err_free_pdata: - kfree(pdata); err_out: return ERR_PTR(error); } @@ -699,10 +697,10 @@ static int gpio_keys_probe(struct platform_device *pdev) return PTR_ERR(pdata); } - ddata = kzalloc(sizeof(struct gpio_keys_drvdata) + + ddata = devm_kzalloc(&pdev->dev, sizeof(struct gpio_keys_drvdata) + pdata->nbuttons * sizeof(struct gpio_button_data), GFP_KERNEL); - input = input_allocate_device(); + input = devm_input_allocate_device(&pdev->dev); if (!ddata || !input) { dev_err(dev, "failed to allocate state\n"); error = -ENOMEM; @@ -768,8 +766,6 @@ static int gpio_keys_probe(struct platform_device *pdev) gpio_remove_key(&ddata->data[i]); fail1: - input_free_device(input); - kfree(ddata); /* If we have no platform data, we allocated pdata dynamically. */ if (!dev_get_platdata(&pdev->dev)) kfree(pdata); @@ -796,8 +792,6 @@ static int gpio_keys_remove(struct platform_device *pdev) if (!dev_get_platdata(&pdev->dev)) kfree(ddata->pdata); - kfree(ddata); - return 0; }