All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] hwmon: (raspberrypi) Exit immediately in case of error in init
@ 2021-12-11 18:44 Armin Wolf
  2021-12-17 15:31 ` Guenter Roeck
  0 siblings, 1 reply; 2+ messages in thread
From: Armin Wolf @ 2021-12-11 18:44 UTC (permalink / raw)
  To: jdelvare, linux; +Cc: linux-hwmon, linux-kernel

Exit immediately if devm_hwmon_device_register_with_info()
fails since registering a delayed work whould be useless
in such a case anyway.

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
---
 drivers/hwmon/raspberrypi-hwmon.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/hwmon/raspberrypi-hwmon.c b/drivers/hwmon/raspberrypi-hwmon.c
index 573f53d52912..1650d3b4c26e 100644
--- a/drivers/hwmon/raspberrypi-hwmon.c
+++ b/drivers/hwmon/raspberrypi-hwmon.c
@@ -120,6 +120,8 @@ static int rpi_hwmon_probe(struct platform_device *pdev)
 							       data,
 							       &rpi_chip_info,
 							       NULL);
+	if (IS_ERR(data->hwmon_dev))
+		return PTR_ERR(data->hwmon_dev);

 	ret = devm_delayed_work_autocancel(dev, &data->get_values_poll_work,
 					   get_values_poll);
@@ -127,10 +129,9 @@ static int rpi_hwmon_probe(struct platform_device *pdev)
 		return ret;
 	platform_set_drvdata(pdev, data);

-	if (!PTR_ERR_OR_ZERO(data->hwmon_dev))
-		schedule_delayed_work(&data->get_values_poll_work, 2 * HZ);
+	schedule_delayed_work(&data->get_values_poll_work, 2 * HZ);

-	return PTR_ERR_OR_ZERO(data->hwmon_dev);
+	return 0;
 }

 static struct platform_driver rpi_hwmon_driver = {
--
2.30.2


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

* Re: [PATCH] hwmon: (raspberrypi) Exit immediately in case of error in init
  2021-12-11 18:44 [PATCH] hwmon: (raspberrypi) Exit immediately in case of error in init Armin Wolf
@ 2021-12-17 15:31 ` Guenter Roeck
  0 siblings, 0 replies; 2+ messages in thread
From: Guenter Roeck @ 2021-12-17 15:31 UTC (permalink / raw)
  To: Armin Wolf; +Cc: jdelvare, linux-hwmon, linux-kernel

On Sat, Dec 11, 2021 at 07:44:49PM +0100, Armin Wolf wrote:
> Exit immediately if devm_hwmon_device_register_with_info()
> fails since registering a delayed work whould be useless
> in such a case anyway.
> 
> Signed-off-by: Armin Wolf <W_Armin@gmx.de>

Applied.

Thanks,
Guenter

> ---
>  drivers/hwmon/raspberrypi-hwmon.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> --
> 2.30.2
> 
> diff --git a/drivers/hwmon/raspberrypi-hwmon.c b/drivers/hwmon/raspberrypi-hwmon.c
> index 573f53d52912..1650d3b4c26e 100644
> --- a/drivers/hwmon/raspberrypi-hwmon.c
> +++ b/drivers/hwmon/raspberrypi-hwmon.c
> @@ -120,6 +120,8 @@ static int rpi_hwmon_probe(struct platform_device *pdev)
>  							       data,
>  							       &rpi_chip_info,
>  							       NULL);
> +	if (IS_ERR(data->hwmon_dev))
> +		return PTR_ERR(data->hwmon_dev);
> 
>  	ret = devm_delayed_work_autocancel(dev, &data->get_values_poll_work,
>  					   get_values_poll);
> @@ -127,10 +129,9 @@ static int rpi_hwmon_probe(struct platform_device *pdev)
>  		return ret;
>  	platform_set_drvdata(pdev, data);
> 
> -	if (!PTR_ERR_OR_ZERO(data->hwmon_dev))
> -		schedule_delayed_work(&data->get_values_poll_work, 2 * HZ);
> +	schedule_delayed_work(&data->get_values_poll_work, 2 * HZ);
> 
> -	return PTR_ERR_OR_ZERO(data->hwmon_dev);
> +	return 0;
>  }
> 
>  static struct platform_driver rpi_hwmon_driver = {

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

end of thread, other threads:[~2021-12-17 15:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-11 18:44 [PATCH] hwmon: (raspberrypi) Exit immediately in case of error in init Armin Wolf
2021-12-17 15:31 ` Guenter Roeck

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.