Skip to contentSkip to conversation

thermal/drivers/mediatek: remove redundant dev_warn in probe

PATCH In review Alexandru Ardelean 2 participants 3 messages Aug 13, 2023 – Aug 14, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 thermal/drivers/mediatek: remove redundant dev_warn in probe

There's no need to print any extra messages in the driver if devm_thermal_add_hwmon_sysfs() fails.
If this function has any failures, they will already be printed.

While looking inside 'drivers/thermal/mediatek/auxadc_thermal.c', the failure will be either be one of:
'Failed to allocate device resource data'
or
'Failed to add hwmon sysfs attributes'

Also, the failure will be reported on the 'dev' object passed to 'devm_thermal_add_hwmon_sysfs()', so it should be clear which device this error belongs to.

---
 drivers/thermal/mediatek/auxadc_thermal.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/thermal/mediatek/auxadc_thermal.c +1 -5
index f59d36de20a0..55f7fde470e5 100644
@@ -1290,11 +1290,7 @@ static int mtk_thermal_probe(struct platform_device *pdev)
 	if (IS_ERR(tzdev))
 		return PTR_ERR(tzdev);
 
-	ret = devm_thermal_add_hwmon_sysfs(&pdev->dev, tzdev);
-	if (ret)
-		dev_warn(&pdev->dev, "error in thermal_add_hwmon_sysfs");
-
-	return 0;
+	return devm_thermal_add_hwmon_sysfs(&pdev->dev, tzdev);
 }
 
 static struct platform_driver mtk_thermal_driver = {
Signature · 1 line
2.41.0
#1 lore raw
Quoted 25 lines · Alexandru Ardelean

There's no need to print any extra messages in the driver if devm_thermal_add_hwmon_sysfs() fails.
If this function has any failures, they will already be printed.

While looking inside 'drivers/thermal/mediatek/auxadc_thermal.c', the failure will be either be one of:
'Failed to allocate device resource data'
or
'Failed to add hwmon sysfs attributes'

Also, the failure will be reported on the 'dev' object passed to 'devm_thermal_add_hwmon_sysfs()', so it should be clear which device this error belongs to.

---
 drivers/thermal/mediatek/auxadc_thermal.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/thermal/mediatek/auxadc_thermal.c +0 -0
index f59d36de20a0..55f7fde470e5 100644

drivers/thermal/mediatek/auxadc_thermal.c static int mtk_thermal_probe(struct platform_device *pdev) · line 1293

Quoted 9 lines
drivers/thermal/mediatek/auxadc_thermal.c +1 -5
@@ -1290,11 +1290,7 @@ static int mtk_thermal_probe(struct platform_device *pdev)
        if (IS_ERR(tzdev))
                return PTR_ERR(tzdev);
 
-       ret = devm_thermal_add_hwmon_sysfs(&pdev->dev, tzdev);
-       if (ret)
-               dev_warn(&pdev->dev, "error in thermal_add_hwmon_sysfs");
-
-       return 0;
+       return devm_thermal_add_hwmon_sysfs(&pdev->dev, tzdev);

You changed the logic here. The original logic is to print a warning if the hwmon sysfs stuff failed, but continue to probe the driver. In other words, hwmon sysfs failing is a non-fatal error.

Your changes make it fatal.

ChenYu

Quoted 7 lines
drivers/thermal/mediatek/auxadc_thermal.c +0 -1
 }
 
 static struct platform_driver mtk_thermal_driver = {
--

2.41.0

#2 lore raw
Quoted 41 lines · Chen-Yu Tsai
Quoted 25 lines · Alexandru Ardelean

There's no need to print any extra messages in the driver if devm_thermal_add_hwmon_sysfs() fails.
If this function has any failures, they will already be printed.

While looking inside 'drivers/thermal/mediatek/auxadc_thermal.c', the failure will be either be one of:
'Failed to allocate device resource data'
or
'Failed to add hwmon sysfs attributes'

Also, the failure will be reported on the 'dev' object passed to 'devm_thermal_add_hwmon_sysfs()', so it should be clear which device this error belongs to.

---
 drivers/thermal/mediatek/auxadc_thermal.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/thermal/mediatek/auxadc_thermal.c +0 -0
index f59d36de20a0..55f7fde470e5 100644

drivers/thermal/mediatek/auxadc_thermal.c static int mtk_thermal_probe(struct platform_device *pdev) · line 1293

Quoted 9 lines
drivers/thermal/mediatek/auxadc_thermal.c +1 -5
@@ -1290,11 +1290,7 @@ static int mtk_thermal_probe(struct platform_device *pdev)
        if (IS_ERR(tzdev))
                return PTR_ERR(tzdev);
 
-       ret = devm_thermal_add_hwmon_sysfs(&pdev->dev, tzdev);
-       if (ret)
-               dev_warn(&pdev->dev, "error in thermal_add_hwmon_sysfs");
-
-       return 0;
+       return devm_thermal_add_hwmon_sysfs(&pdev->dev, tzdev);

You changed the logic here. The original logic is to print a warning if the hwmon sysfs stuff failed, but continue to probe the driver. In other words, hwmon sysfs failing is a non-fatal error.

Quoted 1 line

Your changes make it fatal.

Ah, right.
My bad

Quoted 10 lines

ChenYu

Quoted 7 lines
drivers/thermal/mediatek/auxadc_thermal.c +0 -1
 }
 
 static struct platform_driver mtk_thermal_driver = {
--

2.41.0