From: Krzysztof Kozlowski <krzk@kernel.org>
To: rodrigo.alencar@analog.com, linux-kernel@vger.kernel.org,
linux-iio@vger.kernel.org, devicetree@vger.kernel.org
Cc: Michael Hennerich <Michael.Hennerich@analog.com>,
Lars-Peter Clausen <lars@metafoo.de>,
Jonathan Cameron <jic23@kernel.org>,
David Lechner <dlechner@baylibre.com>,
Andy Shevchenko <andy@kernel.org>, Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>
Subject: Re: [PATCH 5/7] iio: amplifiers: ad8366: use cleanup.h mutex guard
Date: Mon, 19 Jan 2026 15:43:07 +0100 [thread overview]
Message-ID: <e5b175ae-34d4-47f2-92a4-2788f680da36@kernel.org> (raw)
In-Reply-To: <20260119-iio-ad8366-update-v1-5-8044e23e964a@analog.com>
On 19/01/2026 15:36, Rodrigo Alencar via B4 Relay wrote:
> From: Rodrigo Alencar <rodrigo.alencar@analog.com>
>
> Changes related to mutex handling:
> - use guard() from cleanup for mutex locking
> - replace mutex_init() for devm_mutex_init()
Why? We see all this from the diff but I do not see benefits.
>
> Signed-off-by: Rodrigo Alencar <rodrigo.alencar@analog.com>
> ---
> drivers/iio/amplifiers/ad8366.c | 14 +++++++++-----
> 1 file changed, 9 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/iio/amplifiers/ad8366.c b/drivers/iio/amplifiers/ad8366.c
> index 160a8ab0c2ee..26856cb4216e 100644
> --- a/drivers/iio/amplifiers/ad8366.c
> +++ b/drivers/iio/amplifiers/ad8366.c
> @@ -17,6 +17,7 @@
> * Copyright 2012-2026 Analog Devices Inc.
> */
>
> +#include <linux/cleanup.h>
> #include <linux/device.h>
> #include <linux/kernel.h>
> #include <linux/slab.h>
> @@ -164,7 +165,8 @@ static int ad8366_read_raw(struct iio_dev *indio_dev,
> int ret;
> int code, gain = 0;
>
> - mutex_lock(&st->lock);
> + guard(mutex)(&st->lock);
> +
> switch (m) {
> case IIO_CHAN_INFO_HARDWAREGAIN:
> code = st->ch[chan->channel];
> @@ -210,7 +212,6 @@ static int ad8366_read_raw(struct iio_dev *indio_dev,
> default:
> ret = -EINVAL;
> }
> - mutex_unlock(&st->lock);
This does not simplify code.
>
> return ret;
> };
> @@ -267,7 +268,8 @@ static int ad8366_write_raw(struct iio_dev *indio_dev,
> break;
> }
>
> - mutex_lock(&st->lock);
> + guard(mutex)(&st->lock);
Neither this.
> +
> switch (mask) {
> case IIO_CHAN_INFO_HARDWAREGAIN:
> st->ch[chan->channel] = code;
> @@ -276,7 +278,6 @@ static int ad8366_write_raw(struct iio_dev *indio_dev,
> default:
> ret = -EINVAL;
> }
> - mutex_unlock(&st->lock);
>
> return ret;
> }
> @@ -336,10 +337,13 @@ static int ad8366_probe(struct spi_device *spi)
> }
>
> spi_set_drvdata(spi, indio_dev);
> - mutex_init(&st->lock);
> st->spi = spi;
> st->type = spi_get_device_id(spi)->driver_data;
>
> + ret = devm_mutex_init(&spi->dev, &st->lock);
And this one actually has impact - missing mutex_destroy...
> + if (ret)
> + return ret;
> +
> switch (st->type) {
> case ID_AD8366:
> indio_dev->channels = ad8366_channels;
>
Best regards,
Krzysztof
next prev parent reply other threads:[~2026-01-19 14:43 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-19 14:36 [PATCH 0/7] iio: amplifiers: ad8366: driver update and dt support Rodrigo Alencar via B4 Relay
2026-01-19 14:36 ` [PATCH 1/7] MAINTAINERS: Add missing maintainer entry for AD8366 driver Rodrigo Alencar via B4 Relay
2026-01-19 14:36 ` [PATCH 2/7] dt-bindings: iio: amplifiers: Add AD8366 support Rodrigo Alencar via B4 Relay
2026-01-21 8:10 ` Krzysztof Kozlowski
2026-01-19 14:36 ` [PATCH 3/7] iio: amplifiers: ad8366: consume enable gpio for applicable parts Rodrigo Alencar via B4 Relay
2026-01-23 8:26 ` Jonathan Cameron
2026-01-19 14:36 ` [PATCH 4/7] iio: amplifiers: ad8366: Update device support Rodrigo Alencar via B4 Relay
2026-01-23 8:33 ` Jonathan Cameron
2026-01-23 8:38 ` Jonathan Cameron
2026-01-19 14:36 ` [PATCH 5/7] iio: amplifiers: ad8366: use cleanup.h mutex guard Rodrigo Alencar via B4 Relay
2026-01-19 14:43 ` Krzysztof Kozlowski [this message]
2026-01-23 8:36 ` Jonathan Cameron
2026-01-19 14:37 ` [PATCH 6/7] iio: amplifiers: ad8366: simplify resource management Rodrigo Alencar via B4 Relay
2026-01-19 14:45 ` Krzysztof Kozlowski
2026-01-19 14:37 ` [PATCH 7/7] iio: amplifiers: ad8366: add device tree support Rodrigo Alencar via B4 Relay
2026-01-19 14:47 ` Krzysztof Kozlowski
2026-01-23 8:42 ` 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=e5b175ae-34d4-47f2-92a4-2788f680da36@kernel.org \
--to=krzk@kernel.org \
--cc=Michael.Hennerich@analog.com \
--cc=andy@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dlechner@baylibre.com \
--cc=jic23@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=robh@kernel.org \
--cc=rodrigo.alencar@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
all inboxes | Powered by JetHome®