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

pwm: mtk-disp: Simplify using devm_pwmchip_add()

With devm_pwmchip_add() pwmchip_remove() can be dropped from the remove
callback. Then the remove callback is empty and can go away, too. With
mtk_disp_pwm_remove() the last user of platform_get_drvdata() is gone and
so platform_set_drvdata() can be dropped, too.

Also use dev_err_probe() for simplified (and improved) error reporting.

Link: https://lore.kernel.org/r/20230929161918.2410424-6-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 92fcd5b6
...@@ -246,34 +246,25 @@ static int mtk_disp_pwm_probe(struct platform_device *pdev) ...@@ -246,34 +246,25 @@ static int mtk_disp_pwm_probe(struct platform_device *pdev)
mdp->clk_main = devm_clk_get(&pdev->dev, "main"); mdp->clk_main = devm_clk_get(&pdev->dev, "main");
if (IS_ERR(mdp->clk_main)) if (IS_ERR(mdp->clk_main))
return PTR_ERR(mdp->clk_main); return dev_err_probe(&pdev->dev, PTR_ERR(mdp->clk_main),
"Failed to get main clock\n");
mdp->clk_mm = devm_clk_get(&pdev->dev, "mm"); mdp->clk_mm = devm_clk_get(&pdev->dev, "mm");
if (IS_ERR(mdp->clk_mm)) if (IS_ERR(mdp->clk_mm))
return PTR_ERR(mdp->clk_mm); return dev_err_probe(&pdev->dev, PTR_ERR(mdp->clk_mm),
"Failed to get mm clock\n");
mdp->chip.dev = &pdev->dev; mdp->chip.dev = &pdev->dev;
mdp->chip.ops = &mtk_disp_pwm_ops; mdp->chip.ops = &mtk_disp_pwm_ops;
mdp->chip.npwm = 1; mdp->chip.npwm = 1;
ret = pwmchip_add(&mdp->chip); ret = devm_pwmchip_add(&pdev->dev, &mdp->chip);
if (ret < 0) { if (ret < 0)
dev_err(&pdev->dev, "pwmchip_add() failed: %pe\n", ERR_PTR(ret)); return dev_err_probe(&pdev->dev, ret, "pwmchip_add() failed\n");
return ret;
}
platform_set_drvdata(pdev, mdp);
return 0; return 0;
} }
static void mtk_disp_pwm_remove(struct platform_device *pdev)
{
struct mtk_disp_pwm *mdp = platform_get_drvdata(pdev);
pwmchip_remove(&mdp->chip);
}
static const struct mtk_pwm_data mt2701_pwm_data = { static const struct mtk_pwm_data mt2701_pwm_data = {
.enable_mask = BIT(16), .enable_mask = BIT(16),
.con0 = 0xa8, .con0 = 0xa8,
...@@ -319,7 +310,6 @@ static struct platform_driver mtk_disp_pwm_driver = { ...@@ -319,7 +310,6 @@ static struct platform_driver mtk_disp_pwm_driver = {
.of_match_table = mtk_disp_pwm_of_match, .of_match_table = mtk_disp_pwm_of_match,
}, },
.probe = mtk_disp_pwm_probe, .probe = mtk_disp_pwm_probe,
.remove_new = mtk_disp_pwm_remove,
}; };
module_platform_driver(mtk_disp_pwm_driver); module_platform_driver(mtk_disp_pwm_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