linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] thermal/of: Add error information printing for devm_thermal_of_zone_register()
@ 2023-07-11 12:45 Yangtao Li
  2023-07-11 12:45 ` [PATCH 2/2] thermal/drivers/amlogic: Remove redundant msg in amlogic_thermal_probe() Yangtao Li
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Yangtao Li @ 2023-07-11 12:45 UTC (permalink / raw)
  To: Rafael J. Wysocki, Daniel Lezcano, Amit Kucheria, Zhang Rui
  Cc: Yangtao Li, linux-pm, linux-kernel

Ensure that all error handling branches print error information. In this
way, when this function fails, the upper-layer functions can directly
return an error code without missing debugging information. Otherwise,
the error message will be printed redundantly or missing.

Signed-off-by: Yangtao Li <frank.li@vivo.com>
---
 drivers/thermal/thermal_of.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c
index 6fb14e521197..8ce231f7639a 100644
--- a/drivers/thermal/thermal_of.c
+++ b/drivers/thermal/thermal_of.c
@@ -583,11 +583,14 @@ struct thermal_zone_device *devm_thermal_of_zone_register(struct device *dev, in
 
 	ptr = devres_alloc(devm_thermal_of_zone_release, sizeof(*ptr),
 			   GFP_KERNEL);
-	if (!ptr)
+	if (!ptr) {
+		dev_err(dev, "Failed to allocate device resource data\n");
 		return ERR_PTR(-ENOMEM);
+	}
 
 	tzd = thermal_of_zone_register(dev->of_node, sensor_id, data, ops);
 	if (IS_ERR(tzd)) {
+		dev_err(dev, "Failed to register thermal zone: %d\n", PTR_ERR(tzd));
 		devres_free(ptr);
 		return tzd;
 	}
-- 
2.39.0


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

* [PATCH 2/2] thermal/drivers/amlogic: Remove redundant msg in amlogic_thermal_probe()
  2023-07-11 12:45 [PATCH 1/2] thermal/of: Add error information printing for devm_thermal_of_zone_register() Yangtao Li
@ 2023-07-11 12:45 ` Yangtao Li
  2023-07-12  2:51 ` [PATCH 1/2] thermal/of: Add error information printing for devm_thermal_of_zone_register() Yangtao Li
  2023-07-13 13:00 ` Daniel Lezcano
  2 siblings, 0 replies; 4+ messages in thread
From: Yangtao Li @ 2023-07-11 12:45 UTC (permalink / raw)
  To: Guillaume La Roque, Rafael J. Wysocki, Daniel Lezcano,
	Amit Kucheria, Zhang Rui
  Cc: Yangtao Li, linux-pm, linux-amlogic, linux-kernel

The upper-layer devm_thermal_of_zone_register() function can directly
print error information.

Signed-off-by: Yangtao Li <frank.li@vivo.com>
---
 drivers/thermal/amlogic_thermal.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/thermal/amlogic_thermal.c b/drivers/thermal/amlogic_thermal.c
index 756b218880a7..134f5a8d1019 100644
--- a/drivers/thermal/amlogic_thermal.c
+++ b/drivers/thermal/amlogic_thermal.c
@@ -276,11 +276,8 @@ static int amlogic_thermal_probe(struct platform_device *pdev)
 						   0,
 						   pdata,
 						   &amlogic_thermal_ops);
-	if (IS_ERR(pdata->tzd)) {
-		ret = PTR_ERR(pdata->tzd);
-		dev_err(dev, "Failed to register tsensor: %d\n", ret);
-		return ret;
-	}
+	if (IS_ERR(pdata->tzd))
+		return PTR_ERR(pdata->tzd);
 
 	devm_thermal_add_hwmon_sysfs(&pdev->dev, pdata->tzd);
 
-- 
2.39.0


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

