linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2/2] Input: da9055_onkey: convert to use devm_*
@ 2014-08-08  7:16 Kiran Padwal
  2014-08-08  7:42 ` Dmitry Torokhov
  0 siblings, 1 reply; 2+ messages in thread
From: Kiran Padwal @ 2014-08-08  7:16 UTC (permalink / raw)
  To: support.opensource, dmitry.torokhov
  Cc: anthony.olech.opensource, david.chen, kiran.padwal21, linux-input,
	linux-kernel, Kiran Padwal

Converting to devm functions can make the code smaller and cleaner.

Signed-off-by: Kiran Padwal <kiran.padwal@smartplayin.com>
---
 drivers/input/misc/da9055_onkey.c |   22 ++++++----------------
 1 file changed, 6 insertions(+), 16 deletions(-)

diff --git a/drivers/input/misc/da9055_onkey.c b/drivers/input/misc/da9055_onkey.c
index ed6eaa9..1a1e760 100644
--- a/drivers/input/misc/da9055_onkey.c
+++ b/drivers/input/misc/da9055_onkey.c
@@ -90,9 +90,9 @@ static int da9055_onkey_probe(struct platform_device *pdev)
 	if (!onkey)
 		return -ENOMEM;
 
-	input_dev = input_allocate_device();
+	input_dev = devm_input_allocate_device(&pdev->dev);
 	if (!input_dev) {
-		dev_err(&pdev->dev, "Failed to allocate memory\n");
+		dev_err(&pdev->dev, "Failed to allocate input device\n");
 		return -ENOMEM;
 	}
 
@@ -107,43 +107,33 @@ static int da9055_onkey_probe(struct platform_device *pdev)
 
 	INIT_DELAYED_WORK(&onkey->work, da9055_onkey_work);
 
-	err = request_threaded_irq(irq, NULL, da9055_onkey_irq,
+	err = devm_request_threaded_irq(&pdev->dev, irq, NULL, da9055_onkey_irq,
 				   IRQF_TRIGGER_HIGH | IRQF_ONESHOT,
 				   "ONKEY", onkey);
 	if (err < 0) {
 		dev_err(&pdev->dev,
 			"Failed to register ONKEY IRQ %d, error = %d\n",
 			irq, err);
-		goto err_free_input;
+		return err;
 	}
 
 	err = input_register_device(input_dev);
 	if (err) {
 		dev_err(&pdev->dev, "Unable to register input device, %d\n",
 			err);
-		goto err_free_irq;
+		cancel_delayed_work_sync(&onkey->work);
+		return err;
 	}
 
 	platform_set_drvdata(pdev, onkey);
 
 	return 0;
-
-err_free_irq:
-	free_irq(irq, onkey);
-	cancel_delayed_work_sync(&onkey->work);
-err_free_input:
-	input_free_device(input_dev);
-
-	return err;
 }
 
 static int da9055_onkey_remove(struct platform_device *pdev)
 {
 	struct da9055_onkey *onkey = platform_get_drvdata(pdev);
-	int irq = platform_get_irq_byname(pdev, "ONKEY");
 
-	irq = regmap_irq_get_virq(onkey->da9055->irq_data, irq);
-	free_irq(irq, onkey);
 	cancel_delayed_work_sync(&onkey->work);
 	input_unregister_device(onkey->input);
 
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH 2/2] Input: da9055_onkey: convert to use devm_*
  2014-08-08  7:16 [PATCH 2/2] Input: da9055_onkey: convert to use devm_* Kiran Padwal
@ 2014-08-08  7:42 ` Dmitry Torokhov
  0 siblings, 0 replies; 2+ messages in thread
From: Dmitry Torokhov @ 2014-08-08  7:42 UTC (permalink / raw)
  To: Kiran Padwal
  Cc: support.opensource, anthony.olech.opensource, david.chen,
	kiran.padwal21, linux-input, linux-kernel

Hi Kiran,

On Fri, Aug 08, 2014 at 12:46:52PM +0530, Kiran Padwal wrote:
> Converting to devm functions can make the code smaller and cleaner.

Unfortunately it also makes it incorrect. As presented this conversion
introduces race on driver removal. Before doing any more devm conversions
please try to spot it or ping me back in a couple of days if you'd like it
explained.

Thanks.

-- 
Dmitry

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-08-08  7:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-08  7:16 [PATCH 2/2] Input: da9055_onkey: convert to use devm_* Kiran Padwal
2014-08-08  7:42 ` Dmitry Torokhov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).