mirror of
https://github.com/torvalds/linux.git
synced 2025-11-03 18:20:25 +02:00
pwm: sprd: Simplify using devm_pwmchip_add() and dev_err_probe()
Using devm_pwmchip_add() allows to drop pwmchip_remove() from the remove function which makes this function empty. Then there is no user of drvdata left and platform_set_drvdata() can be dropped, too. Further simplify and improve error returning using dev_err_probe(). Link: https://lore.kernel.org/r/20230929161918.2410424-9-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
d8a2f6f26a
commit
21c0e1aaf7
1 changed files with 3 additions and 14 deletions
|
|
@ -242,10 +242,8 @@ static int sprd_pwm_clk_init(struct sprd_pwm_chip *spc)
|
||||||
chn->clk_rate = clk_get_rate(clk_pwm);
|
chn->clk_rate = clk_get_rate(clk_pwm);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!i) {
|
if (!i)
|
||||||
dev_err(spc->dev, "no available PWM channels\n");
|
return dev_err_probe(spc->dev, -ENODEV, "no available PWM channels\n");
|
||||||
return -ENODEV;
|
|
||||||
}
|
|
||||||
|
|
||||||
spc->num_pwms = i;
|
spc->num_pwms = i;
|
||||||
|
|
||||||
|
|
@ -266,7 +264,6 @@ static int sprd_pwm_probe(struct platform_device *pdev)
|
||||||
return PTR_ERR(spc->base);
|
return PTR_ERR(spc->base);
|
||||||
|
|
||||||
spc->dev = &pdev->dev;
|
spc->dev = &pdev->dev;
|
||||||
platform_set_drvdata(pdev, spc);
|
|
||||||
|
|
||||||
ret = sprd_pwm_clk_init(spc);
|
ret = sprd_pwm_clk_init(spc);
|
||||||
if (ret)
|
if (ret)
|
||||||
|
|
@ -276,20 +273,13 @@ static int sprd_pwm_probe(struct platform_device *pdev)
|
||||||
spc->chip.ops = &sprd_pwm_ops;
|
spc->chip.ops = &sprd_pwm_ops;
|
||||||
spc->chip.npwm = spc->num_pwms;
|
spc->chip.npwm = spc->num_pwms;
|
||||||
|
|
||||||
ret = pwmchip_add(&spc->chip);
|
ret = devm_pwmchip_add(&pdev->dev, &spc->chip);
|
||||||
if (ret)
|
if (ret)
|
||||||
dev_err(&pdev->dev, "failed to add PWM chip\n");
|
dev_err(&pdev->dev, "failed to add PWM chip\n");
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sprd_pwm_remove(struct platform_device *pdev)
|
|
||||||
{
|
|
||||||
struct sprd_pwm_chip *spc = platform_get_drvdata(pdev);
|
|
||||||
|
|
||||||
pwmchip_remove(&spc->chip);
|
|
||||||
}
|
|
||||||
|
|
||||||
static const struct of_device_id sprd_pwm_of_match[] = {
|
static const struct of_device_id sprd_pwm_of_match[] = {
|
||||||
{ .compatible = "sprd,ums512-pwm", },
|
{ .compatible = "sprd,ums512-pwm", },
|
||||||
{ },
|
{ },
|
||||||
|
|
@ -302,7 +292,6 @@ static struct platform_driver sprd_pwm_driver = {
|
||||||
.of_match_table = sprd_pwm_of_match,
|
.of_match_table = sprd_pwm_of_match,
|
||||||
},
|
},
|
||||||
.probe = sprd_pwm_probe,
|
.probe = sprd_pwm_probe,
|
||||||
.remove_new = sprd_pwm_remove,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
module_platform_driver(sprd_pwm_driver);
|
module_platform_driver(sprd_pwm_driver);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue