All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sanjay Chitroda <sanjayembeddedse@gmail.com>
To: lucas.p.stankus@gmail.com, lars@metafoo.de,
	Michael.Hennerich@analog.com, jic23@kernel.org,
	puranjay@kernel.org, cosmin.tanislav@analog.com,
	marcelo.schmitt@analog.com, antoniu.miclaus@analog.com,
	ramona.gradinariu@analog.com
Cc: dlechner@baylibre.com, nuno.sa@analog.com, andy@kernel.org,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v2 2/8] iio: accel: adxl313: Use dev_err_probe
Date: Fri, 17 Apr 2026 18:19:18 +0530	[thread overview]
Message-ID: <20260417124924.353189-3-sanjayembedded@gmail.com> (raw)
In-Reply-To: <20260417124924.353189-1-sanjayembedded@gmail.com>

From: Sanjay Chitroda <sanjayembeddedse@gmail.com>

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

Signed-off-by: Sanjay Chitroda <sanjayembeddedse@gmail.com>
---
 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(-)

diff --git a/drivers/iio/accel/adxl313_core.c b/drivers/iio/accel/adxl313_core.c
index 1fc96b7b0f1f..6dc918c4ae17 100644
--- a/drivers/iio/accel/adxl313_core.c
+++ b/drivers/iio/accel/adxl313_core.c
@@ -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) {
diff --git a/drivers/iio/accel/adxl313_i2c.c b/drivers/iio/accel/adxl313_i2c.c
index b67ff0b4dc54..6736b83f23bd 100644
--- a/drivers/iio/accel/adxl313_i2c.c
+++ b/drivers/iio/accel/adxl313_i2c.c
@@ -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 = {
diff --git a/drivers/iio/accel/adxl313_spi.c b/drivers/iio/accel/adxl313_spi.c
index dedb0885c277..555c11b68421 100644
--- a/drivers/iio/accel/adxl313_spi.c
+++ b/drivers/iio/accel/adxl313_spi.c
@@ -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);
 }
 
-- 
2.34.1


  parent reply	other threads:[~2026-04-17 12:49 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-17 12:49 [PATCH 0/2] iio: accel: small cleanups and error-handling improvements Sanjay Chitroda
2026-04-17 12:49 ` [PATCH v2 1/8] iio: accel: adxl313_core: Use devm-managed mutex initialization Sanjay Chitroda
2026-04-17 12:49 ` Sanjay Chitroda [this message]
2026-04-17 18:35   ` [PATCH v2 2/8] iio: accel: adxl313: Use dev_err_probe Andy Shevchenko
2026-04-17 18:47     ` Sanjay Chitroda
2026-04-18  0:15       ` Andy Shevchenko
2026-04-17 12:49 ` [PATCH v2 3/8] iio: accel: adxl380: Use devm-managed mutex initialization Sanjay Chitroda
2026-04-17 12:49 ` [PATCH v2 4/8] iio: accel: adxl355_core: " Sanjay Chitroda
2026-04-17 12:49 ` [PATCH v2 5/8] iio: accel: adxl355: Use dev_err_probe Sanjay Chitroda
2026-04-17 12:49 ` [PATCH v2 6/8] iio: accel: adxl367: Use devm-managed mutex initialization Sanjay Chitroda
2026-04-17 12:49 ` [PATCH v2 7/8] iio: accel: adxl372: " Sanjay Chitroda
2026-04-17 12:49 ` [PATCH v2 8/8] iio: accel: adxl372: Use dev_err_probe Sanjay Chitroda
2026-04-17 19:20   ` Sanjay Chitroda
2026-04-18  7:01     ` Cosmin Tanislav
2026-04-19 16:34 ` [PATCH 0/2] iio: accel: small cleanups and error-handling improvements Jonathan Cameron
2026-04-19 17:19   ` Sanjay Chitroda

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260417124924.353189-3-sanjayembedded@gmail.com \
    --to=sanjayembeddedse@gmail.com \
    --cc=Michael.Hennerich@analog.com \
    --cc=andy@kernel.org \
    --cc=antoniu.miclaus@analog.com \
    --cc=cosmin.tanislav@analog.com \
    --cc=dlechner@baylibre.com \
    --cc=jic23@kernel.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lucas.p.stankus@gmail.com \
    --cc=marcelo.schmitt@analog.com \
    --cc=nuno.sa@analog.com \
    --cc=puranjay@kernel.org \
    --cc=ramona.gradinariu@analog.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.