Skip to content

Commit

Permalink
clk: renesas: cpg-mssr: 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.

Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Link: https://lore.kernel.org/r/20211117115101.28281-4-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 3374874 commit fa58e46
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion drivers/clk/renesas/renesas-cpg-mssr.c
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,11 @@ void cpg_mssr_detach_dev(struct generic_pm_domain *unused, struct device *dev)
pm_clk_destroy(dev);
}

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

static int __init cpg_mssr_add_clk_domain(struct device *dev,
const unsigned int *core_pm_clks,
unsigned int num_core_pm_clks)
Expand All @@ -560,6 +565,7 @@ static int __init cpg_mssr_add_clk_domain(struct device *dev,
struct generic_pm_domain *genpd;
struct cpg_mssr_clk_domain *pd;
size_t pm_size = num_core_pm_clks * sizeof(core_pm_clks[0]);
int ret;

pd = devm_kzalloc(dev, sizeof(*pd) + pm_size, GFP_KERNEL);
if (!pd)
Expand All @@ -574,7 +580,14 @@ static int __init cpg_mssr_add_clk_domain(struct device *dev,
GENPD_FLAG_ACTIVE_WAKEUP;
genpd->attach_dev = cpg_mssr_attach_dev;
genpd->detach_dev = cpg_mssr_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, cpg_mssr_genpd_remove, genpd);
if (ret)
return ret;

cpg_mssr_clk_domain = pd;

of_genpd_add_provider_simple(np, genpd);
Expand Down

0 comments on commit fa58e46

Please sign in to comment.