Linux Input/HID development
 help / color / mirror / Atom feed
From: Vaishali Thakkar <vthakkar1994@gmail.com>
To: Support Opensource <support.opensource@diasemi.com>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	linux-input@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] Input: da9052_onkey: Convert to managed resources
Date: Mon, 27 Jul 2015 08:26:17 +0530	[thread overview]
Message-ID: <20150727025616.GA4227@vaishali-Ideapad-Z570> (raw)

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 <vthakkar1994@gmail.com>
---
 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;
 }
 
-- 
1.9.1


             reply	other threads:[~2015-07-27  2:56 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-27  2:56 Vaishali Thakkar [this message]
2015-08-04 12:52 ` [PATCH] Input: da9052_onkey: Convert to managed resources Opensource [Steve Twiss]
2015-10-02 17:43   ` Dmitry Torokhov
2015-10-02 18:35     ` Vaishali Thakkar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150727025616.GA4227@vaishali-Ideapad-Z570 \
    --to=vthakkar1994@gmail.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=support.opensource@diasemi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox