Skip to contentSkip to conversation

iio: accel: small cleanups and error-handling improvements

PATCH In review Sanjay Chitroda 4 participants 16 messages Apr 17 – Apr 19

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

cover iio: accel: small cleanups and error-handling improvements

From: Sanjay Chitroda <[email protected]>

Hi all,

This series contains a few small cleanups and robustness improvements to adxl313, adxl380, adxl355, adxl367 and adxl372 IIO accelerometer drivers.

The changes modernize mutex handling using devm-managed helpers. In addition, error handling during probe is cleaned up by switching to dev_err_probe() to better handle deferred probing.

Changes in v2:
- Drop guard() changes as it's already available in iio/testing.
- Rebase changes on top of iio/testing with guidance from Andy.
- Added new change for additional iio accel drivers.

No functional changes are intended.

Testing:
- Compiled with W=1
- Build-tested on QEMU x86_64

Thanks,
Sanjay Chitroda

Sanjay Chitroda (8):
iio: accel: adxl313_core: Use devm-managed mutex initialization
iio: accel: adxl313: Use dev_err_probe
iio: accel: adxl380: Use devm-managed mutex initialization
iio: accel: adxl355_core: Use devm-managed mutex initialization
iio: accel: adxl355: Use dev_err_probe
iio: accel: adxl367: Use devm-managed mutex initialization
iio: accel: adxl372: Use devm-managed mutex initialization
iio: accel: adxl372: Use dev_err_probe

 drivers/iio/accel/adxl313_core.c | 10 +++++-----
 drivers/iio/accel/adxl313_i2c.c  | 10 ++++------
 drivers/iio/accel/adxl313_spi.c  | 10 ++++------
 drivers/iio/accel/adxl355_core.c | 28 +++++++++++-----------------
 drivers/iio/accel/adxl355_i2c.c  | 11 ++++-------
 drivers/iio/accel/adxl355_spi.c  | 11 ++++-------
 drivers/iio/accel/adxl367.c      |  4 +++-
 drivers/iio/accel/adxl372.c      | 10 +++++-----
 drivers/iio/accel/adxl380.c      |  4 +++-
 9 files changed, 43 insertions(+), 55 deletions(-)

base-commit: 0ccdcdc698b7ba52f2c9bc09bfdf9f020ca0e6e6

Signature · 1 line
2.34.1
#1 lore raw

PATCH v2 1/8 iio: accel: adxl313_core: Use devm-managed mutex initialization

From: Sanjay Chitroda <[email protected]>

Use devm_mutex_init() to tie the mutex lifetime to the device and improve debugging when CONFIG_DEBUG_MUTEXES is enabled.

---
 drivers/iio/accel/adxl313_core.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/iio/accel/adxl313_core.c +3 -1
index bcc11dabdf22..1fc96b7b0f1f 100644
@@ -1240,7 +1240,9 @@ int adxl313_core_probe(struct device *dev,
 	data->regmap = regmap;
 	data->chip_info = chip_info;
 
-	mutex_init(&data->lock);
+	ret = devm_mutex_init(dev, &data->lock);
+	if (ret)
+		return ret;
 
 	indio_dev->name = chip_info->name;
 	indio_dev->info = &adxl313_info;
Signature · 1 line
2.34.1
#2 lore raw

PATCH v2 2/8 iio: accel: adxl313: Use dev_err_probe

In reply to Sanjay Chitroda

From: Sanjay Chitroda <[email protected]>

dev_err_probe() makes error code handling simpler and handles deferred probe nicely (avoid spamming logs).

---
 drivers/iio/accel/adxl313_core.c |  6 ++----
 drivers/iio/accel/adxl313_i2c.c  | 10 ++++------
 drivers/iio/accel/adxl313_spi.c  | 10 ++++------
 3 files changed, 10 insertions(+), 16 deletions(-)
drivers/iio/accel/adxl313_core.c +2 -4
index 1fc96b7b0f1f..6dc918c4ae17 100644
@@ -1252,10 +1252,8 @@ int adxl313_core_probe(struct device *dev,
 	indio_dev->available_scan_masks = adxl313_scan_masks;
 
 	ret = adxl313_setup(dev, data, setup);
-	if (ret) {
-		dev_err(dev, "ADXL313 setup failed\n");
-		return ret;
-	}
+	if (ret)
+		return dev_err_probe(dev, ret, "ADXL313 setup failed\n");
 
 	int_line = adxl313_get_int_type(dev, &irq);
 	if (int_line == ADXL313_INT_NONE) {
drivers/iio/accel/adxl313_i2c.c +4 -6
index b67ff0b4dc54..6736b83f23bd 100644
@@ -65,6 +65,7 @@ MODULE_DEVICE_TABLE(of, adxl313_of_match);
 static int adxl313_i2c_probe(struct i2c_client *client)
 {
 	const struct adxl313_chip_info *chip_data;
+	struct device *dev = &client->dev;
 	struct regmap *regmap;
 
 	/*
@@ -75,13 +76,10 @@ static int adxl313_i2c_probe(struct i2c_client *client)
 
 	regmap = devm_regmap_init_i2c(client,
 				      &adxl31x_i2c_regmap_config[chip_data->type]);
-	if (IS_ERR(regmap)) {
-		dev_err(&client->dev, "Error initializing i2c regmap: %ld\n",
-			PTR_ERR(regmap));
-		return PTR_ERR(regmap);
-	}
+	if (IS_ERR(regmap))
+		return dev_err_probe(dev, PTR_ERR(regmap), "Error initializing i2c regmap\n");
 
-	return adxl313_core_probe(&client->dev, regmap, chip_data, NULL);
+	return adxl313_core_probe(dev, regmap, chip_data, NULL);
 }
 
 static struct i2c_driver adxl313_i2c_driver = {
drivers/iio/accel/adxl313_spi.c +4 -6
index dedb0885c277..555c11b68421 100644
@@ -70,6 +70,7 @@ static int adxl313_spi_setup(struct device *dev, struct regmap *regmap)
 static int adxl313_spi_probe(struct spi_device *spi)
 {
 	const struct adxl313_chip_info *chip_data;
+	struct device *dev = &spi->dev;
 	struct regmap *regmap;
 	int ret;
 
@@ -83,13 +84,10 @@ static int adxl313_spi_probe(struct spi_device *spi)
 	regmap = devm_regmap_init_spi(spi,
 				      &adxl31x_spi_regmap_config[chip_data->type]);
 
-	if (IS_ERR(regmap)) {
-		dev_err(&spi->dev, "Error initializing spi regmap: %ld\n",
-			PTR_ERR(regmap));
-		return PTR_ERR(regmap);
-	}
+	if (IS_ERR(regmap))
+		return dev_err_probe(dev, PTR_ERR(regmap), "Error initializing spi regmap\n");
 
-	return adxl313_core_probe(&spi->dev, regmap,
+	return adxl313_core_probe(dev, regmap,
 				  chip_data, &adxl313_spi_setup);
 }
 
Signature · 1 line
2.34.1
#3 lore raw

Re: [PATCH v2 2/8] iio: accel: adxl313: Use dev_err_probe

Quoted 2 lines · Sanjay Chitroda

dev_err_probe() makes error code handling simpler and handles deferred probe nicely (avoid spamming logs).

In the Subject also should be "dev_err_probe()".

...

drivers/iio/accel/adxl313_spi.c static int adxl313_spi_probe(struct spi_device *spi) · line 91

Quoted 2 lines
drivers/iio/accel/adxl313_spi.c +1 -0
+	return adxl313_core_probe(dev, regmap,
 				  chip_data, &adxl313_spi_setup);

Now it may be a single line.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#4 lore raw

Re: [PATCH v2 2/8] iio: accel: adxl313: Use dev_err_probe

Quoted 7 lines · Andy Shevchenko
Quoted 2 lines · Sanjay Chitroda

dev_err_probe() makes error code handling simpler and handles deferred probe nicely (avoid spamming logs).

In the Subject also should be "dev_err_probe()".

Thank you for your input.

I agree, will rectify the same in next series/update.

Quoted 7 lines

...

drivers/iio/accel/adxl313_spi.c static int adxl313_spi_probe(struct spi_device *spi) · line 91

Quoted 2 lines
drivers/iio/accel/adxl313_spi.c +1 -0
+	return adxl313_core_probe(dev, regmap,
 				  chip_data, &adxl313_spi_setup);

Now it may be a single line.

It was the single line, length is reduced.

dev_err() was multi line in few driver; however with your input on dev dev_err_probe(dev, ...) become single line.

#5 lore raw

Re: [PATCH v2 2/8] iio: accel: adxl313: Use dev_err_probe

Quoted 2 lines · Sanjay Chitroda
Quoted 1 line · Andy Shevchenko

On Fri, Apr 17, 2026 at 06:19:18PM +0530, Sanjay Chitroda wrote:

...

Quoted 10 lines
Quoted 5 lines

drivers/iio/accel/adxl313_spi.c static int adxl313_spi_probe(struct spi_device *spi) · line 91

Quoted 2 lines
drivers/iio/accel/adxl313_spi.c +1 -0
+	return adxl313_core_probe(dev, regmap,
 				  chip_data, &adxl313_spi_setup);

Now it may be a single line.

It was the single line, length is reduced.

dev_err() was multi line in few driver; however with your input on dev dev_err_probe(dev, ...) become single line.

I haven't commented on that one, I left the line I commented on above. And I have checked, it's perfectly fits 80 characters.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#6 lore raw

PATCH v2 3/8 iio: accel: adxl380: Use devm-managed mutex initialization

In reply to Sanjay Chitroda

From: Sanjay Chitroda <[email protected]>

Use devm_mutex_init() to tie the mutex lifetime to the device and improve debugging when CONFIG_DEBUG_MUTEXES is enabled.

---
 drivers/iio/accel/adxl380.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/iio/accel/adxl380.c +3 -1
index e7bb32fbc475..7dca5523091f 100644
@@ -1967,7 +1967,9 @@ int adxl380_probe(struct device *dev, struct regmap *regmap,
 	st->chip_info = chip_info;
 	st->odr = ADXL380_ODR_DSM;
 
-	mutex_init(&st->lock);
+	ret = devm_mutex_init(dev, &st->lock);
+	if (ret)
+		return ret;
 
 	indio_dev->channels = adxl380_channels;
 	indio_dev->num_channels = ARRAY_SIZE(adxl380_channels);
Signature · 1 line
2.34.1
#7 lore raw

PATCH v2 4/8 iio: accel: adxl355_core: Use devm-managed mutex initialization

In reply to Sanjay Chitroda

From: Sanjay Chitroda <[email protected]>

Use devm_mutex_init() to tie the mutex lifetime to the device and improve debugging when CONFIG_DEBUG_MUTEXES is enabled.

---
 drivers/iio/accel/adxl355_core.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/iio/accel/adxl355_core.c +3 -1
index 8f90c58f4100..a310f8e37e3d 100644
@@ -802,7 +802,9 @@ int adxl355_core_probe(struct device *dev, struct regmap *regmap,
 	data->dev = dev;
 	data->op_mode = ADXL355_STANDBY;
 	data->chip_info = chip_info;
-	mutex_init(&data->lock);
+	ret = devm_mutex_init(dev, &data->lock);
+	if (ret)
+		return ret;
 
 	indio_dev->name = chip_info->name;
 	indio_dev->info = &adxl355_info;
Signature · 1 line
2.34.1
#8 lore raw

PATCH v2 5/8 iio: accel: adxl355: Use dev_err_probe

In reply to Sanjay Chitroda

From: Sanjay Chitroda <[email protected]>

dev_err_probe() makes error code handling simpler and handles deferred probe nicely (avoid spamming logs).

---
 drivers/iio/accel/adxl355_core.c | 24 ++++++++----------------
 drivers/iio/accel/adxl355_i2c.c  | 11 ++++-------
 drivers/iio/accel/adxl355_spi.c  | 11 ++++-------
 3 files changed, 16 insertions(+), 30 deletions(-)
drivers/iio/accel/adxl355_core.c +8 -16
index a310f8e37e3d..03e5744d9667 100644
@@ -336,10 +336,8 @@ static int adxl355_setup(struct adxl355_data *data)
 		return ret;
 
 	do {
-		if (--retries == 0) {
-			dev_err(data->dev, "Shadow registers mismatch\n");
-			return -EIO;
-		}
+		if (--retries == 0)
+			return dev_err_probe(data->dev, -EIO, "Shadow registers mismatch\n");
 
 		/*
 		 * Perform a software reset to make sure the device is in a consistent
@@ -775,10 +773,8 @@ static int adxl355_probe_trigger(struct iio_dev *indio_dev, int irq)
 				     irq);
 
 	ret = devm_iio_trigger_register(data->dev, data->dready_trig);
-	if (ret) {
-		dev_err(data->dev, "iio trigger register failed\n");
-		return ret;
-	}
+	if (ret)
+		return dev_err_probe(data->dev, ret, "iio trigger register failed\n");
 
 	indio_dev->trig = iio_trigger_get(data->dready_trig);
 
@@ -814,18 +810,14 @@ int adxl355_core_probe(struct device *dev, struct regmap *regmap,
 	indio_dev->available_scan_masks = adxl355_avail_scan_masks;
 
 	ret = adxl355_setup(data);
-	if (ret) {
-		dev_err(dev, "ADXL355 setup failed\n");
-		return ret;
-	}
+	if (ret)
+		return dev_err_probe(dev, ret, "ADXL355 setup failed\n");
 
 	ret = devm_iio_triggered_buffer_setup(dev, indio_dev,
 					      &iio_pollfunc_store_time,
 					      &adxl355_trigger_handler, NULL);
-	if (ret) {
-		dev_err(dev, "iio triggered buffer setup failed\n");
-		return ret;
-	}
+	if (ret)
+		return dev_err_probe(dev, ret, "iio triggered buffer setup failed\n");
 
 	irq = fwnode_irq_get_byname(dev_fwnode(dev), "DRDY");
 	if (irq > 0) {
drivers/iio/accel/adxl355_i2c.c +4 -7
index 1a512c7b792b..19490a6e1f35 100644
@@ -23,6 +23,7 @@ static const struct regmap_config adxl355_i2c_regmap_config = {
 static int adxl355_i2c_probe(struct i2c_client *client)
 {
 	struct regmap *regmap;
+	struct device *dev = &client->dev;
 	const struct adxl355_chip_info *chip_data;
 
 	chip_data = i2c_get_match_data(client);
@@ -30,14 +31,10 @@ static int adxl355_i2c_probe(struct i2c_client *client)
 		return -ENODEV;
 
 	regmap = devm_regmap_init_i2c(client, &adxl355_i2c_regmap_config);
-	if (IS_ERR(regmap)) {
-		dev_err(&client->dev, "Error initializing i2c regmap: %ld\n",
-			PTR_ERR(regmap));
+	if (IS_ERR(regmap))
+		return dev_err_probe(dev, PTR_ERR(regmap), "Error initializing i2c regmap\n");
 
-		return PTR_ERR(regmap);
-	}
-
-	return adxl355_core_probe(&client->dev, regmap, chip_data);
+	return adxl355_core_probe(dev, regmap, chip_data);
 }
 
 static const struct i2c_device_id adxl355_i2c_id[] = {
drivers/iio/accel/adxl355_spi.c +4 -7
index 869e3e57d6f7..347ed62b6582 100644
@@ -26,6 +26,7 @@ static const struct regmap_config adxl355_spi_regmap_config = {
 static int adxl355_spi_probe(struct spi_device *spi)
 {
 	const struct adxl355_chip_info *chip_data;
+	struct device *dev = &spi->dev;
 	struct regmap *regmap;
 
 	chip_data = spi_get_device_match_data(spi);
@@ -33,14 +34,10 @@ static int adxl355_spi_probe(struct spi_device *spi)
 		return -EINVAL;
 
 	regmap = devm_regmap_init_spi(spi, &adxl355_spi_regmap_config);
-	if (IS_ERR(regmap)) {
-		dev_err(&spi->dev, "Error initializing spi regmap: %ld\n",
-			PTR_ERR(regmap));
+	if (IS_ERR(regmap))
+		return dev_err_probe(dev, PTR_ERR(regmap), "Error initializing spi regmap\n");
 
-		return PTR_ERR(regmap);
-	}
-
-	return adxl355_core_probe(&spi->dev, regmap, chip_data);
+	return adxl355_core_probe(dev, regmap, chip_data);
 }
 
 static const struct spi_device_id adxl355_spi_id[] = {
Signature · 1 line
2.34.1
#9 lore raw

PATCH v2 6/8 iio: accel: adxl367: Use devm-managed mutex initialization

In reply to Sanjay Chitroda

From: Sanjay Chitroda <[email protected]>

Use devm_mutex_init() to tie the mutex lifetime to the device and improve debugging when CONFIG_DEBUG_MUTEXES is enabled.

---
 drivers/iio/accel/adxl367.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/iio/accel/adxl367.c +3 -1
index 0c04b2bb7efb..63a0b182824f 100644
@@ -1445,7 +1445,9 @@ int adxl367_probe(struct device *dev, const struct adxl367_ops *ops,
 	st->context = context;
 	st->ops = ops;
 
-	mutex_init(&st->lock);
+	ret = devm_mutex_init(dev, &st->lock);
+	if (ret)
+		return ret;
 
 	indio_dev->channels = adxl367_channels;
 	indio_dev->num_channels = ARRAY_SIZE(adxl367_channels);
Signature · 1 line
2.34.1
#10 lore raw

PATCH v2 7/8 iio: accel: adxl372: Use devm-managed mutex initialization

In reply to Sanjay Chitroda

From: Sanjay Chitroda <[email protected]>

Use devm_mutex_init() to tie the mutex lifetime to the device and improve debugging when CONFIG_DEBUG_MUTEXES is enabled.

---
 drivers/iio/accel/adxl372.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/iio/accel/adxl372.c +3 -1
index 545a21e5a308..1a6ba94f54f4 100644
@@ -1299,7 +1299,9 @@ int adxl372_probe(struct device *dev, struct regmap *regmap,
 	st->irq = irq;
 	st->chip_info = chip_info;
 
-	mutex_init(&st->threshold_m);
+	ret = devm_mutex_init(dev, &st->threshold_m);
+	if (ret < 0)
+		return ret;
 
 	indio_dev->channels = adxl372_channels;
 	indio_dev->num_channels = ARRAY_SIZE(adxl372_channels);
Signature · 1 line
2.34.1
#11 lore raw

PATCH v2 8/8 iio: accel: adxl372: Use dev_err_probe

In reply to Sanjay Chitroda

From: Sanjay Chitroda <[email protected]>

dev_err_probe() makes error code handling simpler and handles deferred probe nicely (avoid spamming logs).

---
 drivers/iio/accel/adxl372.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/iio/accel/adxl372.c +2 -4
index 1a6ba94f54f4..e375d068a3f5 100644
@@ -1316,10 +1316,8 @@ int adxl372_probe(struct device *dev, struct regmap *regmap,
 	}
 
 	ret = adxl372_setup(st);
-	if (ret < 0) {
-		dev_err(dev, "ADXL372 setup failed\n");
-		return ret;
-	}
+	if (ret < 0)
+		return dev_err_probe(dev, ret, "ADXL372 setup failed\n");
 
 	if (chip_info->fifo_supported) {
 		ret = adxl372_buffer_setup(indio_dev);
Signature · 1 line
2.34.1
#12 lore raw

Re: [PATCH v2 8/8] iio: accel: adxl372: Use dev_err_probe

Quoted 17 lines · Sanjay Chitroda

From: Sanjay Chitroda <[email protected]>

dev_err_probe() makes error code handling simpler and handles deferred probe nicely (avoid spamming logs).

---
drivers/iio/accel/adxl372.c | 6 ++----

1 file changed, 2 insertions(+), 4 deletions(-)
drivers/iio/accel/adxl372.c +0 -0
index 1a6ba94f54f4..e375d068a3f5 100644
@@ -1316,10 +1316,8 @@ int adxl372_probe(struct device *dev, struct regmap *regmap,
 	}
 

drivers/iio/accel/adxl372.c int adxl372_probe(struct device *dev, struct regmap *regmap, · line 1323

Quoted 10 lines
drivers/iio/accel/adxl372.c +2 -4
 	ret = adxl372_setup(st);
-	if (ret < 0) {
-		dev_err(dev, "ADXL372 setup failed\n");
-		return ret;
-	}
+	if (ret < 0)
+		return dev_err_probe(dev, ret, "ADXL372 setup failed\n");
 
 	if (chip_info->fifo_supported) {
 		ret = adxl372_buffer_setup(indio_dev);

Hi Cosmin,

Your email address listed in MAINTAINERS ([email protected]) appears to be bouncing.

I noticed recent commits from you using [email protected] and [email protected], so I plan to update the entry accordingly.

Could you please confirm whether you are still maintaining this subsystem with renesas/gmail account ?

Thanks,
Sanjay Chitroda

#13 lore raw

Re: [PATCH v2 8/8] iio: accel: adxl372: Use dev_err_probe

Quoted 33 lines · Sanjay Chitroda
Quoted 17 lines · Sanjay Chitroda

From: Sanjay Chitroda <[email protected]>

dev_err_probe() makes error code handling simpler and handles deferred probe nicely (avoid spamming logs).

---
drivers/iio/accel/adxl372.c | 6 ++----

1 file changed, 2 insertions(+), 4 deletions(-)
drivers/iio/accel/adxl372.c +0 -0
index 1a6ba94f54f4..e375d068a3f5 100644
@@ -1316,10 +1316,8 @@ int adxl372_probe(struct device *dev, struct regmap *regmap,
 	}
 

drivers/iio/accel/adxl372.c int adxl372_probe(struct device *dev, struct regmap *regmap, · line 1323

Quoted 10 lines
drivers/iio/accel/adxl372.c +2 -4
 	ret = adxl372_setup(st);
-	if (ret < 0) {
-		dev_err(dev, "ADXL372 setup failed\n");
-		return ret;
-	}
+	if (ret < 0)
+		return dev_err_probe(dev, ret, "ADXL372 setup failed\n");
 
 	if (chip_info->fifo_supported) {
 		ret = adxl372_buffer_setup(indio_dev);

Hi Cosmin,

Quoted 6 lines

Your email address listed in MAINTAINERS ([email protected]) appears to be bouncing.

I noticed recent commits from you using [email protected] and [email protected], so I plan to update the entry accordingly.

Could you please confirm whether you are still maintaining this subsystem with renesas/gmail account ?

Hi.

Someone at Analog should be taking over as maintainer, I don't work for Analog anymore.

CC Nuno
Quoted 2 lines

Thanks,
Sanjay Chitroda

maintainer
#14 lore raw
In reply to Sanjay Chitroda
Quoted 6 lines · On Fri, 17 Apr 2026 18:19:16 +0530 Sanjay Chitroda…

From: Sanjay Chitroda <[email protected]>

Hi all,

This series contains a few small cleanups and robustness improvements to adxl313, adxl380, adxl355, adxl367 and adxl372 IIO accelerometer drivers.

0/2 in patch title? It's fine for that bit to change from version to version.

Anyhow, I tweaked as Andy suggested whilst applying and picked up the lot.

Note however, that the advantage of devm_mutex_init() is minor at best, which is why we didn't bother with mutex_destroy() most of the time before this convenient way of calling it existed. Combined with dev_err_probe() being nice but minor cleanup, I'd generally reserved these sorts of changes for when someone is otherwise working on a driver or doing a more thorough modernisation.

I don't mind people doing this sort of thing for one of their first few patches, so what you have here is fine, but it's not suitable material for a mass cleanup of the whole subsystem!

Thanks,

Jonathan

Quoted 42 lines

The changes modernize mutex handling using devm-managed helpers. In addition, error handling during probe is cleaned up by switching to dev_err_probe() to better handle deferred probing.

Changes in v2:
- Drop guard() changes as it's already available in iio/testing.
- Rebase changes on top of iio/testing with guidance from Andy.
- Added new change for additional iio accel drivers.

No functional changes are intended.

Testing:
- Compiled with W=1
- Build-tested on QEMU x86_64

Thanks,
Sanjay Chitroda

Sanjay Chitroda (8):
iio: accel: adxl313_core: Use devm-managed mutex initialization
iio: accel: adxl313: Use dev_err_probe
iio: accel: adxl380: Use devm-managed mutex initialization
iio: accel: adxl355_core: Use devm-managed mutex initialization
iio: accel: adxl355: Use dev_err_probe
iio: accel: adxl367: Use devm-managed mutex initialization
iio: accel: adxl372: Use devm-managed mutex initialization
iio: accel: adxl372: Use dev_err_probe

 drivers/iio/accel/adxl313_core.c | 10 +++++-----
 drivers/iio/accel/adxl313_i2c.c  | 10 ++++------
 drivers/iio/accel/adxl313_spi.c  | 10 ++++------
 drivers/iio/accel/adxl355_core.c | 28 +++++++++++-----------------
 drivers/iio/accel/adxl355_i2c.c  | 11 ++++-------
 drivers/iio/accel/adxl355_spi.c  | 11 ++++-------
 drivers/iio/accel/adxl367.c      |  4 +++-
 drivers/iio/accel/adxl372.c      | 10 +++++-----
 drivers/iio/accel/adxl380.c      |  4 +++-
 9 files changed, 43 insertions(+), 55 deletions(-)

base-commit: 0ccdcdc698b7ba52f2c9bc09bfdf9f020ca0e6e6

#15 lore raw
Quoted 21 lines · Jonathan Cameron
Quoted 6 lines · On Fri, 17 Apr 2026 18:19:16 +0530 Sanjay Chitroda…

From: Sanjay Chitroda <[email protected]>

Hi all,

This series contains a few small cleanups and robustness improvements to adxl313, adxl380, adxl355, adxl367 and adxl372 IIO accelerometer drivers.

0/2 in patch title? It's fine for that bit to change from version to version.

Anyhow, I tweaked as Andy suggested whilst applying and picked up the lot.

Note however, that the advantage of devm_mutex_init() is minor at best, which is why we didn't bother with mutex_destroy() most of the time before this convenient way of calling it existed. Combined with dev_err_probe() being nice but minor cleanup, I'd generally reserved these sorts of changes for when someone is otherwise working on a driver or doing a more thorough modernisation.

Quoted 7 lines

I don't mind people doing this sort of thing for one of their first few patches, so what you have here is fine, but it's not suitable material for a mass cleanup of the whole subsystem!

Thanks,

Jonathan

Hi Jonathan,

Thank you for your input, assistance and considering the changes.

I understand and agree, will take care this part.

Quoted 44 lines
Quoted 43 lines

The changes modernize mutex handling using devm-managed helpers. In addition, error handling during probe is cleaned up by switching to dev_err_probe() to better handle deferred probing.

Changes in v2:
- Drop guard() changes as it's already available in iio/testing.
- Rebase changes on top of iio/testing with guidance from Andy.
- Added new change for additional iio accel drivers.

No functional changes are intended.

Testing:
- Compiled with W=1
- Build-tested on QEMU x86_64

Thanks,
Sanjay Chitroda

Sanjay Chitroda (8):
iio: accel: adxl313_core: Use devm-managed mutex initialization
iio: accel: adxl313: Use dev_err_probe
iio: accel: adxl380: Use devm-managed mutex initialization
iio: accel: adxl355_core: Use devm-managed mutex initialization
iio: accel: adxl355: Use dev_err_probe
iio: accel: adxl367: Use devm-managed mutex initialization
iio: accel: adxl372: Use devm-managed mutex initialization
iio: accel: adxl372: Use dev_err_probe

 drivers/iio/accel/adxl313_core.c | 10 +++++-----
 drivers/iio/accel/adxl313_i2c.c  | 10 ++++------
 drivers/iio/accel/adxl313_spi.c  | 10 ++++------
 drivers/iio/accel/adxl355_core.c | 28 +++++++++++-----------------
 drivers/iio/accel/adxl355_i2c.c  | 11 ++++-------
 drivers/iio/accel/adxl355_spi.c  | 11 ++++-------
 drivers/iio/accel/adxl367.c      |  4 +++-
 drivers/iio/accel/adxl372.c      | 10 +++++-----
 drivers/iio/accel/adxl380.c      |  4 +++-
 9 files changed, 43 insertions(+), 55 deletions(-)

base-commit: 0ccdcdc698b7ba52f2c9bc09bfdf9f020ca0e6e6