mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-03 12:24:37 -04:00
pwm: samsung: Simplify by using devm functions in probe
With using devm_clk_get_enabled() and devm_pwmchip_add() the .remove_new() callback can be dropped and an error path in .probe() simplified. Link: https://lore.kernel.org/r/d46ec625c14c460039082f74ec8ca3084b7c8e3a.1707900770.git.u.kleine-koenig@pengutronix.de Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
This commit is contained in:
@@ -577,18 +577,12 @@ static int pwm_samsung_probe(struct platform_device *pdev)
|
||||
if (IS_ERR(our_chip->base))
|
||||
return PTR_ERR(our_chip->base);
|
||||
|
||||
our_chip->base_clk = devm_clk_get(&pdev->dev, "timers");
|
||||
our_chip->base_clk = devm_clk_get_enabled(&pdev->dev, "timers");
|
||||
if (IS_ERR(our_chip->base_clk)) {
|
||||
dev_err(dev, "failed to get timer base clk\n");
|
||||
return PTR_ERR(our_chip->base_clk);
|
||||
}
|
||||
|
||||
ret = clk_prepare_enable(our_chip->base_clk);
|
||||
if (ret < 0) {
|
||||
dev_err(dev, "failed to enable base clock\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
for (chan = 0; chan < SAMSUNG_PWM_NUM; ++chan)
|
||||
if (our_chip->variant.output_mask & BIT(chan))
|
||||
pwm_samsung_set_invert(our_chip, chan, true);
|
||||
@@ -599,10 +593,9 @@ static int pwm_samsung_probe(struct platform_device *pdev)
|
||||
|
||||
platform_set_drvdata(pdev, chip);
|
||||
|
||||
ret = pwmchip_add(chip);
|
||||
ret = devm_pwmchip_add(&pdev->dev, chip);
|
||||
if (ret < 0) {
|
||||
dev_err(dev, "failed to register PWM chip\n");
|
||||
clk_disable_unprepare(our_chip->base_clk);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -614,16 +607,6 @@ static int pwm_samsung_probe(struct platform_device *pdev)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void pwm_samsung_remove(struct platform_device *pdev)
|
||||
{
|
||||
struct pwm_chip *chip = platform_get_drvdata(pdev);
|
||||
struct samsung_pwm_chip *our_chip = to_samsung_pwm_chip(chip);
|
||||
|
||||
pwmchip_remove(chip);
|
||||
|
||||
clk_disable_unprepare(our_chip->base_clk);
|
||||
}
|
||||
|
||||
static int pwm_samsung_resume(struct device *dev)
|
||||
{
|
||||
struct pwm_chip *chip = dev_get_drvdata(dev);
|
||||
@@ -666,7 +649,6 @@ static struct platform_driver pwm_samsung_driver = {
|
||||
.of_match_table = of_match_ptr(samsung_pwm_matches),
|
||||
},
|
||||
.probe = pwm_samsung_probe,
|
||||
.remove_new = pwm_samsung_remove,
|
||||
};
|
||||
module_platform_driver(pwm_samsung_driver);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user