Message ID | 20230418202102.117658-1-u.kleine-koenig@pengutronix.de (mailing list archive) |
---|---|
State | Handled Elsewhere |
Headers | show |
Series | pwm: sifive: Simplify using devm_clk_get_prepared() | expand |
Context | Check | Description |
---|---|---|
conchuod/tree_selection | fail | Failed to apply to next/pending-fixes or riscv/for-next |
On Tue, 18 Apr 2023 at 22:23, Uwe Kleine-König <u.kleine-koenig@pengutronix.de> wrote: > > 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> Looks good to me, thanks. Reviewed-by: Emil Renner Berthing <emil.renner.berthing@canonical.com> > --- > drivers/pwm/pwm-sifive.c | 7 ++----- > 1 file changed, 2 insertions(+), 5 deletions(-) > > diff --git a/drivers/pwm/pwm-sifive.c b/drivers/pwm/pwm-sifive.c > index 5b0574f635f6..ae49d67ab2b1 100644 > --- a/drivers/pwm/pwm-sifive.c > +++ b/drivers/pwm/pwm-sifive.c > @@ -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; > @@ -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; > } > @@ -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[] = { > > base-commit: 247ee6c780406513c6031a7f4ea41f1648b03295 > -- > 2.39.2 > > > _______________________________________________ > linux-riscv mailing list > linux-riscv@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-riscv
On Tue, 18 Apr 2023 22:21:02 +0200, Uwe Kleine-König wrote: > 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. > > Applied, thanks! [1/1] pwm: sifive: Simplify using devm_clk_get_prepared() commit: 55e644b840baf7a884a27be81b7582794f54a808 Best regards,
diff --git a/drivers/pwm/pwm-sifive.c b/drivers/pwm/pwm-sifive.c index 5b0574f635f6..ae49d67ab2b1 100644 --- a/drivers/pwm/pwm-sifive.c +++ b/drivers/pwm/pwm-sifive.c @@ -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; @@ -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; } @@ -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[] = {
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> --- drivers/pwm/pwm-sifive.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) base-commit: 247ee6c780406513c6031a7f4ea41f1648b03295