[PATCH 10/12] thermal: qoriq: Simplify error handling in qoriq_tmu_get_sensor_id()

From: Andrey Smirnov
Date: Mon Feb 18 2019 - 14:12:32 EST


Use goto to avoid repeating resource deallocation code.

Signed-off-by: Andrey Smirnov <andrew.smirnov@xxxxxxxxx>
Cc: Chris Healy <cphealy@xxxxxxxxx>
Cc: Lucas Stach <l.stach@xxxxxxxxxxxxxx>
Cc: Zhang Rui <rui.zhang@xxxxxxxxx>
Cc: Eduardo Valentin <edubezval@xxxxxxxxx>
Cc: Daniel Lezcano <daniel.lezcano@xxxxxxxxxx>
Cc: linux-imx@xxxxxxx
Cc: linux-pm@xxxxxxxxxxxxxxx
Cc: linux-kernel@xxxxxxxxxxxxxxx
---
drivers/thermal/qoriq_thermal.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/thermal/qoriq_thermal.c b/drivers/thermal/qoriq_thermal.c
index 3d520d3b2da4..d4f5e180e1ee 100644
--- a/drivers/thermal/qoriq_thermal.c
+++ b/drivers/thermal/qoriq_thermal.c
@@ -78,9 +78,8 @@ static int qoriq_tmu_get_sensor_id(void)
"#thermal-sensor-cells",
0, &sensor_specs);
if (ret) {
- of_node_put(np);
- of_node_put(sensor_np);
- return ret;
+ id = ret;
+ goto out;
}

if (sensor_specs.args_count >= 1) {
@@ -91,7 +90,7 @@ static int qoriq_tmu_get_sensor_id(void)
} else {
id = 0;
}
-
+out:
of_node_put(np);
of_node_put(sensor_np);

--
2.20.1