linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] thermal: mtk_thermal: Check return value of devm_thermal_zone_of_sensor_register
@ 2016-09-07  9:24 Axel Lin
  2016-09-13  8:46 ` Matthias Brugger
  0 siblings, 1 reply; 2+ messages in thread
From: Axel Lin @ 2016-09-07  9:24 UTC (permalink / raw)
  To: Zhang Rui
  Cc: Eduardo Valentin, Matthias Brugger, linux-pm, linux-mediatek,
	Axel Lin

devm_thermal_zone_of_sensor_register can fail, so check it's return value.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
 drivers/thermal/mtk_thermal.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/thermal/mtk_thermal.c b/drivers/thermal/mtk_thermal.c
index 7b233c7..34169c3 100644
--- a/drivers/thermal/mtk_thermal.c
+++ b/drivers/thermal/mtk_thermal.c
@@ -584,6 +584,7 @@ static int mtk_thermal_probe(struct platform_device *pdev)
 	struct resource *res;
 	const struct of_device_id *of_id;
 	u64 auxadc_phys_base, apmixed_phys_base;
+	struct thermal_zone_device *tzdev;
 
 	mt = devm_kzalloc(&pdev->dev, sizeof(*mt), GFP_KERNEL);
 	if (!mt)
@@ -666,11 +667,17 @@ static int mtk_thermal_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, mt);
 
-	devm_thermal_zone_of_sensor_register(&pdev->dev, 0, mt,
-					     &mtk_thermal_ops);
+	tzdev = devm_thermal_zone_of_sensor_register(&pdev->dev, 0, mt,
+						     &mtk_thermal_ops);
+	if (IS_ERR(tzdev)) {
+		ret = PTR_ERR(tzdev);
+		goto err_disable_clk_peri_therm;
+	}
 
 	return 0;
 
+err_disable_clk_peri_therm:
+	clk_disable_unprepare(mt->clk_peri_therm);
 err_disable_clk_auxadc:
 	clk_disable_unprepare(mt->clk_auxadc);
 
-- 
2.7.4


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

* Re: [PATCH] thermal: mtk_thermal: Check return value of devm_thermal_zone_of_sensor_register
  2016-09-07  9:24 [PATCH] thermal: mtk_thermal: Check return value of devm_thermal_zone_of_sensor_register Axel Lin
@ 2016-09-13  8:46 ` Matthias Brugger
  0 siblings, 0 replies; 2+ messages in thread
From: Matthias Brugger @ 2016-09-13  8:46 UTC (permalink / raw)
  To: Axel Lin, Zhang Rui; +Cc: Eduardo Valentin, linux-pm, linux-mediatek



On 07/09/16 11:24, Axel Lin wrote:
> devm_thermal_zone_of_sensor_register can fail, so check it's return value.
>
> Signed-off-by: Axel Lin <axel.lin@ingics.com>
> ---
>  drivers/thermal/mtk_thermal.c | 11 +++++++++--
>  1 file changed, 9 insertions(+), 2 deletions(-)
>

Reviewed-by: Matthias Brugger <matthias.bgg@gmail.com>

> diff --git a/drivers/thermal/mtk_thermal.c b/drivers/thermal/mtk_thermal.c
> index 7b233c7..34169c3 100644
> --- a/drivers/thermal/mtk_thermal.c
> +++ b/drivers/thermal/mtk_thermal.c
> @@ -584,6 +584,7 @@ static int mtk_thermal_probe(struct platform_device *pdev)
>  	struct resource *res;
>  	const struct of_device_id *of_id;
>  	u64 auxadc_phys_base, apmixed_phys_base;
> +	struct thermal_zone_device *tzdev;
>
>  	mt = devm_kzalloc(&pdev->dev, sizeof(*mt), GFP_KERNEL);
>  	if (!mt)
> @@ -666,11 +667,17 @@ static int mtk_thermal_probe(struct platform_device *pdev)
>
>  	platform_set_drvdata(pdev, mt);
>
> -	devm_thermal_zone_of_sensor_register(&pdev->dev, 0, mt,
> -					     &mtk_thermal_ops);
> +	tzdev = devm_thermal_zone_of_sensor_register(&pdev->dev, 0, mt,
> +						     &mtk_thermal_ops);
> +	if (IS_ERR(tzdev)) {
> +		ret = PTR_ERR(tzdev);
> +		goto err_disable_clk_peri_therm;
> +	}
>
>  	return 0;
>
> +err_disable_clk_peri_therm:
> +	clk_disable_unprepare(mt->clk_peri_therm);
>  err_disable_clk_auxadc:
>  	clk_disable_unprepare(mt->clk_auxadc);
>
>

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

end of thread, other threads:[~2016-09-13  8:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-07  9:24 [PATCH] thermal: mtk_thermal: Check return value of devm_thermal_zone_of_sensor_register Axel Lin
2016-09-13  8:46 ` Matthias Brugger

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