linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iio: adc: xilinx-ams: Use devm_delayed_work_autocancel() to simplify code
@ 2022-02-13 18:29 Christophe JAILLET
  2022-02-20 11:45 ` Jonathan Cameron
  0 siblings, 1 reply; 4+ messages in thread
From: Christophe JAILLET @ 2022-02-13 18:29 UTC (permalink / raw)
  To: Anand Ashok Dumbre, Jonathan Cameron, Lars-Peter Clausen, Michal Simek
  Cc: linux-kernel, kernel-janitors, Christophe JAILLET, linux-iio,
	linux-arm-kernel

Use devm_delayed_work_autocancel() instead of hand writing it. This is
less verbose and saves a few lines of code.

devm_delayed_work_autocancel() uses devm_add_action() instead of
devm_add_action_or_reset(). This is fine, because if the underlying memory
allocation fails, no work has been scheduled yet. So there is nothing to
undo.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 drivers/iio/adc/xilinx-ams.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/drivers/iio/adc/xilinx-ams.c b/drivers/iio/adc/xilinx-ams.c
index 8343c5f74121..6ffddf4038b8 100644
--- a/drivers/iio/adc/xilinx-ams.c
+++ b/drivers/iio/adc/xilinx-ams.c
@@ -12,6 +12,7 @@
 #include <linux/bitfield.h>
 #include <linux/clk.h>
 #include <linux/delay.h>
+#include <linux/devm-helpers.h>
 #include <linux/interrupt.h>
 #include <linux/io.h>
 #include <linux/iopoll.h>
@@ -1348,11 +1349,6 @@ static void ams_clk_disable_unprepare(void *data)
 	clk_disable_unprepare(data);
 }
 
-static void ams_cancel_delayed_work(void *data)
-{
-	cancel_delayed_work(data);
-}
-
 static int ams_probe(struct platform_device *pdev)
 {
 	struct iio_dev *indio_dev;
@@ -1389,9 +1385,8 @@ static int ams_probe(struct platform_device *pdev)
 	if (ret < 0)
 		return ret;
 
-	INIT_DELAYED_WORK(&ams->ams_unmask_work, ams_unmask_worker);
-	ret = devm_add_action_or_reset(&pdev->dev, ams_cancel_delayed_work,
-				       &ams->ams_unmask_work);
+	ret = devm_delayed_work_autocancel(&pdev->dev, &ams->ams_unmask_work,
+					   ams_unmask_worker);
 	if (ret < 0)
 		return ret;
 
-- 
2.32.0


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

* Re: [PATCH] iio: adc: xilinx-ams: Use devm_delayed_work_autocancel() to simplify code
  2022-02-13 18:29 [PATCH] iio: adc: xilinx-ams: Use devm_delayed_work_autocancel() to simplify code Christophe JAILLET
@ 2022-02-20 11:45 ` Jonathan Cameron
  2022-02-21 10:02   ` Michal Simek
  0 siblings, 1 reply; 4+ messages in thread
From: Jonathan Cameron @ 2022-02-20 11:45 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: Anand Ashok Dumbre, Lars-Peter Clausen, Michal Simek,
	linux-kernel, kernel-janitors, linux-iio, linux-arm-kernel

On Sun, 13 Feb 2022 19:29:05 +0100
Christophe JAILLET <christophe.jaillet@wanadoo.fr> wrote:

> Use devm_delayed_work_autocancel() instead of hand writing it. This is
> less verbose and saves a few lines of code.
> 
> devm_delayed_work_autocancel() uses devm_add_action() instead of
> devm_add_action_or_reset(). This is fine, because if the underlying memory
> allocation fails, no work has been scheduled yet. So there is nothing to
> undo.
> 
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Looks good to me, but I'd ideally like some input from someone familiar with
the driver.

Thanks,

Jonathan

> ---
>  drivers/iio/adc/xilinx-ams.c | 11 +++--------
>  1 file changed, 3 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/iio/adc/xilinx-ams.c b/drivers/iio/adc/xilinx-ams.c
> index 8343c5f74121..6ffddf4038b8 100644
> --- a/drivers/iio/adc/xilinx-ams.c
> +++ b/drivers/iio/adc/xilinx-ams.c
> @@ -12,6 +12,7 @@
>  #include <linux/bitfield.h>
>  #include <linux/clk.h>
>  #include <linux/delay.h>
> +#include <linux/devm-helpers.h>
>  #include <linux/interrupt.h>
>  #include <linux/io.h>
>  #include <linux/iopoll.h>
> @@ -1348,11 +1349,6 @@ static void ams_clk_disable_unprepare(void *data)
>  	clk_disable_unprepare(data);
>  }
>  
> -static void ams_cancel_delayed_work(void *data)
> -{
> -	cancel_delayed_work(data);
> -}
> -
>  static int ams_probe(struct platform_device *pdev)
>  {
>  	struct iio_dev *indio_dev;
> @@ -1389,9 +1385,8 @@ static int ams_probe(struct platform_device *pdev)
>  	if (ret < 0)
>  		return ret;
>  
> -	INIT_DELAYED_WORK(&ams->ams_unmask_work, ams_unmask_worker);
> -	ret = devm_add_action_or_reset(&pdev->dev, ams_cancel_delayed_work,
> -				       &ams->ams_unmask_work);
> +	ret = devm_delayed_work_autocancel(&pdev->dev, &ams->ams_unmask_work,
> +					   ams_unmask_worker);
>  	if (ret < 0)
>  		return ret;
>  


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

* Re: [PATCH] iio: adc: xilinx-ams: Use devm_delayed_work_autocancel() to simplify code
  2022-02-20 11:45 ` Jonathan Cameron
