public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Cc: Anand Ashok Dumbre <anand.ashok.dumbre@xilinx.com>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Michal Simek <michal.simek@xilinx.com>,
	linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org,
	linux-iio@vger.kernel.org, linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] iio: adc: xilinx-ams: Use devm_delayed_work_autocancel() to simplify code
Date: Sun, 20 Feb 2022 11:45:52 +0000	[thread overview]
Message-ID: <20220220114552.53fedd33@jic23-huawei> (raw)
In-Reply-To: <2626e6a057e40cd2271ef0e5f81d12e607bad5b4.1644776929.git.christophe.jaillet@wanadoo.fr>

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;
>  


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2022-02-20 11:40 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2022-02-21 10:02   ` Michal Simek
2022-02-26 16:43     ` Jonathan Cameron

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220220114552.53fedd33@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=anand.ashok.dumbre@xilinx.com \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=lars@metafoo.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michal.simek@xilinx.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox