From: David Lechner <dlechner@baylibre.com>
To: Menderes Sabaz <sabazmenderes@gmail.com>,
lars@metafoo.de, Michael.Hennerich@analog.com, jic23@kernel.org
Cc: nuno.sa@analog.com, andy@kernel.org, linux-iio@vger.kernel.org
Subject: Re: [PATCH] iio: dac: ad5360: convert to guard(mutex)
Date: Wed, 28 Jan 2026 08:54:34 -0600 [thread overview]
Message-ID: <beadc1df-050a-40ae-af7d-409b2f13f30e@baylibre.com> (raw)
In-Reply-To: <20260128113751.258219-1-sabazmenderes@gmail.com>
On 1/28/26 5:37 AM, Menderes Sabaz wrote:
> Converting mutex_lock and mutex_unlock to guard(mutex)
> Simplify the locking logic by using guard(mutex).
> This removes the need for explicit unlock calls in error paths and
> simplifies the code by removing goto labels.
>
> Signed-off-by: Menderes Sabaz <sabazmenderes@gmail.com>
> ---
> drivers/iio/dac/ad5360.c | 12 +++---------
> 1 file changed, 3 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/iio/dac/ad5360.c b/drivers/iio/dac/ad5360.c
> index 8271849b1..a22bafa45 100644
> --- a/drivers/iio/dac/ad5360.c
> +++ b/drivers/iio/dac/ad5360.c
> @@ -209,10 +209,8 @@ static int ad5360_write(struct iio_dev *indio_dev, unsigned int cmd,
> int ret;
> struct ad5360_state *st = iio_priv(indio_dev);
>
> - mutex_lock(&st->lock);
> + guard(mutex)(&st->lock);
> ret = ad5360_write_unlocked(indio_dev, cmd, addr, val, shift);
> - mutex_unlock(&st->lock);
> -
> return ret;
> }
>
All of the `return ret` can be removed now and function calls can return
directly. Otherwise, this isn't really an improvement. Same applies below.
> @@ -232,7 +230,7 @@ static int ad5360_read(struct iio_dev *indio_dev, unsigned int type,
> },
> };
>
> - mutex_lock(&st->lock);
> + guard(mutex)(&st->lock);
>
> st->data[0].d32 = cpu_to_be32(AD5360_CMD(AD5360_CMD_SPECIAL_FUNCTION) |
> AD5360_ADDR(AD5360_REG_SF_READBACK) |
> @@ -243,8 +241,6 @@ static int ad5360_read(struct iio_dev *indio_dev, unsigned int type,
> if (ret >= 0)
> ret = be32_to_cpu(st->data[1].d32) & 0xffff;
>
> - mutex_unlock(&st->lock);
> -
> return ret;
> }
>
> @@ -264,7 +260,7 @@ static int ad5360_update_ctrl(struct iio_dev *indio_dev, unsigned int set,
> struct ad5360_state *st = iio_priv(indio_dev);
> int ret;
>
> - mutex_lock(&st->lock);
> + guard(mutex)(&st->lock);
>
> st->ctrl |= set;
> st->ctrl &= ~clr;
> @@ -272,8 +268,6 @@ static int ad5360_update_ctrl(struct iio_dev *indio_dev, unsigned int set,
> ret = ad5360_write_unlocked(indio_dev, AD5360_CMD_SPECIAL_FUNCTION,
> AD5360_REG_SF_CTRL, st->ctrl, 0);
>
> - mutex_unlock(&st->lock);
> -
> return ret;
> }
>
next prev parent reply other threads:[~2026-01-28 14:54 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-28 11:37 [PATCH] iio: dac: ad5360: convert to guard(mutex) Menderes Sabaz
2026-01-28 14:54 ` David Lechner [this message]
2026-01-28 15:32 ` [PATCH v2] " Menderes Sabaz
2026-01-28 22:32 ` Andy Shevchenko
2026-01-28 22:47 ` David Lechner
2026-01-28 23:14 ` [PATCH] iio: dac: ad5360: converting " Menderes Sabaz
2026-01-29 10:54 ` Andy Shevchenko
2026-01-29 16:16 ` [PATCH v2] iio: dac: ad5360: convert " Jonathan Cameron
2026-01-29 16:18 ` 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=beadc1df-050a-40ae-af7d-409b2f13f30e@baylibre.com \
--to=dlechner@baylibre.com \
--cc=Michael.Hennerich@analog.com \
--cc=andy@kernel.org \
--cc=jic23@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=nuno.sa@analog.com \
--cc=sabazmenderes@gmail.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