linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iio: as3935: Use devm_delayed_work_autocancel()
@ 2022-02-13 12:30 Christophe JAILLET
  2022-02-13 16:19 ` Jonathan Cameron
  0 siblings, 1 reply; 2+ messages in thread
From: Christophe JAILLET @ 2022-02-13 12:30 UTC (permalink / raw)
  To: Jonathan Cameron, Lars-Peter Clausen
  Cc: linux-kernel, kernel-janitors, Christophe JAILLET, linux-iio

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/iio/proximity/as3935.c | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)

diff --git a/drivers/iio/proximity/as3935.c b/drivers/iio/proximity/as3935.c
index bd7595db31d4..00e06491b188 100644
--- a/drivers/iio/proximity/as3935.c
+++ b/drivers/iio/proximity/as3935.c
@@ -12,6 +12,7 @@
 #include <linux/interrupt.h>
 #include <linux/delay.h>
 #include <linux/workqueue.h>
+#include <linux/devm-helpers.h>
 #include <linux/mutex.h>
 #include <linux/err.h>
 #include <linux/irq.h>
@@ -344,14 +345,6 @@ static SIMPLE_DEV_PM_OPS(as3935_pm_ops, as3935_suspend, as3935_resume);
 #define AS3935_PM_OPS NULL
 #endif
 
-static void as3935_stop_work(void *data)
-{
-	struct iio_dev *indio_dev = data;
-	struct as3935_state *st = iio_priv(indio_dev);
-
-	cancel_delayed_work_sync(&st->work);
-}
-
 static int as3935_probe(struct spi_device *spi)
 {
 	struct device *dev = &spi->dev;
@@ -432,8 +425,7 @@ static int as3935_probe(struct spi_device *spi)
 
 	calibrate_as3935(st);
 
-	INIT_DELAYED_WORK(&st->work, as3935_event_work);
-	ret = devm_add_action(dev, as3935_stop_work, indio_dev);
+	ret = devm_delayed_work_autocancel(dev, &st->work, as3935_event_work);
 	if (ret)
 		return ret;
 
-- 
2.32.0


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

* Re: [PATCH] iio: as3935: Use devm_delayed_work_autocancel()
  2022-02-13 12:30 [PATCH] iio: as3935: Use devm_delayed_work_autocancel() Christophe JAILLET
@ 2022-02-13 16:19 ` Jonathan Cameron
  0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2022-02-13 16:19 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: Lars-Peter Clausen, linux-kernel, kernel-janitors, linux-iio,
	Matt Ranostay

On Sun, 13 Feb 2022 13:30:11 +0100
Christophe JAILLET <christophe.jaillet@wanadoo.fr> 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>
Nice.

+CC Matt as it's his driver. As this is an obvious like for like replacement
I'll apply it now.

Applied to the togreg branch of iio.git and pushed out as testing
to let the autobuilders see if we missed anything.

Thanks,

Jonathan

> ---
>  drivers/iio/proximity/as3935.c | 12 ++----------
>  1 file changed, 2 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/iio/proximity/as3935.c b/drivers/iio/proximity/as3935.c
> index bd7595db31d4..00e06491b188 100644
> --- a/drivers/iio/proximity/as3935.c
> +++ b/drivers/iio/proximity/as3935.c
> @@ -12,6 +12,7 @@
>  #include <linux/interrupt.h>
>  #include <linux/delay.h>
>  #include <linux/workqueue.h>
> +#include <linux/devm-helpers.h>
>  #include <linux/mutex.h>
>  #include <linux/err.h>
>  #include <linux/irq.h>
> @@ -344,14 +345,6 @@ static SIMPLE_DEV_PM_OPS(as3935_pm_ops, as3935_suspend, as3935_resume);
>  #define AS3935_PM_OPS NULL
>  #endif
>  
> -static void as3935_stop_work(void *data)
> -{
> -	struct iio_dev *indio_dev = data;
> -	struct as3935_state *st = iio_priv(indio_dev);
> -
> -	cancel_delayed_work_sync(&st->work);
> -}
> -
>  static int as3935_probe(struct spi_device *spi)
>  {
>  	struct device *dev = &spi->dev;
> @@ -432,8 +425,7 @@ static int as3935_probe(struct spi_device *spi)
>  
>  	calibrate_as3935(st);
>  
> -	INIT_DELAYED_WORK(&st->work, as3935_event_work);
> -	ret = devm_add_action(dev, as3935_stop_work, indio_dev);
> +	ret = devm_delayed_work_autocancel(dev, &st->work, as3935_event_work);
>  	if (ret)
>  		return ret;
>  


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

end of thread, other threads:[~2022-02-13 16:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-13 12:30 [PATCH] iio: as3935: Use devm_delayed_work_autocancel() Christophe JAILLET
2022-02-13 16:19 ` Jonathan Cameron

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).