From: Jonathan Cameron <jic23@kernel.org>
To: Andy Shevchenko <andriy.shevchenko@intel.com>
Cc: Educg550 <educg550@usp.br>,
lars@metafoo.de, Michael.Hennerich@analog.com,
antoniu.miclaus@analog.com, 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: Tue, 5 May 2026 17:25:26 +0100 [thread overview]
Message-ID: <20260505172526.087ad783@jic23-huawei> (raw)
In-Reply-To: <afLwqYt_XUjeroGJ@ashevche-desk.local>
On Thu, 30 Apr 2026 09:03:21 +0300
Andy Shevchenko <andriy.shevchenko@intel.com> wrote:
> 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.
FWIW I prefer this option.
>
> Alternatively:
>
> scoped_guard(mutex, &st->lock)
> ret = adf4377_init(st);
> return notifier_from_errno(ret);
>
> > }
> >
> > return NOTIFY_OK;
>
next prev parent reply other threads:[~2026-05-05 16:25 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
2026-05-05 16:25 ` Jonathan Cameron [this message]
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=20260505172526.087ad783@jic23-huawei \
--to=jic23@kernel.org \
--cc=Michael.Hennerich@analog.com \
--cc=andriy.shevchenko@intel.com \
--cc=andy@kernel.org \
--cc=antoniu.miclaus@analog.com \
--cc=dlechner@baylibre.com \
--cc=educg550@usp.br \
--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