Skip to content

Commit

Permalink
pwm: sifive: Simplify using devm_clk_get_prepared()
Browse files Browse the repository at this point in the history
Instead of preparing the clk after it was requested and unpreparing in
.probe()'s error path and .remove(), use devm_clk_get_prepared() which
copes for unpreparing automatically.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Reviewed-by: Emil Renner Berthing <emil.renner.berthing@canonical.com>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
  • Loading branch information
Uwe Kleine-König authored and Thierry Reding committed Jun 23, 2023
1 parent 2b8e30b commit 55e644b
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions drivers/pwm/pwm-sifive.c
Original file line number Diff line number Diff line change
Expand Up @@ -244,12 +244,12 @@ static int pwm_sifive_probe(struct platform_device *pdev)
if (IS_ERR(ddata->regs))
return PTR_ERR(ddata->regs);

ddata->clk = devm_clk_get(dev, NULL);
ddata->clk = devm_clk_get_prepared(dev, NULL);
if (IS_ERR(ddata->clk))
return dev_err_probe(dev, PTR_ERR(ddata->clk),
"Unable to find controller clock\n");

ret = clk_prepare_enable(ddata->clk);
ret = clk_enable(ddata->clk);
if (ret) {
dev_err(dev, "failed to enable clock for pwm: %d\n", ret);
return ret;
Expand Down Expand Up @@ -308,7 +308,6 @@ static int pwm_sifive_probe(struct platform_device *pdev)
clk_disable(ddata->clk);
--enabled_clks;
}
clk_unprepare(ddata->clk);

return ret;
}
Expand All @@ -327,8 +326,6 @@ static void pwm_sifive_remove(struct platform_device *dev)
if (pwm->state.enabled)
clk_disable(ddata->clk);
}

clk_unprepare(ddata->clk);
}

static const struct of_device_id pwm_sifive_of_match[] = {
Expand Down

0 comments on commit 55e644b

Please sign in to comment.