Commit b498c14e authored by Uwe Kleine-König's avatar Uwe Kleine-König Committed by Thierry Reding

pwm: bcm-iproc: 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-2-u.kleine-koenig@pengutronix.deSigned-off-by: default avatarUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: default avatarThierry Reding <thierry.reding@gmail.com>
parent 8151b37b
...@@ -206,18 +206,10 @@ static int iproc_pwmc_probe(struct platform_device *pdev) ...@@ -206,18 +206,10 @@ static int iproc_pwmc_probe(struct platform_device *pdev)
if (IS_ERR(ip->base)) if (IS_ERR(ip->base))
return PTR_ERR(ip->base); return PTR_ERR(ip->base);
ip->clk = devm_clk_get(&pdev->dev, NULL); ip->clk = devm_clk_get_enabled(&pdev->dev, NULL);
if (IS_ERR(ip->clk)) { if (IS_ERR(ip->clk))
dev_err(&pdev->dev, "failed to get clock: %ld\n", return dev_err_probe(&pdev->dev, PTR_ERR(ip->clk),
PTR_ERR(ip->clk)); "failed to get clock\n");
return PTR_ERR(ip->clk);
}
ret = clk_prepare_enable(ip->clk);
if (ret < 0) {
dev_err(&pdev->dev, "failed to enable clock: %d\n", ret);
return ret;
}
/* Set full drive and normal polarity for all channels */ /* Set full drive and normal polarity for all channels */
value = readl(ip->base + IPROC_PWM_CTRL_OFFSET); value = readl(ip->base + IPROC_PWM_CTRL_OFFSET);
...@@ -229,22 +221,12 @@ static int iproc_pwmc_probe(struct platform_device *pdev) ...@@ -229,22 +221,12 @@ static int iproc_pwmc_probe(struct platform_device *pdev)
writel(value, ip->base + IPROC_PWM_CTRL_OFFSET); writel(value, ip->base + IPROC_PWM_CTRL_OFFSET);
ret = pwmchip_add(&ip->chip); ret = devm_pwmchip_add(&pdev->dev, &ip->chip);
if (ret < 0) { if (ret < 0)
dev_err(&pdev->dev, "failed to add PWM chip: %d\n", ret); return dev_err_probe(&pdev->dev, ret,
clk_disable_unprepare(ip->clk); "failed to add PWM chip\n");
}
return ret;
}
static void iproc_pwmc_remove(struct platform_device *pdev)
{
struct iproc_pwmc *ip = platform_get_drvdata(pdev);
pwmchip_remove(&ip->chip); return 0;
clk_disable_unprepare(ip->clk);
} }
static const struct of_device_id bcm_iproc_pwmc_dt[] = { static const struct of_device_id bcm_iproc_pwmc_dt[] = {
...@@ -259,7 +241,6 @@ static struct platform_driver iproc_pwmc_driver = { ...@@ -259,7 +241,6 @@ static struct platform_driver iproc_pwmc_driver = {
.of_match_table = bcm_iproc_pwmc_dt, .of_match_table = bcm_iproc_pwmc_dt,
}, },
.probe = iproc_pwmc_probe, .probe = iproc_pwmc_probe,
.remove_new = iproc_pwmc_remove,
}; };
module_platform_driver(iproc_pwmc_driver); module_platform_driver(iproc_pwmc_driver);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment