Skip to content

Commit

Permalink
thermal: sun8i: Use scoped device node handling to simplify error paths
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Krzysztof Kozlowski authored and Rafael J. Wysocki committed Nov 26, 2024
1 parent 2ff772f commit c79886c
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions drivers/thermal/sun8i_thermal.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*/

#include <linux/bitmap.h>
#include <linux/cleanup.h>
#include <linux/clk.h>
#include <linux/device.h>
#include <linux/interrupt.h>
Expand Down Expand Up @@ -348,19 +349,18 @@ static void sun8i_ths_reset_control_assert(void *data)

static struct regmap *sun8i_ths_get_sram_regmap(struct device_node *node)
{
struct device_node *sram_node;
struct platform_device *sram_pdev;
struct regmap *regmap = NULL;

sram_node = of_parse_phandle(node, "allwinner,sram", 0);
struct device_node *sram_node __free(device_node) =
of_parse_phandle(node, "allwinner,sram", 0);
if (!sram_node)
return ERR_PTR(-ENODEV);

sram_pdev = of_find_device_by_node(sram_node);
if (!sram_pdev) {
/* platform device might not be probed yet */
regmap = ERR_PTR(-EPROBE_DEFER);
goto out_put_node;
return ERR_PTR(-EPROBE_DEFER);
}

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

platform_device_put(sram_pdev);
out_put_node:
of_node_put(sram_node);

return regmap;
}

Expand Down

0 comments on commit c79886c

Please sign in to comment.