Skip to contentSkip to conversation

staging: iio: frequency: ad9832: use devm_mutex_init()

PATCH Applied Nithishvelan M 2 participants 2 messages Oct 31

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

PATCH v2 1/1 staging: iio: frequency: ad9832: use devm_mutex_init()

Replace mutex_init() with devm_mutex_init() in ad9832_probe() and check its return value. The driver already uses devm_* helpers for its other resources and has no remove() callback, so this ensures the mutex is destroyed automatically on teardown when mutex debugging is enabled.

No functional change intended. Compile-tested only.

---
Changes in v2:
- Add blank line after "st->spi = spi;" (Andy)

 drivers/staging/iio/frequency/ad9832.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/staging/iio/frequency/ad9832.c +4 -1
index 35f823f24f..e3b4e19a8d 100644
@@ -325,7 +325,10 @@ static int ad9832_probe(struct spi_device *spi)
 		return PTR_ERR(st->mclk);
 
 	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 = &ad9832_info;
Signature · 1 line
2.56.0
maintainer Applied
#1 lore raw
Quoted 9 lines · On Sat, 31 Oct 2026 14:42:36 +0530 Nithishvelan M <[email protected]>…

Replace mutex_init() with devm_mutex_init() in ad9832_probe() and check its return value. The driver already uses devm_* helpers for its other resources and has no remove() callback, so this ensures the mutex is destroyed automatically on teardown when mutex debugging is enabled.

No functional change intended. Compile-tested only.

Applied.

Thanks,

Jonathan

Quoted 23 lines

---
Changes in v2:
- Add blank line after "st->spi = spi;" (Andy)

 drivers/staging/iio/frequency/ad9832.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/staging/iio/frequency/ad9832.c +4 -1
index 35f823f24f..e3b4e19a8d 100644
@@ -325,7 +325,10 @@ static int ad9832_probe(struct spi_device *spi)
 		return PTR_ERR(st->mclk);
 
 	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 = &ad9832_info;