Input: da9063 - use devm_delayed_work_autocancel()
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Tue, 1 Mar 2022 07:25:35 +0000 (23:25 -0800)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Tue, 1 Mar 2022 07:31:24 +0000 (23:31 -0800)
Use devm_delayed_work_autocancel() instead of hand-writing it.
This saves a few lines of code.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>
Link: https://lore.kernel.org/r/a76ac3f4c7aee205395b89b5b3f587e30a48df96.1645205312.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
drivers/input/misc/da9063_onkey.c

index 7985192..b14a389 100644 (file)
@@ -4,6 +4,7 @@
  * Copyright (C) 2015  Dialog Semiconductor Ltd.
  */
 
+#include <linux/devm-helpers.h>
 #include <linux/module.h>
 #include <linux/errno.h>
 #include <linux/input.h>
@@ -182,13 +183,6 @@ static irqreturn_t da9063_onkey_irq_handler(int irq, void *data)
        return IRQ_HANDLED;
 }
 
-static void da9063_cancel_poll(void *data)
-{
-       struct da9063_onkey *onkey = data;
-
-       cancel_delayed_work_sync(&onkey->work);
-}
-
 static int da9063_onkey_probe(struct platform_device *pdev)
 {
        struct da9063_onkey *onkey;
@@ -234,9 +228,8 @@ static int da9063_onkey_probe(struct platform_device *pdev)
 
        input_set_capability(onkey->input, EV_KEY, KEY_POWER);
 
-       INIT_DELAYED_WORK(&onkey->work, da9063_poll_on);
-
-       error = devm_add_action(&pdev->dev, da9063_cancel_poll, onkey);
+       error = devm_delayed_work_autocancel(&pdev->dev, &onkey->work,
+                                            da9063_poll_on);
        if (error) {
                dev_err(&pdev->dev,
                        "Failed to add cancel poll action: %d\n",