mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-14 07:44:21 +08:00
pwm: brcmstb: 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/20230929161918.2410424-4-u.kleine-koenig@pengutronix.de Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
This commit is contained in:
parent
2ce7b7f670
commit
5af615f8ac
@ -237,17 +237,10 @@ static int brcmstb_pwm_probe(struct platform_device *pdev)
|
||||
if (!p)
|
||||
return -ENOMEM;
|
||||
|
||||
p->clk = devm_clk_get(&pdev->dev, NULL);
|
||||
if (IS_ERR(p->clk)) {
|
||||
dev_err(&pdev->dev, "failed to obtain clock\n");
|
||||
return PTR_ERR(p->clk);
|
||||
}
|
||||
|
||||
ret = clk_prepare_enable(p->clk);
|
||||
if (ret < 0) {
|
||||
dev_err(&pdev->dev, "failed to enable clock: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
p->clk = devm_clk_get_enabled(&pdev->dev, NULL);
|
||||
if (IS_ERR(p->clk))
|
||||
return dev_err_probe(&pdev->dev, PTR_ERR(p->clk),
|
||||
"failed to obtain clock\n");
|
||||
|
||||
platform_set_drvdata(pdev, p);
|
||||
|
||||
@ -256,30 +249,14 @@ static int brcmstb_pwm_probe(struct platform_device *pdev)
|
||||
p->chip.npwm = 2;
|
||||
|
||||
p->base = devm_platform_ioremap_resource(pdev, 0);
|
||||
if (IS_ERR(p->base)) {
|
||||
ret = PTR_ERR(p->base);
|
||||
goto out_clk;
|
||||
}
|
||||
if (IS_ERR(p->base))
|
||||
return PTR_ERR(p->base);
|
||||
|
||||
ret = pwmchip_add(&p->chip);
|
||||
if (ret) {
|
||||
dev_err(&pdev->dev, "failed to add PWM chip: %d\n", ret);
|
||||
goto out_clk;
|
||||
}
|
||||
ret = devm_pwmchip_add(&pdev->dev, &p->chip);
|
||||
if (ret)
|
||||
return dev_err_probe(&pdev->dev, ret, "failed to add PWM chip\n");
|
||||
|
||||
return 0;
|
||||
|
||||
out_clk:
|
||||
clk_disable_unprepare(p->clk);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void brcmstb_pwm_remove(struct platform_device *pdev)
|
||||
{
|
||||
struct brcmstb_pwm *p = platform_get_drvdata(pdev);
|
||||
|
||||
pwmchip_remove(&p->chip);
|
||||
clk_disable_unprepare(p->clk);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PM_SLEEP
|
||||
@ -307,7 +284,6 @@ static SIMPLE_DEV_PM_OPS(brcmstb_pwm_pm_ops, brcmstb_pwm_suspend,
|
||||
|
||||
static struct platform_driver brcmstb_pwm_driver = {
|
||||
.probe = brcmstb_pwm_probe,
|
||||
.remove_new = brcmstb_pwm_remove,
|
||||
.driver = {
|
||||
.name = "pwm-brcmstb",
|
||||
.of_match_table = brcmstb_pwm_of_match,
|
||||
|
Loading…
Reference in New Issue
Block a user