diff mbox series

power: supply: max14656: Use devm_work_autocancel()

Message ID e73d025d989444354d3e9a4c44feb806653424dd.1644753283.git.christophe.jaillet@wanadoo.fr
State Accepted
Commit d016fc7ab52ab378d8bc11ac6f7e326da7b7a625
Headers show
Series power: supply: max14656: Use devm_work_autocancel() | expand

Commit Message

Christophe JAILLET Feb. 13, 2022, 11:54 a.m. UTC
Use devm_delayed_work_autocancel() instead of hand writing it.
It saves a few lines of code.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 drivers/power/supply/max14656_charger_detector.c | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)

Comments

Sebastian Reichel Feb. 24, 2022, 11:23 a.m. UTC | #1
Hi,

On Sun, Feb 13, 2022 at 12:54:56PM +0100, Christophe JAILLET wrote:
> Use devm_delayed_work_autocancel() instead of hand writing it.
> It saves a few lines of code.
> 
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---

Thanks, queued.

-- Sebastian

>  drivers/power/supply/max14656_charger_detector.c | 15 ++++-----------
>  1 file changed, 4 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/power/supply/max14656_charger_detector.c b/drivers/power/supply/max14656_charger_detector.c
> index 3f49b29f3c88..fc36828895bf 100644
> --- a/drivers/power/supply/max14656_charger_detector.c
> +++ b/drivers/power/supply/max14656_charger_detector.c
> @@ -18,6 +18,7 @@
>  #include <linux/of_device.h>
>  #include <linux/workqueue.h>
>  #include <linux/power_supply.h>
> +#include <linux/devm-helpers.h>
>  
>  #define MAX14656_MANUFACTURER	"Maxim Integrated"
>  #define MAX14656_NAME		"max14656"
> @@ -233,14 +234,6 @@ static enum power_supply_property max14656_battery_props[] = {
>  	POWER_SUPPLY_PROP_MANUFACTURER,
>  };
>  
> -static void stop_irq_work(void *data)
> -{
> -	struct max14656_chip *chip = data;
> -
> -	cancel_delayed_work_sync(&chip->irq_work);
> -}
> -
> -
>  static int max14656_probe(struct i2c_client *client,
>  			  const struct i2c_device_id *id)
>  {
> @@ -286,10 +279,10 @@ static int max14656_probe(struct i2c_client *client,
>  		return -EINVAL;
>  	}
>  
> -	INIT_DELAYED_WORK(&chip->irq_work, max14656_irq_worker);
> -	ret = devm_add_action(dev, stop_irq_work, chip);
> +	ret = devm_delayed_work_autocancel(dev, &chip->irq_work,
> +					   max14656_irq_worker);
>  	if (ret) {
> -		dev_err(dev, "devm_add_action %d failed\n", ret);
> +		dev_err(dev, "devm_delayed_work_autocancel %d failed\n", ret);
>  		return ret;
>  	}
>  
> -- 
> 2.32.0
>
diff mbox series

Patch

diff --git a/drivers/power/supply/max14656_charger_detector.c b/drivers/power/supply/max14656_charger_detector.c
index 3f49b29f3c88..fc36828895bf 100644
--- a/drivers/power/supply/max14656_charger_detector.c
+++ b/drivers/power/supply/max14656_charger_detector.c
@@ -18,6 +18,7 @@ 
 #include <linux/of_device.h>
 #include <linux/workqueue.h>
 #include <linux/power_supply.h>
+#include <linux/devm-helpers.h>
 
 #define MAX14656_MANUFACTURER	"Maxim Integrated"
 #define MAX14656_NAME		"max14656"
@@ -233,14 +234,6 @@  static enum power_supply_property max14656_battery_props[] = {
 	POWER_SUPPLY_PROP_MANUFACTURER,
 };
 
-static void stop_irq_work(void *data)
-{
-	struct max14656_chip *chip = data;
-
-	cancel_delayed_work_sync(&chip->irq_work);
-}
-
-
 static int max14656_probe(struct i2c_client *client,
 			  const struct i2c_device_id *id)
 {
@@ -286,10 +279,10 @@  static int max14656_probe(struct i2c_client *client,
 		return -EINVAL;
 	}
 
-	INIT_DELAYED_WORK(&chip->irq_work, max14656_irq_worker);
-	ret = devm_add_action(dev, stop_irq_work, chip);
+	ret = devm_delayed_work_autocancel(dev, &chip->irq_work,
+					   max14656_irq_worker);
 	if (ret) {
-		dev_err(dev, "devm_add_action %d failed\n", ret);
+		dev_err(dev, "devm_delayed_work_autocancel %d failed\n", ret);
 		return ret;
 	}