From patchwork Fri Aug 8 07:18:44 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: kiran.padwal@smartplayin.com X-Patchwork-Id: 4694521 Return-Path: X-Original-To: patchwork-linux-input@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 9EB159F377 for ; Fri, 8 Aug 2014 07:31:46 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CF07D2017D for ; Fri, 8 Aug 2014 07:31:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E1D252016C for ; Fri, 8 Aug 2014 07:31:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752575AbaHHHbo (ORCPT ); Fri, 8 Aug 2014 03:31:44 -0400 Received: from smtp72.ord1c.emailsrvr.com ([108.166.43.72]:57309 "EHLO smtp72.ord1c.emailsrvr.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751193AbaHHHbn (ORCPT ); Fri, 8 Aug 2014 03:31:43 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp10.relay.ord1c.emailsrvr.com (SMTP Server) with ESMTP id CBC1B38046D; Fri, 8 Aug 2014 03:21:28 -0400 (EDT) X-Virus-Scanned: OK Received: by smtp10.relay.ord1c.emailsrvr.com (Authenticated sender: kiran.padwal-AT-smartplayin.com) with ESMTPSA id 5DDDE38061B; Fri, 8 Aug 2014 03:21:26 -0400 (EDT) X-Sender-Id: kiran.padwal@smartplayin.com Received: from SPINITDTDL00291.smartplayin.local ([UNAVAILABLE]. [220.227.185.53]) (using TLSv1.1 with cipher DHE-RSA-AES256-SHA) by 0.0.0.0:587 (trex/5.2.10); Fri, 08 Aug 2014 07:21:28 GMT From: Kiran Padwal To: support.opensource@diasemi.com, dmitry.torokhov@gmail.com Cc: anthony.olech.opensource@diasemi.com, david.chen@diasemi.com, kiran.padwal21@gmail.com, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Kiran Padwal Subject: [PATCH] Input: da9052_onkey: convert to use devm_* Date: Fri, 8 Aug 2014 12:48:44 +0530 Message-Id: <1407482324-17713-1-git-send-email-kiran.padwal@smartplayin.com> X-Mailer: git-send-email 1.7.9.5 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 Converting to devm functions can make the code smaller and cleaner. Signed-off-by: Kiran Padwal --- drivers/input/misc/da9052_onkey.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/drivers/input/misc/da9052_onkey.c b/drivers/input/misc/da9052_onkey.c index 184c8f2..909441e 100644 --- a/drivers/input/misc/da9052_onkey.c +++ b/drivers/input/misc/da9052_onkey.c @@ -84,12 +84,14 @@ static int da9052_onkey_probe(struct platform_device *pdev) return -EINVAL; } - onkey = kzalloc(sizeof(*onkey), GFP_KERNEL); - input_dev = input_allocate_device(); - if (!onkey || !input_dev) { - dev_err(&pdev->dev, "Failed to allocate memory\n"); - error = -ENOMEM; - goto err_free_mem; + onkey = devm_kzalloc(&pdev->dev, sizeof(*onkey), GFP_KERNEL); + if (!onkey) + return -ENOMEM; + + input_dev = devm_input_allocate_device(&pdev->dev); + if (!input_dev) { + dev_err(&pdev->dev, "Failed to allocate input device\n"); + return -ENOMEM; } onkey->input = input_dev; @@ -108,7 +110,7 @@ static int da9052_onkey_probe(struct platform_device *pdev) if (error < 0) { dev_err(onkey->da9052->dev, "Failed to register ONKEY IRQ: %d\n", error); - goto err_free_mem; + return error; } error = input_register_device(onkey->input); @@ -124,9 +126,6 @@ static int da9052_onkey_probe(struct platform_device *pdev) err_free_irq: da9052_free_irq(onkey->da9052, DA9052_IRQ_NONKEY, onkey); cancel_delayed_work_sync(&onkey->work); -err_free_mem: - input_free_device(input_dev); - kfree(onkey); return error; } @@ -139,7 +138,6 @@ static int da9052_onkey_remove(struct platform_device *pdev) cancel_delayed_work_sync(&onkey->work); input_unregister_device(onkey->input); - kfree(onkey); return 0; }