Skip to content

Commit c79886c

Browse files
krzkrafaeljw
authored andcommitted
thermal: sun8i: Use scoped device node handling to simplify error paths
Obtain the device node reference with scoped/cleanup.h to reduce error handling and make the code a bit simpler. Reviewed-by: Chen-Yu Tsai <wenst@chromium.org> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> Link: https://patch.msgid.link/20241010-b4-cleanup-h-of-node-put-thermal-v4-6-bfbe29ad81f4@linaro.org Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 2ff772f commit c79886c

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

drivers/thermal/sun8i_thermal.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
*/
1010

1111
#include <linux/bitmap.h>
12+
#include <linux/cleanup.h>
1213
#include <linux/clk.h>
1314
#include <linux/device.h>
1415
#include <linux/interrupt.h>
@@ -348,19 +349,18 @@ static void sun8i_ths_reset_control_assert(void *data)
348349

349350
static struct regmap *sun8i_ths_get_sram_regmap(struct device_node *node)
350351
{
351-
struct device_node *sram_node;
352352
struct platform_device *sram_pdev;
353353
struct regmap *regmap = NULL;
354354

355-
sram_node = of_parse_phandle(node, "allwinner,sram", 0);
355+
struct device_node *sram_node __free(device_node) =
356+
of_parse_phandle(node, "allwinner,sram", 0);
356357
if (!sram_node)
357358
return ERR_PTR(-ENODEV);
358359

359360
sram_pdev = of_find_device_by_node(sram_node);
360361
if (!sram_pdev) {
361362
/* platform device might not be probed yet */
362-
regmap = ERR_PTR(-EPROBE_DEFER);
363-
goto out_put_node;
363+
return ERR_PTR(-EPROBE_DEFER);
364364
}
365365

366366
/* If no regmap is found then the other device driver is at fault */
@@ -369,8 +369,7 @@ static struct regmap *sun8i_ths_get_sram_regmap(struct device_node *node)
369369
regmap = ERR_PTR(-EINVAL);
370370

371371
platform_device_put(sram_pdev);
372-
out_put_node:
373-
of_node_put(sram_node);
372+
374373
return regmap;
375374
}
376375

0 commit comments

Comments
 (0)