[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240823-cleanup-h-guard-pm-domain-v1-9-8320722eaf39@linaro.org>
Date: Fri, 23 Aug 2024 14:51:13 +0200
From: Krzysztof Kozlowski <krzysztof.kozlowski@...aro.org>
To: Ulf Hansson <ulf.hansson@...aro.org>, Heiko Stuebner <heiko@...ech.de>,
Shawn Guo <shawnguo@...nel.org>, Sascha Hauer <s.hauer@...gutronix.de>,
Pengutronix Kernel Team <kernel@...gutronix.de>,
Fabio Estevam <festevam@...il.com>, Bjorn Andersson <andersson@...nel.org>,
Konrad Dybcio <konradybcio@...nel.org>,
Geert Uytterhoeven <geert+renesas@...der.be>,
Magnus Damm <magnus.damm@...il.com>
Cc: linux-pm@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
linux-rockchip@...ts.infradead.org, linux-kernel@...r.kernel.org,
imx@...ts.linux.dev, linux-arm-msm@...r.kernel.org,
linux-renesas-soc@...r.kernel.org,
Krzysztof Kozlowski <krzysztof.kozlowski@...aro.org>
Subject: [PATCH 09/10] pmdomain: renesas: rcar-gen4-sysc: 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.
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@...aro.org>
---
drivers/pmdomain/renesas/rcar-gen4-sysc.c | 26 ++++++++++----------------
1 file changed, 10 insertions(+), 16 deletions(-)
diff --git a/drivers/pmdomain/renesas/rcar-gen4-sysc.c b/drivers/pmdomain/renesas/rcar-gen4-sysc.c
index 66409cff2083..4ca85dbdedc2 100644
--- a/drivers/pmdomain/renesas/rcar-gen4-sysc.c
+++ b/drivers/pmdomain/renesas/rcar-gen4-sysc.c
@@ -6,6 +6,7 @@
*/
#include <linux/bits.h>
+#include <linux/cleanup.h>
#include <linux/clk/renesas.h>
#include <linux/delay.h>
#include <linux/err.h>
@@ -303,12 +304,12 @@ static int __init rcar_gen4_sysc_pd_init(void)
const struct rcar_gen4_sysc_info *info;
const struct of_device_id *match;
struct rcar_gen4_pm_domains *domains;
- struct device_node *np;
void __iomem *base;
unsigned int i;
int error;
- np = of_find_matching_node_and_match(NULL, rcar_gen4_sysc_matches, &match);
+ struct device_node *np __free(device_node) =
+ of_find_matching_node_and_match(NULL, rcar_gen4_sysc_matches, &match);
if (!np)
return -ENODEV;
@@ -317,17 +318,14 @@ static int __init rcar_gen4_sysc_pd_init(void)
base = of_iomap(np, 0);
if (!base) {
pr_warn("%pOF: Cannot map regs\n", np);
- error = -ENOMEM;
- goto out_put;
+ return -ENOMEM;
}
rcar_gen4_sysc_base = base;
domains = kzalloc(sizeof(*domains), GFP_KERNEL);
- if (!domains) {
- error = -ENOMEM;
- goto out_put;
- }
+ if (!domains)
+ return -ENOMEM;
domains->onecell_data.domains = domains->domains;
domains->onecell_data.num_domains = ARRAY_SIZE(domains->domains);
@@ -345,10 +343,8 @@ static int __init rcar_gen4_sysc_pd_init(void)
n = strlen(area->name) + 1;
pd = kzalloc(sizeof(*pd) + n, GFP_KERNEL);
- if (!pd) {
- error = -ENOMEM;
- goto out_put;
- }
+ if (!pd)
+ return -ENOMEM;
memcpy(pd->name, area->name, n);
pd->genpd.name = pd->name;
@@ -357,7 +353,7 @@ static int __init rcar_gen4_sysc_pd_init(void)
error = rcar_gen4_sysc_pd_setup(pd);
if (error)
- goto out_put;
+ return error;
domains->domains[area->pdr] = &pd->genpd;
@@ -369,14 +365,12 @@ static int __init rcar_gen4_sysc_pd_init(void)
if (error) {
pr_warn("Failed to add PM subdomain %s to parent %u\n",
area->name, area->parent);
- goto out_put;
+ return error;
}
}
error = of_genpd_add_provider_onecell(np, &domains->onecell_data);
-out_put:
- of_node_put(np);
return error;
}
early_initcall(rcar_gen4_sysc_pd_init);
--
2.43.0
Powered by blists - more mailing lists