diff mbox series

[v6,099/164] pwm: samsung: Simplify by using devm functions in probe

Message ID d46ec625c14c460039082f74ec8ca3084b7c8e3a.1707900770.git.u.kleine-koenig@pengutronix.de (mailing list archive)
State New, archived
Headers show
Series [v6,001/164] pwm: Provide an inline function to get the parent device of a given chip | expand

Commit Message

Uwe Kleine-König Feb. 14, 2024, 9:32 a.m. UTC
With using devm_clk_get_enabled() and devm_pwmchip_add() the
.remove_new() callback can be dropped and an error path in .probe()
simplified.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/pwm/pwm-samsung.c | 22 ++--------------------
 1 file changed, 2 insertions(+), 20 deletions(-)
diff mbox series

Patch

diff --git a/drivers/pwm/pwm-samsung.c b/drivers/pwm/pwm-samsung.c
index cabdcdf37ec9..81a2e66e927e 100644
--- a/drivers/pwm/pwm-samsung.c
+++ b/drivers/pwm/pwm-samsung.c
@@ -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);