Re: [PATCH v4 05/11] iio: amplifiers: ad8366: use devm_mutex_init() and drop mutex_init()

Jonathan Cameron
2026-02-14T18:36:27Z

On Tue, 10 Feb 2026 19:42:05 +0000
Rodrigo Alencar via B4 Relay <devnull+rodrigo.alencar.analog.com@kernel.org> wrote:

> From: Rodrigo Alencar <rodrigo.alencar@analog.com>
>
> Adopt proper mutex lifecycle with devm_mutex_init(), replacing
> mutex_init(). Also, Include linux/mutex.h header.

Why move the *mutex_init()? Even if it is just because it looks better there,
not breaking up spi related stuff, then say that.

>
> Signed-off-by: Rodrigo Alencar <rodrigo.alencar@analog.com>
> ---
> drivers/iio/amplifiers/ad8366.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/iio/amplifiers/ad8366.c b/drivers/iio/amplifiers/ad8366.c
> index 3456a31cb1ee..f0053a09cbb6 100644
> --- a/drivers/iio/amplifiers/ad8366.c
> +++ b/drivers/iio/amplifiers/ad8366.c
> @@ -15,6 +15,7 @@
> #include <linux/err.h>
> #include <linux/gpio/consumer.h>
> #include <linux/module.h>
> +#include <linux/mutex.h>
> #include <linux/regulator/consumer.h>
> #include <linux/spi/spi.h>
>
> @@ -251,6 +252,10 @@ static int ad8366_probe(struct spi_device *spi)
>
> st = iio_priv(indio_dev);
>
> + ret = devm_mutex_init(dev, &st->lock);
> + if (ret)
> + return ret;
> +
> st->reg = devm_regulator_get(&spi->dev, "vcc");
> if (!IS_ERR(st->reg)) {
> ret = regulator_enable(st->reg);
> @@ -259,7 +264,6 @@ 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;
>
>