Skip to content

Commit 27527a3

Browse files
prabhakarladgeertu
authored andcommitted
clk: renesas: rzg2l: Check return value of pm_genpd_init()
Make sure we check the return value of pm_genpd_init() which might fail. Also add a devres action to remove the power-domain in-case the probe callback fails further down in the code flow. Fixes: ef3c613 ("clk: renesas: Add CPG core wrapper for RZ/G2L SoC") Signed-off-by: Lad Prabhakar <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Geert Uytterhoeven <[email protected]>
1 parent e7d960c commit 27527a3

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

drivers/clk/renesas/rzg2l-cpg.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -851,10 +851,16 @@ static void rzg2l_cpg_detach_dev(struct generic_pm_domain *unused, struct device
851851
pm_clk_destroy(dev);
852852
}
853853

854+
static void rzg2l_cpg_genpd_remove(void *data)
855+
{
856+
pm_genpd_remove(data);
857+
}
858+
854859
static int __init rzg2l_cpg_add_clk_domain(struct device *dev)
855860
{
856861
struct device_node *np = dev->of_node;
857862
struct generic_pm_domain *genpd;
863+
int ret;
858864

859865
genpd = devm_kzalloc(dev, sizeof(*genpd), GFP_KERNEL);
860866
if (!genpd)
@@ -865,7 +871,13 @@ static int __init rzg2l_cpg_add_clk_domain(struct device *dev)
865871
GENPD_FLAG_ACTIVE_WAKEUP;
866872
genpd->attach_dev = rzg2l_cpg_attach_dev;
867873
genpd->detach_dev = rzg2l_cpg_detach_dev;
868-
pm_genpd_init(genpd, &pm_domain_always_on_gov, false);
874+
ret = pm_genpd_init(genpd, &pm_domain_always_on_gov, false);
875+
if (ret)
876+
return ret;
877+
878+
ret = devm_add_action_or_reset(dev, rzg2l_cpg_genpd_remove, genpd);
879+
if (ret)
880+
return ret;
869881

870882
of_genpd_add_provider_simple(np, genpd);
871883
return 0;

0 commit comments

Comments
 (0)