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

Signed-off-by: Kiran Padwal <[email protected]>
---
 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

--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to