diff mbox

[PATCHv3,3/3] Input: twl4030-pwrbutton: simplify driver using devm_*

Message ID 1382546835-20212-4-git-send-email-sre@debian.org
State New, archived
Headers show

Commit Message

Sebastian Reichel Oct. 23, 2013, 4:47 p.m. UTC
Use managed irq resource to simplify the driver.

Signed-off-by: Sebastian Reichel <sre@debian.org>
---
 drivers/input/misc/twl4030-pwrbutton.c | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)

Comments

Aaro Koskinen Oct. 23, 2013, 5:25 p.m. UTC | #1
Hi,

On Wed, Oct 23, 2013 at 06:47:15PM +0200, Sebastian Reichel wrote:
>  static int __exit twl4030_pwrbutton_remove(struct platform_device *pdev)
>  {
>  	struct input_dev *pwr = platform_get_drvdata(pdev);
> -	int irq = platform_get_irq(pdev, 0);
>  
> -	free_irq(irq, pwr);
>  	input_unregister_device(pwr);

The same bug still exists. You don't need to unregister manually any more,
this whole function can be just reduced to "return 0;".

A.
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Felipe Balbi Oct. 23, 2013, 5:44 p.m. UTC | #2
On Wed, Oct 23, 2013 at 08:25:24PM +0300, Aaro Koskinen wrote:
> Hi,
> 
> On Wed, Oct 23, 2013 at 06:47:15PM +0200, Sebastian Reichel wrote:
> >  static int __exit twl4030_pwrbutton_remove(struct platform_device *pdev)
> >  {
> >  	struct input_dev *pwr = platform_get_drvdata(pdev);
> > -	int irq = platform_get_irq(pdev, 0);
> >  
> > -	free_irq(irq, pwr);
> >  	input_unregister_device(pwr);
> 
> The same bug still exists. You don't need to unregister manually any more,
> this whole function can be just reduced to "return 0;".

then it can be removed altogether, no ?
diff mbox

Patch

diff --git a/drivers/input/misc/twl4030-pwrbutton.c b/drivers/input/misc/twl4030-pwrbutton.c
index 3efbb13..91bb497 100644
--- a/drivers/input/misc/twl4030-pwrbutton.c
+++ b/drivers/input/misc/twl4030-pwrbutton.c
@@ -58,7 +58,7 @@  static int twl4030_pwrbutton_probe(struct platform_device *pdev)
 	int irq = platform_get_irq(pdev, 0);
 	int err;
 
-	pwr = input_allocate_device();
+	pwr = devm_input_allocate_device(&pdev->dev);
 	if (!pwr) {
 		dev_err(&pdev->dev, "Can't allocate power button\n");
 		return -ENOMEM;
@@ -70,37 +70,29 @@  static int twl4030_pwrbutton_probe(struct platform_device *pdev)
 	pwr->phys = "twl4030_pwrbutton/input0";
 	pwr->dev.parent = &pdev->dev;
 
-	err = request_threaded_irq(irq, NULL, powerbutton_irq,
+	err = devm_request_threaded_irq(&pwr->dev, irq, NULL, powerbutton_irq,
 			IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING,
 			"twl4030_pwrbutton", pwr);
 	if (err < 0) {
 		dev_err(&pdev->dev, "Can't get IRQ for pwrbutton: %d\n", err);
-		goto free_input_dev;
+		return err;
 	}
 
 	err = input_register_device(pwr);
 	if (err) {
 		dev_err(&pdev->dev, "Can't register power button: %d\n", err);
-		goto free_irq;
+		return err;
 	}
 
 	platform_set_drvdata(pdev, pwr);
 
 	return 0;
-
-free_irq:
-	free_irq(irq, pwr);
-free_input_dev:
-	input_free_device(pwr);
-	return err;
 }
 
 static int __exit twl4030_pwrbutton_remove(struct platform_device *pdev)
 {
 	struct input_dev *pwr = platform_get_drvdata(pdev);
-	int irq = platform_get_irq(pdev, 0);
 
-	free_irq(irq, pwr);
 	input_unregister_device(pwr);
 
 	return 0;