Skip to content

Commit 92fcd5b

Browse files
Uwe Kleine-Königthierryreding
authored andcommitted
pwm: imx-tpm: Simplify using devm functions
With devm_clk_get_enabled() the call to clk_disable_unprepare() can be dropped from the error path and the remove callback. With devm_pwmchip_add() pwmchip_remove() can be dropped. Then the remove callback is empty and can go away, too. Also use dev_err_probe() for simplified (and improved) error reporting. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Uwe Kleine-König <[email protected]> Signed-off-by: Thierry Reding <[email protected]>
1 parent 5af615f commit 92fcd5b

File tree

1 file changed

+5
-24
lines changed

1 file changed

+5
-24
lines changed

drivers/pwm/pwm-imx-tpm.c

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -350,18 +350,11 @@ static int pwm_imx_tpm_probe(struct platform_device *pdev)
350350
if (IS_ERR(tpm->base))
351351
return PTR_ERR(tpm->base);
352352

353-
tpm->clk = devm_clk_get(&pdev->dev, NULL);
353+
tpm->clk = devm_clk_get_enabled(&pdev->dev, NULL);
354354
if (IS_ERR(tpm->clk))
355355
return dev_err_probe(&pdev->dev, PTR_ERR(tpm->clk),
356356
"failed to get PWM clock\n");
357357

358-
ret = clk_prepare_enable(tpm->clk);
359-
if (ret) {
360-
dev_err(&pdev->dev,
361-
"failed to prepare or enable clock: %d\n", ret);
362-
return ret;
363-
}
364-
365358
tpm->chip.dev = &pdev->dev;
366359
tpm->chip.ops = &imx_tpm_pwm_ops;
367360

@@ -371,22 +364,11 @@ static int pwm_imx_tpm_probe(struct platform_device *pdev)
371364

372365
mutex_init(&tpm->lock);
373366

374-
ret = pwmchip_add(&tpm->chip);
375-
if (ret) {
376-
dev_err(&pdev->dev, "failed to add PWM chip: %d\n", ret);
377-
clk_disable_unprepare(tpm->clk);
378-
}
379-
380-
return ret;
381-
}
382-
383-
static void pwm_imx_tpm_remove(struct platform_device *pdev)
384-
{
385-
struct imx_tpm_pwm_chip *tpm = platform_get_drvdata(pdev);
386-
387-
pwmchip_remove(&tpm->chip);
367+
ret = devm_pwmchip_add(&pdev->dev, &tpm->chip);
368+
if (ret)
369+
return dev_err_probe(&pdev->dev, ret, "failed to add PWM chip\n");
388370

389-
clk_disable_unprepare(tpm->clk);
371+
return 0;
390372
}
391373

392374
static int __maybe_unused pwm_imx_tpm_suspend(struct device *dev)
@@ -436,7 +418,6 @@ static struct platform_driver imx_tpm_pwm_driver = {
436418
.pm = &imx_tpm_pwm_pm,
437419
},
438420
.probe = pwm_imx_tpm_probe,
439-
.remove_new = pwm_imx_tpm_remove,
440421
};
441422
module_platform_driver(imx_tpm_pwm_driver);
442423

0 commit comments

Comments
 (0)