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

Rodrigo Alencar via B4 Relay
2026-02-10T19:42:17Z

From: Rodrigo Alencar <rodrigo.alencar@analog.com>

Adopt proper mutex lifecycle with devm_mutex_init(), replacing
mutex_init(). Also, Include linux/mutex.h header.

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;

--
2.43.0