Skip to contentSkip to conversation

thermal: imx: Use dev_err_probe() to simplify error handling

PATCH Superseded Anson Huang 1 participant 2 messages Aug 11, 2020

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

PATCH v2 1/2 thermal: imx: Use dev_err_probe() to simplify error handling

dev_err_probe() can reduce code size, uniform error handling and record the defer probe reason etc., use it to simplify the code.

---
changes since V1:
- remove redundant return value print.

---
 drivers/thermal/imx_thermal.c | 22 ++++++----------------
 1 file changed, 6 insertions(+), 16 deletions(-)
drivers/thermal/imx_thermal.c +6 -16
index 3f74ab4..2c7473d 100644
@@ -716,14 +716,9 @@ static int imx_thermal_probe(struct platform_device *pdev)
 
 	if (of_find_property(pdev->dev.of_node, "nvmem-cells", NULL)) {
 		ret = imx_init_from_nvmem_cells(pdev);
-		if (ret) {
-			if (ret == -EPROBE_DEFER)
-				return ret;
-
-			dev_err(&pdev->dev, "failed to init from nvmem: %d\n",
-				ret);
-			return ret;
-		}
+		if (ret)
+			return dev_err_probe(&pdev->dev, ret,
+					     "failed to init from nvmem\n");
 	} else {
 		ret = imx_init_from_tempmon_data(pdev);
 		if (ret) {
@@ -746,14 +741,9 @@ static int imx_thermal_probe(struct platform_device *pdev)
 		     data->socdata->power_down_mask);
 
 	ret = imx_thermal_register_legacy_cooling(data);
-	if (ret) {
-		if (ret == -EPROBE_DEFER)
-			return ret;
-
-		dev_err(&pdev->dev,
-			"failed to register cpufreq cooling device: %d\n", ret);
-		return ret;
-	}
+	if (ret)
+		return dev_err_probe(&pdev->dev, ret,
+				     "failed to register cpufreq cooling device\n");
 
 	data->thermal_clk = devm_clk_get(&pdev->dev, NULL);
 	if (IS_ERR(data->thermal_clk)) {
Signature · 1 line
2.7.4
#1 lore raw

PATCH v2 2/2 thermal: imx8mm: Use dev_err_probe() to simplify error handling

dev_err_probe() can reduce code size, uniform error handling and record the defer probe reason etc., use it to simplify the code.

---
changes since V1:
- remove redundant return value print.

---
 drivers/thermal/imx8mm_thermal.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
drivers/thermal/imx8mm_thermal.c +3 -7
index f5124f1..a1e4f9b 100644
@@ -146,13 +146,9 @@ static int imx8mm_tmu_probe(struct platform_device *pdev)
 		return PTR_ERR(tmu->base);
 
 	tmu->clk = devm_clk_get(&pdev->dev, NULL);
-	if (IS_ERR(tmu->clk)) {
-		ret = PTR_ERR(tmu->clk);
-		if (ret != -EPROBE_DEFER)
-			dev_err(&pdev->dev,
-				"failed to get tmu clock: %d\n", ret);
-		return ret;
-	}
+	if (IS_ERR(tmu->clk))
+		return dev_err_probe(&pdev->dev, PTR_ERR(tmu->clk),
+				     "failed to get tmu clock\n");
 
 	ret = clk_prepare_enable(tmu->clk);
 	if (ret) {
Signature · 1 line
2.7.4