mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Antoniu Miclaus <antoniu.miclaus@analog.com>
To: "Lars-Peter Clausen" <lars@metafoo.de>,
	"Michael Hennerich" <Michael.Hennerich@analog.com>,
	"Antoniu Miclaus" <antoniu.miclaus@analog.com>,
	"Jonathan Cameron" <jic23@kernel.org>,
	"David Lechner" <dlechner@baylibre.com>,
	"Nuno Sá" <nuno.sa@analog.com>,
	"Andy Shevchenko" <andy@kernel.org>,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v3 5/6] iio: dac: ad7293: add dev variable and use dev_err_probe
Date: Wed, 25 Feb 2026 17:05:51 +0200	[thread overview]
Message-ID: <20260225150615.274078-6-antoniu.miclaus@analog.com> (raw)
In-Reply-To: <20260225150615.274078-1-antoniu.miclaus@analog.com>

Introduce a struct device *dev local variable and replace dev_err() +
return with dev_err_probe() in functions that use devm_ managed
resources. This simplifies error handling and ensures proper logging
of deferred probes.

Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
---
 drivers/iio/dac/ad7293.c | 32 ++++++++++++++++----------------
 1 file changed, 16 insertions(+), 16 deletions(-)

diff --git a/drivers/iio/dac/ad7293.c b/drivers/iio/dac/ad7293.c
index c3797e40cdd9..e26cc36e9270 100644
--- a/drivers/iio/dac/ad7293.c
+++ b/drivers/iio/dac/ad7293.c
@@ -776,27 +776,27 @@ static int ad7293_reset(struct ad7293_state *st)
 
 static int ad7293_properties_parse(struct ad7293_state *st)
 {
-	struct spi_device *spi = st->spi;
+	struct device *dev = &st->spi->dev;
 	int ret;
 
-	ret = devm_regulator_get_enable(&spi->dev, "avdd");
+	ret = devm_regulator_get_enable(dev, "avdd");
 	if (ret)
-		return dev_err_probe(&spi->dev, ret, "failed to enable AVDD\n");
+		return dev_err_probe(dev, ret, "failed to enable AVDD\n");
 
-	ret = devm_regulator_get_enable(&spi->dev, "vdrive");
+	ret = devm_regulator_get_enable(dev, "vdrive");
 	if (ret)
-		return dev_err_probe(&spi->dev, ret, "failed to enable VDRIVE\n");
+		return dev_err_probe(dev, ret, "failed to enable VDRIVE\n");
 
-	ret = devm_regulator_get_enable_optional(&spi->dev, "vrefin");
+	ret = devm_regulator_get_enable_optional(dev, "vrefin");
 	if (ret < 0 && ret != -ENODEV)
-		return dev_err_probe(&spi->dev, ret, "failed to enable VREFIN\n");
+		return dev_err_probe(dev, ret, "failed to enable VREFIN\n");
 
 	st->vrefin_en = ret != -ENODEV;
 
-	st->gpio_reset = devm_gpiod_get_optional(&st->spi->dev, "reset",
+	st->gpio_reset = devm_gpiod_get_optional(dev, "reset",
 						 GPIOD_OUT_HIGH);
 	if (IS_ERR(st->gpio_reset))
-		return dev_err_probe(&spi->dev, PTR_ERR(st->gpio_reset),
+		return dev_err_probe(dev, PTR_ERR(st->gpio_reset),
 				     "failed to get the reset GPIO\n");
 
 	return 0;
@@ -806,7 +806,7 @@ static int ad7293_init(struct ad7293_state *st)
 {
 	int ret;
 	u16 chip_id;
-	struct spi_device *spi = st->spi;
+	struct device *dev = &st->spi->dev;
 
 	ret = ad7293_properties_parse(st);
 	if (ret)
@@ -821,10 +821,9 @@ static int ad7293_init(struct ad7293_state *st)
 	if (ret)
 		return ret;
 
-	if (chip_id != AD7293_CHIP_ID) {
-		dev_err(&spi->dev, "Invalid Chip ID.\n");
-		return -EINVAL;
-	}
+	if (chip_id != AD7293_CHIP_ID)
+		return dev_err_probe(dev, -EINVAL,
+				     "Invalid Chip ID.\n");
 
 	if (!st->vrefin_en)
 		return __ad7293_spi_update_bits(st, AD7293_REG_GENERAL,
@@ -845,9 +844,10 @@ static int ad7293_probe(struct spi_device *spi)
 {
 	struct iio_dev *indio_dev;
 	struct ad7293_state *st;
+	struct device *dev = &spi->dev;
 	int ret;
 
-	indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
+	indio_dev = devm_iio_device_alloc(dev, sizeof(*st));
 	if (!indio_dev)
 		return -ENOMEM;
 
@@ -867,7 +867,7 @@ static int ad7293_probe(struct spi_device *spi)
 	if (ret)
 		return ret;
 
-	return devm_iio_device_register(&spi->dev, indio_dev);
+	return devm_iio_device_register(dev, indio_dev);
 }
 
 static const struct spi_device_id ad7293_id[] = {
-- 
2.43.0


  parent reply	other threads:[~2026-02-25 15:07 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-25 15:05 [PATCH v3 0/6] iio: use dev_err_probe in probe path for ADI drivers Antoniu Miclaus
2026-02-25 15:05 ` [PATCH v3 1/6] iio: frequency: adrf6780: add dev variable and use dev_err_probe Antoniu Miclaus
2026-02-25 15:05 ` [PATCH v3 2/6] iio: frequency: admv1014: " Antoniu Miclaus
2026-02-25 15:05 ` [PATCH v3 3/6] iio: frequency: admv1013: " Antoniu Miclaus
2026-02-25 15:05 ` [PATCH v3 4/6] iio: frequency: adf4377: " Antoniu Miclaus
2026-02-25 15:05 ` Antoniu Miclaus [this message]
2026-02-25 15:05 ` [PATCH v3 6/6] iio: filter: admv8818: " Antoniu Miclaus
2026-02-25 16:15 ` [PATCH v3 0/6] iio: use dev_err_probe in probe path for ADI drivers Andy Shevchenko
2026-02-27 11:23   ` Miclaus, Antoniu
2026-02-27 14:48     ` Andy Shevchenko

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=20260225150615.274078-6-antoniu.miclaus@analog.com \
    --to=antoniu.miclaus@analog.com \
    --cc=Michael.Hennerich@analog.com \
    --cc=andy@kernel.org \
    --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=nuno.sa@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®