]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
iio: amplifiers: ad8366: use devm_mutex_init() and drop mutex_init()
authorRodrigo Alencar <rodrigo.alencar@analog.com>
Mon, 16 Feb 2026 17:10:49 +0000 (17:10 +0000)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Mon, 23 Feb 2026 21:00:57 +0000 (21:00 +0000)
Adopt proper mutex lifecycle with devm_mutex_init(), replacing
mutex_init(). Mutex init is moved up (before regulator init),
so that goto statement in the error path is avoided (which will
be cleaned up later).

Signed-off-by: Rodrigo Alencar <rodrigo.alencar@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/amplifiers/ad8366.c

index 677d02f4f075784d6a3ae884243230a1a87e3059..6466f3eb6bbccdd7de72521347775753db8795be 100644 (file)
@@ -259,6 +259,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);
@@ -267,7 +271,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;