* Re: [PATCH 1/2] thermal/of: Add error information printing for devm_thermal_of_zone_register()
  2023-07-11 12:45 [PATCH 1/2] thermal/of: Add error information printing for devm_thermal_of_zone_register() Yangtao Li
  2023-07-11 12:45 ` [PATCH 2/2] thermal/drivers/amlogic: Remove redundant msg in amlogic_thermal_probe() Yangtao Li
@ 2023-07-12  2:51 ` Yangtao Li
  2023-07-13 13:00 ` Daniel Lezcano
  2 siblings, 0 replies; 4+ messages in thread
From: Yangtao Li @ 2023-07-12  2:51 UTC (permalink / raw)
  To: Rafael J. Wysocki, Daniel Lezcano, Amit Kucheria, Zhang Rui
  Cc: linux-pm, linux-kernel

Hi Daniel,

On 2023/7/11 20:45, Yangtao Li wrote:
> Ensure that all error handling branches print error information. In this
> way, when this function fails, the upper-layer functions can directly
> return an error code without missing debugging information. Otherwise,
> the error message will be printed redundantly or missing.
>
> Signed-off-by: Yangtao Li <frank.li@vivo.com>
> ---
>   drivers/thermal/thermal_of.c | 5 ++++-
>   1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c
> index 6fb14e521197..8ce231f7639a 100644
> --- a/drivers/thermal/thermal_of.c
> +++ b/drivers/thermal/thermal_of.c
> @@ -583,11 +583,14 @@ struct thermal_zone_device *devm_thermal_of_zone_register(struct device *dev, in
>   
>   	ptr = devres_alloc(devm_thermal_of_zone_release, sizeof(*ptr),
>   			   GFP_KERNEL);
> -	if (!ptr)
> +	if (!ptr) {
> +		dev_err(dev, "Failed to allocate device resource data\n");
>   		return ERR_PTR(-ENOMEM);
> +	}
>   
>   	tzd = thermal_of_zone_register(dev->of_node, sensor_id, data, ops);
>   	if (IS_ERR(tzd)) {
> +		dev_err(dev, "Failed to register thermal zone: %d\n", PTR_ERR(tzd));
>   		devres_free(ptr);
>   		return tzd;
>   	}


Do you agree with the current modification?

Or if you have other opinions, please let me know.

I want to do a cleanup of the code below drivers/thermal this time.


Thx,

Yangtao


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

* Re: [PATCH 1/2] thermal/of: Add error information printing for devm_thermal_of_zone_register()
  2023-07-11 12:45 [PATCH 1/2] thermal/of: Add error information printing for devm_thermal_of_zone_register() Yangtao Li
  2023-07-11 12:45 ` [PATCH 2/2] thermal/drivers/amlogic: Remove redundant msg in amlogic_thermal_probe() Yangtao Li
  2023-07-12  2:51 ` [PATCH 1/2] thermal/of: Add error information printing for devm_thermal_of_zone_register() Yangtao Li
@ 2023-07-13 13:00 ` Daniel Lezcano
  2 siblings, 0 replies; 4+ messages in thread
From: Daniel Lezcano @ 2023-07-13 13:00 UTC (permalink / raw)
  To: Yangtao Li, Rafael J. Wysocki, Amit Kucheria, Zhang Rui
  Cc: linux-pm, linux-kernel

On 11/07/2023 14:45, Yangtao Li wrote:
> Ensure that all error handling branches print error information. In this
> way, when this function fails, the upper-layer functions can directly
> return an error code without missing debugging information. Otherwise,
> the error message will be printed redundantly or missing.
> 
> Signed-off-by: Yangtao Li <frank.li@vivo.com>
> ---
>   drivers/thermal/thermal_of.c | 5 ++++-
>   1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c
> index 6fb14e521197..8ce231f7639a 100644
> --- a/drivers/thermal/thermal_of.c
> +++ b/drivers/thermal/thermal_of.c
> @@ -583,11 +583,14 @@ struct thermal_zone_device *devm_thermal_of_zone_register(struct device *dev, in
>   
>   	ptr = devres_alloc(devm_thermal_of_zone_release, sizeof(*ptr),
>   			   GFP_KERNEL);
> -	if (!ptr)
> +	if (!ptr) {
> +		dev_err(dev, "Failed to allocate device resource data\n");
>   		return ERR_PTR(-ENOMEM);
> +	}
>   
>   	tzd = thermal_of_zone_register(dev->of_node, sensor_id, data, ops);
>   	if (IS_ERR(tzd)) {
> +		dev_err(dev, "Failed to register thermal zone: %d\n", PTR_ERR(tzd));

Not sure if having this error is useful as we already have an error 
showing up with the thermal_of_zone_register() function

>   		devres_free(ptr);
>   		return tzd;
>   	}

-- 
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog


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

end of thread, other threads:[~2023-07-13 13:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-11 12:45 [PATCH 1/2] thermal/of: Add error information printing for devm_thermal_of_zone_register() Yangtao Li
2023-07-11 12:45 ` [PATCH 2/2] thermal/drivers/amlogic: Remove redundant msg in amlogic_thermal_probe() Yangtao Li
2023-07-12  2:51 ` [PATCH 1/2] thermal/of: Add error information printing for devm_thermal_of_zone_register() Yangtao Li
2023-07-13 13:00 ` Daniel Lezcano

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).