@ 2022-02-21 10:02   ` Michal Simek
  2022-02-26 16:43     ` Jonathan Cameron
  0 siblings, 1 reply; 4+ messages in thread
From: Michal Simek @ 2022-02-21 10:02 UTC (permalink / raw)
  To: Jonathan Cameron, Christophe JAILLET
  Cc: Anand Ashok Dumbre, Lars-Peter Clausen, Michal Simek,
	linux-kernel, kernel-janitors, linux-iio, linux-arm-kernel

Hi,

On 2/20/22 12:45, Jonathan Cameron wrote:
> On Sun, 13 Feb 2022 19:29:05 +0100
> Christophe JAILLET <christophe.jaillet@wanadoo.fr> wrote:
> 
>> Use devm_delayed_work_autocancel() instead of hand writing it. This is
>> less verbose and saves a few lines of code.
>>
>> devm_delayed_work_autocancel() uses devm_add_action() instead of
>> devm_add_action_or_reset(). This is fine, because if the underlying memory
>> allocation fails, no work has been scheduled yet. So there is nothing to
>> undo.
>>
>> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> Looks good to me, but I'd ideally like some input from someone familiar with
> the driver.

Anand told me that the change is fine that's why here is my
Acked-by: Michal Simek <michal.simek@xilinx.com>

Jonathan: Anand decided to do change in his carrier that's why that emails won't 
go through. But I am still around if you need something xilinx/amd to test.

Thanks,
Michal

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

* Re: [PATCH] iio: adc: xilinx-ams: Use devm_delayed_work_autocancel() to simplify code
  2022-02-21 10:02   ` Michal Simek
@ 2022-02-26 16:43     ` Jonathan Cameron
  0 siblings, 0 replies; 4+ messages in thread
From: Jonathan Cameron @ 2022-02-26 16:43 UTC (permalink / raw)
  To: Michal Simek
  Cc: Christophe JAILLET, Anand Ashok Dumbre, Lars-Peter Clausen,
	Michal Simek, linux-kernel, kernel-janitors, linux-iio,
	linux-arm-kernel

On Mon, 21 Feb 2022 11:02:00 +0100
Michal Simek <monstr@monstr.eu> wrote:

> Hi,
> 
> On 2/20/22 12:45, Jonathan Cameron wrote:
> > On Sun, 13 Feb 2022 19:29:05 +0100
> > Christophe JAILLET <christophe.jaillet@wanadoo.fr> wrote:
> >   
> >> Use devm_delayed_work_autocancel() instead of hand writing it. This is
> >> less verbose and saves a few lines of code.
> >>
> >> devm_delayed_work_autocancel() uses devm_add_action() instead of
> >> devm_add_action_or_reset(). This is fine, because if the underlying memory
> >> allocation fails, no work has been scheduled yet. So there is nothing to
> >> undo.
> >>
> >> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>  
> > Looks good to me, but I'd ideally like some input from someone familiar with
> > the driver.  
> 
> Anand told me that the change is fine that's why here is my
> Acked-by: Michal Simek <michal.simek@xilinx.com>
> 
> Jonathan: Anand decided to do change in his carrier that's why that emails won't 
> go through. But I am still around if you need something xilinx/amd to test.
> 
> Thanks,
> Michal

Thanks Michal and best wishes to Anand for whatever comes next!

Applied to the togreg branch of iio.git and pushed out as testing for
0-day to take a quick look before I expose this to linux-next.

Thanks,

Jonathan



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

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

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-13 18:29 [PATCH] iio: adc: xilinx-ams: Use devm_delayed_work_autocancel() to simplify code Christophe JAILLET
2022-02-20 11:45 ` Jonathan Cameron
2022-02-21 10:02   ` Michal Simek
2022-02-26 16:43     ` 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).