[PATCH v2 8/8] iio: dac: ds4424: ratelimit read errors and use device context

Oleksij Rempel posted 8 patches 1 week, 6 days ago
There is a newer version of this series
[PATCH v2 8/8] iio: dac: ds4424: ratelimit read errors and use device context
Posted by Oleksij Rempel 1 week, 6 days ago
Replace pr_err() with dev_err_ratelimited() in the RAW read path to avoid
log spam on repeated I2C failures and to include the device context.

Use %pe to print errno names for faster debugging.

Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
---
changes v2:
- Update error message
- Rebase against regmap refactoring
---
 drivers/iio/dac/ds4424.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/iio/dac/ds4424.c b/drivers/iio/dac/ds4424.c
index 891069d8c80a..3e762d4e84ef 100644
--- a/drivers/iio/dac/ds4424.c
+++ b/drivers/iio/dac/ds4424.c
@@ -151,8 +151,9 @@ static int ds4424_read_raw(struct iio_dev *indio_dev,
 		ret = regmap_read(data->regmap, DS4424_DAC_ADDR(chan->channel),
 				  &regval);
 		if (ret < 0) {
-			pr_err("%s : regmap_read returned %d\n",
-						__func__, ret);
+			dev_err_ratelimited(&indio_dev->dev,
+					    "Failed to read channel %d:  %pe\n",
+					    chan->channel, ERR_PTR(ret));
 			return ret;
 		}
 
-- 
2.47.3
Re: [PATCH v2 8/8] iio: dac: ds4424: ratelimit read errors and use device context
Posted by Andy Shevchenko 1 week, 6 days ago
On Tue, Jan 27, 2026 at 07:09:39AM +0100, Oleksij Rempel wrote:
> Replace pr_err() with dev_err_ratelimited() in the RAW read path to avoid
> log spam on repeated I2C failures and to include the device context.
> 
> Use %pe to print errno names for faster debugging.

This should have been done before touching this line in the other patch.

...

>  		if (ret < 0) {
> -			pr_err("%s : regmap_read returned %d\n",
> -						__func__, ret);
> +			dev_err_ratelimited(&indio_dev->dev,

Why not physical device?

> +					    "Failed to read channel %d:  %pe\n",

Too many spaces.

> +					    chan->channel, ERR_PTR(ret));
>  			return ret;
>  		}

-- 
With Best Regards,
Andy Shevchenko