From patchwork Mon Jul 27 02:56:17 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaishali Thakkar X-Patchwork-Id: 6867901 Return-Path: X-Original-To: patchwork-linux-input@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 AB2E5C05AC for ; Mon, 27 Jul 2015 02:56:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B267E204D6 for ; Mon, 27 Jul 2015 02:56:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CBB2720461 for ; Mon, 27 Jul 2015 02:56:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755127AbbG0C4Y (ORCPT ); Sun, 26 Jul 2015 22:56:24 -0400 Received: from mail-pa0-f44.google.com ([209.85.220.44]:34484 "EHLO mail-pa0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755058AbbG0C4X (ORCPT ); Sun, 26 Jul 2015 22:56:23 -0400 Received: by pacan13 with SMTP id an13so44257943pac.1; Sun, 26 Jul 2015 19:56:23 -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:mime-version:content-type :content-disposition:user-agent; bh=dxAIiuBg6z69To+NYugSJwDR2D4iiqmPsvS7Rc0UhP8=; b=sxvkYuJfK0nhZ8LVwA/Ebckw9HsLfUudgt0HnV7UA57Zu3NDVVX66m8zfzqVOO0Qfk jkGJgf+fD7miekroON3V2Aj3UhN2W7ja/tCwkWNDYegfYwrCoGvygaxwNy1j6hycgdBx qaBuZLy1gT1e18g1F+3gLMqvMADKgRTk1huKURF45r3oIIGaNkB8dp3/Z8SlNt2yx7Yw lAPK1efOTd+VRe54cwoUJDqHr3R0AMIV/hXaOqt59c2AxDzcML1Ohyi8qlzASKuMwrXz WiW8O8pIrfWRtBJRZPc+EGqFHMyMXBljX9lw5el/LREYkraqpuN2WtY+PW1rSYda0OSv HZqw== X-Received: by 10.67.8.71 with SMTP id di7mr63959739pad.46.1437965783207; Sun, 26 Jul 2015 19:56:23 -0700 (PDT) Received: from vaishali-Ideapad-Z570 ([150.107.241.210]) by smtp.gmail.com with ESMTPSA id y6sm21062436pdl.61.2015.07.26.19.56.20 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 26 Jul 2015 19:56:22 -0700 (PDT) Date: Mon, 27 Jul 2015 08:26:17 +0530 From: Vaishali Thakkar To: Support Opensource Cc: Dmitry Torokhov , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] Input: da9052_onkey: Convert to managed resources Message-ID: <20150727025616.GA4227@vaishali-Ideapad-Z570> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Spam-Status: No, score=-6.8 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 Use managed resource functions devm_input_allocate_device and devm_kzalloc. To be compatible with the change, replace various gotos by direct returns and drop unneeded labels. Signed-off-by: Vaishali Thakkar Acked-by: Steve Twiss --- drivers/input/misc/da9052_onkey.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/drivers/input/misc/da9052_onkey.c b/drivers/input/misc/da9052_onkey.c index 266e07f..3243fe9 100644 --- a/drivers/input/misc/da9052_onkey.c +++ b/drivers/input/misc/da9052_onkey.c @@ -84,12 +84,11 @@ static int da9052_onkey_probe(struct platform_device *pdev) return -EINVAL; } - onkey = kzalloc(sizeof(*onkey), GFP_KERNEL); - input_dev = input_allocate_device(); + onkey = devm_kzalloc(&pdev->dev, sizeof(*onkey), GFP_KERNEL); + input_dev = devm_input_allocate_device(&pdev->dev); if (!onkey || !input_dev) { dev_err(&pdev->dev, "Failed to allocate memory\n"); - error = -ENOMEM; - goto err_free_mem; + return -ENOMEM; } onkey->input = input_dev; @@ -108,7 +107,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 +123,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; } @@ -138,9 +134,6 @@ static int da9052_onkey_remove(struct platform_device *pdev) da9052_free_irq(onkey->da9052, DA9052_IRQ_NONKEY, onkey); cancel_delayed_work_sync(&onkey->work); - input_unregister_device(onkey->input); - kfree(onkey); - return 0; }