Skip to content

Commit

Permalink
clk: renesas: rzg2l: Check return value of pm_genpd_init()
Browse files Browse the repository at this point in the history
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 <prabhakar.mahadev-lad.rj@bp.renesas.com>
Link: https://lore.kernel.org/r/20211117115101.28281-2-prabhakar.mahadev-lad.rj@bp.renesas.com
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
  • Loading branch information
Lad Prabhakar authored and Geert Uytterhoeven committed Nov 19, 2021
1 parent e7d960c commit 27527a3
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion drivers/clk/renesas/rzg2l-cpg.c
Original file line number Diff line number Diff line change
Expand Up @@ -851,10 +851,16 @@ static void rzg2l_cpg_detach_dev(struct generic_pm_domain *unused, struct device
pm_clk_destroy(dev);
}

static void rzg2l_cpg_genpd_remove(void *data)
{
pm_genpd_remove(data);
}

static int __init rzg2l_cpg_add_clk_domain(struct device *dev)
{
struct device_node *np = dev->of_node;
struct generic_pm_domain *genpd;
int ret;

genpd = devm_kzalloc(dev, sizeof(*genpd), GFP_KERNEL);
if (!genpd)
Expand All @@ -865,7 +871,13 @@ static int __init rzg2l_cpg_add_clk_domain(struct device *dev)
GENPD_FLAG_ACTIVE_WAKEUP;
genpd->attach_dev = rzg2l_cpg_attach_dev;
genpd->detach_dev = rzg2l_cpg_detach_dev;
pm_genpd_init(genpd, &pm_domain_always_on_gov, false);
ret = pm_genpd_init(genpd, &pm_domain_always_on_gov, false);
if (ret)
return ret;

ret = devm_add_action_or_reset(dev, rzg2l_cpg_genpd_remove, genpd);
if (ret)
return ret;

of_genpd_add_provider_simple(np, genpd);
return 0;
Expand Down

0 comments on commit 27527a3

Please sign in to comment.