linux-hwmon.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] hwmon: (iio_hwmon) use dev_err_probe
@ 2023-01-31 10:33 Alexander Stein
  2023-01-31 15:05 ` Guenter Roeck
  0 siblings, 1 reply; 2+ messages in thread
From: Alexander Stein @ 2023-01-31 10:33 UTC (permalink / raw)
  To: Jean Delvare, Guenter Roeck; +Cc: Alexander Stein, linux-hwmon, linux-kernel

Instead of just returning an error code, add an error message as well.
While at it, simplify the code and use a common return path.
Upon deferral this also nicely lists the following message in
/sys/kernel/debug/devices_deferred:
adc     iio_hwmon: Failed to get channels

Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
---
 drivers/hwmon/iio_hwmon.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/hwmon/iio_hwmon.c b/drivers/hwmon/iio_hwmon.c
index 3aa40893fc09..4c8a80847891 100644
--- a/drivers/hwmon/iio_hwmon.c
+++ b/drivers/hwmon/iio_hwmon.c
@@ -77,9 +77,11 @@ static int iio_hwmon_probe(struct platform_device *pdev)
 
 	channels = devm_iio_channel_get_all(dev);
 	if (IS_ERR(channels)) {
-		if (PTR_ERR(channels) == -ENODEV)
-			return -EPROBE_DEFER;
-		return PTR_ERR(channels);
+		ret = PTR_ERR(channels);
+		if (ret == -ENODEV)
+			ret = -EPROBE_DEFER;
+		return dev_err_probe(dev, ret,
+				     "Failed to get channels\n");
 	}
 
 	st = devm_kzalloc(dev, sizeof(*st), GFP_KERNEL);
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH 1/1] hwmon: (iio_hwmon) use dev_err_probe
  2023-01-31 10:33 [PATCH 1/1] hwmon: (iio_hwmon) use dev_err_probe Alexander Stein
@ 2023-01-31 15:05 ` Guenter Roeck
  0 siblings, 0 replies; 2+ messages in thread
From: Guenter Roeck @ 2023-01-31 15:05 UTC (permalink / raw)
  To: Alexander Stein; +Cc: Jean Delvare, linux-hwmon, linux-kernel

On Tue, Jan 31, 2023 at 11:33:59AM +0100, Alexander Stein wrote:
> Instead of just returning an error code, add an error message as well.
> While at it, simplify the code and use a common return path.
> Upon deferral this also nicely lists the following message in
> /sys/kernel/debug/devices_deferred:
> adc     iio_hwmon: Failed to get channels
> 
> Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>

Applied to hwmon-next.

Thanks,
Guenter

> ---
>  drivers/hwmon/iio_hwmon.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/hwmon/iio_hwmon.c b/drivers/hwmon/iio_hwmon.c
> index 3aa40893fc09..4c8a80847891 100644
> --- a/drivers/hwmon/iio_hwmon.c
> +++ b/drivers/hwmon/iio_hwmon.c
> @@ -77,9 +77,11 @@ static int iio_hwmon_probe(struct platform_device *pdev)
>  
>  	channels = devm_iio_channel_get_all(dev);
>  	if (IS_ERR(channels)) {
> -		if (PTR_ERR(channels) == -ENODEV)
> -			return -EPROBE_DEFER;
> -		return PTR_ERR(channels);
> +		ret = PTR_ERR(channels);
> +		if (ret == -ENODEV)
> +			ret = -EPROBE_DEFER;
> +		return dev_err_probe(dev, ret,
> +				     "Failed to get channels\n");
>  	}
>  
>  	st = devm_kzalloc(dev, sizeof(*st), GFP_KERNEL);

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-01-31 15:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-31 10:33 [PATCH 1/1] hwmon: (iio_hwmon) use dev_err_probe Alexander Stein
2023-01-31 15:05 ` Guenter Roeck

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).