iio: dac: Convert several drivers to devm_mutex_init()
Subsystems (5)
cover iio: dac: Convert several drivers to devm_mutex_init()
This series converts seven iio DAC/ADDAC drivers to use devm_mutex_init() instead of mutex_init(). These drivers currently call mutex_init() in probe but have no .remove() callback, so mutex_destroy() is never called on device unbind.
Same pattern already accepted in iio for other drivers (e.g. ad5446, ltc2688, ad7124, ad7606, vcnl4000, etc.).
David Carlier (7):
iio: dac: ad3552r: Use devm_mutex_init()
iio: dac: ad7303: Use devm_mutex_init()
iio: dac: ad5758: Use devm_mutex_init()
iio: dac: ad5755: Use devm_mutex_init()
iio: dac: ad5686: Use devm_mutex_init()
iio: dac: ltc2664: Use devm_mutex_init()
iio: addac: ad74115: Use devm_mutex_init()
drivers/iio/addac/ad74115.c | 5 ++++- drivers/iio/dac/ad3552r.c | 4 +++- drivers/iio/dac/ad5686.c | 4 +++- drivers/iio/dac/ad5755.c | 5 +++-- drivers/iio/dac/ad5758.c | 4 +++- drivers/iio/dac/ad7303.c | 4 +++- drivers/iio/dac/ltc2664.c | 4 +++- 7 files changed, 22 insertions(+), 8 deletions(-)
Signature · 1 line
2.53.0
PATCH 1/7 iio: dac: ad3552r: Use devm_mutex_init()
Use devm_mutex_init() which is helpful with CONFIG_DEBUG_MUTEXES.
--- drivers/iio/dac/ad3552r.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/iio/dac/ad3552r.c +3 -1
@@ -629,7 +629,9 @@ static int ad3552r_probe(struct spi_device *spi)if (!dac->model_data)return -EINVAL ; -mutex_init (&dac->lock); + err =devm_mutex_init (&spi->dev, &dac->lock); +if (err) +return err; err =ad3552r_init (dac);if (err)
Signature · 1 line
2.53.0
PATCH 2/7 iio: dac: ad7303: Use devm_mutex_init()
In reply to David CarlierUse devm_mutex_init() which is helpful with CONFIG_DEBUG_MUTEXES.
--- drivers/iio/dac/ad7303.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/iio/dac/ad7303.c +3 -1
@@ -218,7 +218,9 @@ static int ad7303_probe(struct spi_device *spi) st->spi = spi; -mutex_init (&st->lock); + ret =devm_mutex_init (&spi->dev, &st->lock); +if (ret) +return ret; st->vdd_reg =devm_regulator_get (&spi->dev,"Vdd" );if (IS_ERR (st->vdd_reg))
Signature · 1 line
2.53.0
PATCH 3/7 iio: dac: ad5758: Use devm_mutex_init()
In reply to David CarlierUse devm_mutex_init() which is helpful with CONFIG_DEBUG_MUTEXES.
--- drivers/iio/dac/ad5758.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/iio/dac/ad5758.c +3 -1
@@ -851,7 +851,9 @@ static int ad5758_probe(struct spi_device *spi) st->spi = spi; -mutex_init (&st->lock); + ret =devm_mutex_init (&spi->dev, &st->lock); +if (ret) +return ret; indio_dev->name =spi_get_device_id (spi)->name; indio_dev->info = &ad5758_info;
Signature · 1 line
2.53.0
PATCH 4/7 iio: dac: ad5755: Use devm_mutex_init()
In reply to David CarlierUse devm_mutex_init() which is helpful with CONFIG_DEBUG_MUTEXES.
--- drivers/iio/dac/ad5755.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/iio/dac/ad5755.c +3 -2
@@ -827,8 +827,9 @@ static int ad5755_probe(struct spi_device *spi) indio_dev->modes =INDIO_DIRECT_MODE ; indio_dev->num_channels =AD5755_NUM_CHANNELS ; -mutex_init (&st->lock); - + ret =devm_mutex_init (&spi->dev, &st->lock); +if (ret) +return ret; pdata =ad5755_parse_fw (&spi->dev);if (!pdata) {
Signature · 1 line
2.53.0
PATCH 5/7 iio: dac: ad5686: Use devm_mutex_init()
In reply to David CarlierUse devm_mutex_init() which is helpful with CONFIG_DEBUG_MUTEXES.
--- drivers/iio/dac/ad5686.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/iio/dac/ad5686.c +3 -1
@@ -494,7 +494,9 @@ int ad5686_probe(struct device *dev, indio_dev->channels = st->chip_info->channels; indio_dev->num_channels = st->chip_info->num_channels; -mutex_init (&st->lock); + ret =devm_mutex_init (dev, &st->lock); +if (ret) +return ret;switch (st->chip_info->regmap_type) {case AD5310_REGMAP :
Signature · 1 line
2.53.0
PATCH 6/7 iio: dac: ltc2664: Use devm_mutex_init()
In reply to David CarlierUse devm_mutex_init() which is helpful with CONFIG_DEBUG_MUTEXES.
--- drivers/iio/dac/ltc2664.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/iio/dac/ltc2664.c +3 -1
@@ -675,7 +675,9 @@ static int ltc2664_probe(struct spi_device *spi) st->chip_info = chip_info; -mutex_init (&st->lock); + ret =devm_mutex_init (dev, &st->lock); +if (ret) +return ret; st->regmap =devm_regmap_init_spi (spi, <c2664_regmap_config);if (IS_ERR (st->regmap))
Signature · 1 line
2.53.0
PATCH 7/7 iio: addac: ad74115: Use devm_mutex_init()
In reply to David CarlierUse devm_mutex_init() which is helpful with CONFIG_DEBUG_MUTEXES.
--- drivers/iio/addac/ad74115.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/iio/addac/ad74115.c +4 -1
@@ -1835,7 +1835,10 @@ static int ad74115_probe(struct spi_device *spi) st =iio_priv (indio_dev); st->spi = spi; -mutex_init (&st->lock); + ret =devm_mutex_init (dev, &st->lock); +if (ret) +return ret; +init_completion (&st->adc_data_completion); indio_dev->name =AD74115_NAME ;
Signature · 1 line
2.53.0
David Lechner
reviewerQuoted 9 lines · David Carlier
This series converts seven iio DAC/ADDAC drivers to use
devm_mutex_init()instead ofmutex_init(). These drivers currently callmutex_init()in probe but have no .remove() callback, somutex_destroy()is never called on device unbind.Same pattern already accepted in iio for other drivers (e.g. ad5446, ltc2688, ad7124, ad7606, vcnl4000, etc.).
Quoted 9 lines
David Carlier (7):
iio: dac: ad3552r: Usedevm_mutex_init()
iio: dac: ad7303: Usedevm_mutex_init()
iio: dac: ad5758: Usedevm_mutex_init()
iio: dac: ad5755: Usedevm_mutex_init()
iio: dac: ad5686: Usedevm_mutex_init()
iio: dac: ltc2664: Usedevm_mutex_init()
iio: addac: ad74115: Usedevm_mutex_init()
Jonathan has mentioned before that he doesn't care to take patches like this unless we are making other cleanups to the driver too. So we'll see what he says this time.
Jonathan Cameron
maintainerQuoted 20 lines · On Fri, 10 Apr 2026 15:03:33 -0500 David Lechner <[email protected]> wrote:
Quoted 9 lines · David Carlier
This series converts seven iio DAC/ADDAC drivers to use
devm_mutex_init()instead ofmutex_init(). These drivers currently callmutex_init()in probe but have no .remove() callback, somutex_destroy()is never called on device unbind.Same pattern already accepted in iio for other drivers (e.g. ad5446, ltc2688, ad7124, ad7606, vcnl4000, etc.).
Quoted 9 lines
David Carlier (7):
iio: dac: ad3552r: Usedevm_mutex_init()
iio: dac: ad7303: Usedevm_mutex_init()
iio: dac: ad5758: Usedevm_mutex_init()
iio: dac: ad5755: Usedevm_mutex_init()
iio: dac: ad5686: Usedevm_mutex_init()
iio: dac: ltc2664: Usedevm_mutex_init()
iio: addac: ad74115: Usedevm_mutex_init()
Quoted 4 lines
Jonathan has mentioned before that he doesn't care to take patches like this unless we are making other cleanups to the driver too. So we'll see what he says this time.
The one time I'm more flexible on taking small changes is when they come from someone new to the kernel. A quick look suggests that's not quite true of David, but David also doesn't seem to be an old hand. So I'll take this set, but no more of these please unless part of a more general cleanup of a driver. Maybe at somepoint in the future we'll have few enough of these that it makes sense to do this for all of them, but right now there are ~300 mutex_init() calls in IIO and don't want anywhere near that level of churn when there are more useful things to do!
Applied to the testing branch of iio.git.
Thanks,
Jonathan
Hi Jonathan and thanks for your review, I ll remember for next times. Cheers.
Quoted 43 lines · Jonathan Cameron
Quoted 20 lines · On Fri, 10 Apr 2026 15:03:33 -0500 David Lechner <[email protected]> wrote:
Quoted 9 lines · David Carlier
This series converts seven iio DAC/ADDAC drivers to use
devm_mutex_init()instead ofmutex_init(). These drivers currently callmutex_init()in probe but have no .remove() callback, somutex_destroy()is never called on device unbind.Same pattern already accepted in iio for other drivers (e.g. ad5446, ltc2688, ad7124, ad7606, vcnl4000, etc.).
Quoted 9 lines
David Carlier (7):
iio: dac: ad3552r: Usedevm_mutex_init()
iio: dac: ad7303: Usedevm_mutex_init()
iio: dac: ad5758: Usedevm_mutex_init()
iio: dac: ad5755: Usedevm_mutex_init()
iio: dac: ad5686: Usedevm_mutex_init()
iio: dac: ltc2664: Usedevm_mutex_init()
iio: addac: ad74115: Usedevm_mutex_init()Quoted 4 lines
Jonathan has mentioned before that he doesn't care to take patches like this unless we are making other cleanups to the driver too. So we'll see what he says this time.
The one time I'm more flexible on taking small changes is when they come from someone new to the kernel. A quick look suggests that's not quite true of David, but David also doesn't seem to be an old hand. So I'll take this set, but no more of these please unless part of a more general cleanup of a driver. Maybe at somepoint in the future we'll have few enough of these that it makes sense to do this for all of them, but right now there are ~300
mutex_init()calls in IIO and don't want anywhere near that level of churn when there are more useful things to do!Applied to the testing branch of iio.git.
Thanks,
Jonathan