Linux IIO development
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Educg550 <educg550@usp.br>
Cc: lars@metafoo.de, Michael.Hennerich@analog.com,
	antoniu.miclaus@analog.com, jic23@kernel.org,
	dlechner@baylibre.com, nuno.sa@analog.com, andy@kernel.org,
	Lucca Ciriac <luccaciriac@usp.br>,
	linux-iio@vger.kernel.org
Subject: Re: [PATCH] iio: frequency: adf4377: replace mutex_lock/unlock with guard and scoped_guard
Date: Thu, 30 Apr 2026 09:03:21 +0300	[thread overview]
Message-ID: <afLwqYt_XUjeroGJ@ashevche-desk.local> (raw)
In-Reply-To: <20260429202304.25308-1-educg550@usp.br>

On Wed, Apr 29, 2026 at 05:23:04PM -0300, Educg550 wrote:

> Replace manual mutex_lock()/mutex_unlock() calls with guard(mutex) and
> scoped_guard(mutex) from cleanup.h.

...

>  static int adf4377_freq_change(struct notifier_block *nb, unsigned long action, void *data)
>  {
>  	struct adf4377_state *st = container_of(nb, struct adf4377_state, nb);
> -	int ret;
>  
>  	if (action == POST_RATE_CHANGE) {
> -		mutex_lock(&st->lock);
> -		ret = notifier_from_errno(adf4377_init(st));
> -		mutex_unlock(&st->lock);
> -		return ret;
> +		scoped_guard(mutex, &st->lock)
> +			return notifier_from_errno(adf4377_init(st));

The scoped_guard() makes more sense when we have some code in between before
returning, here the guard()() fits much better.

Alternatively:

		scoped_guard(mutex, &st->lock)
			ret = adf4377_init(st);
		return notifier_from_errno(ret);

>  	}
>  
>  	return NOTIFY_OK;

-- 
With Best Regards,
Andy Shevchenko



  reply	other threads:[~2026-04-30  6:03 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-29 20:23 [PATCH] iio: frequency: adf4377: replace mutex_lock/unlock with guard and scoped_guard Educg550
2026-04-30  6:03 ` Andy Shevchenko [this message]
2026-05-05 16:25   ` Jonathan Cameron
2026-05-05 16:25 ` Jonathan Cameron
  -- strict thread matches above, loose matches on Subject: below --
2026-05-06 14:43 Educg550
2026-05-06 14:57 ` Joshua Crofts
2026-05-07 16:24 ` 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=afLwqYt_XUjeroGJ@ashevche-desk.local \
    --to=andriy.shevchenko@intel.com \
    --cc=Michael.Hennerich@analog.com \
    --cc=andy@kernel.org \
    --cc=antoniu.miclaus@analog.com \
    --cc=dlechner@baylibre.com \
    --cc=educg550@usp.br \
    --cc=jic23@kernel.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=luccaciriac@usp.br \
    --cc=nuno.sa@analog.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