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

Oleksij Rempel posted 8 patches 3 weeks ago
There is a newer version of this series
[PATCH v1 7/8] iio: dac: ds4424: ratelimit read errors and use device context
Posted by Oleksij Rempel 3 weeks 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>
---
 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 2d299a52cede..13acb427d43b 100644
--- a/drivers/iio/dac/ds4424.c
+++ b/drivers/iio/dac/ds4424.c
@@ -148,8 +148,9 @@ static int ds4424_read_raw(struct iio_dev *indio_dev,
 	case IIO_CHAN_INFO_RAW:
 		ret = ds4424_get_value(indio_dev, val, chan->channel);
 		if (ret < 0) {
-			pr_err("%s : ds4424_get_value returned %d\n",
-							__func__, ret);
+			dev_err_ratelimited(&indio_dev->dev,
+					    "%s: ds4424_get_value failed %pe\n",
+					    __func__, ERR_PTR(ret));
 			return ret;
 		}
 		raw.bits = *val;
-- 
2.47.3
Re: [PATCH v1 7/8] iio: dac: ds4424: ratelimit read errors and use device context
Posted by Andy Shevchenko 3 weeks ago
On Mon, Jan 19, 2026 at 07:24:23PM +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.

...

> -			pr_err("%s : ds4424_get_value returned %d\n",
> -							__func__, ret);
> +			dev_err_ratelimited(&indio_dev->dev,
> +					    "%s: ds4424_get_value failed %pe\n",
> +					    __func__, ERR_PTR(ret));

Too many information in the output now. __func__ obviously is redundant from
pr_*() limits, since you have now device, no need to have that, I believe. In
general, if you want to use __func__ it's most likely that the message itself
is badly written (not so unique). Rephrasing helps. Also "ds4424_get_value()"
will hint the user that this is about returned value from the call to the
function.

>  			return ret;

-- 
With Best Regards,
Andy Shevchenko