Skip to contentSkip to conversation

iio: dac: Convert several drivers to devm_mutex_init()

PATCH In review David Carlier 3 participants 11 messages Apr 10 – Apr 20

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

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
#1 lore raw

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
index 93c33bc3e1be..a2713b0c176e 100644
@@ -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
#2 lore raw

PATCH 2/7 iio: dac: ad7303: Use devm_mutex_init()

In reply to David Carlier

Use 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
index a88cc639047d..1c2960fa9743 100644
@@ -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
#3 lore raw

PATCH 3/7 iio: dac: ad5758: Use devm_mutex_init()

In reply to David Carlier

Use 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
index 4ed4fda76ea9..8e6fb46cce4d 100644
@@ -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
#4 lore raw

PATCH 4/7 iio: dac: ad5755: Use devm_mutex_init()

In reply to David Carlier

Use 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
index d0e5f35462b1..cc6d56140d66 100644
@@ -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
#5 lore raw

PATCH 5/7 iio: dac: ad5686: Use devm_mutex_init()

In reply to David Carlier

Use 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
index 4b18498aa074..9a384c50929b 100644
@@ -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
#6 lore raw

PATCH 6/7 iio: dac: ltc2664: Use devm_mutex_init()

In reply to David Carlier

Use 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
index 67f14046cf77..616806615d3d 100644
@@ -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, &ltc2664_regmap_config);
 	if (IS_ERR(st->regmap))
Signature · 1 line
2.53.0
#7 lore raw

PATCH 7/7 iio: addac: ad74115: Use devm_mutex_init()

In reply to David Carlier

Use 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
index f8b04d86b01f..41e0b1d334cc 100644
@@ -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
reviewer
#8 lore raw
In reply to David Carlier
Quoted 9 lines · David Carlier

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.).

Quoted 9 lines

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()

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.

maintainer
#9 lore raw
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 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.).

Quoted 9 lines

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()

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

#10 lore raw

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 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.).

Quoted 9 lines

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()

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