pwm: sti: Simplify probe function using devm functions
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Sun, 10 Mar 2024 11:00:54 +0000 (12:00 +0100)
committerUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Fri, 26 Apr 2024 19:29:16 +0000 (21:29 +0200)
commit5bb0b194aeee5d5da6881232f4e9989b35957c25
tree545d0e939ac9060e6cd50e0310dcf56918c30ba6
parent4bda9700a55447dfcf33b219de1cf5d7904fdd4f
pwm: sti: Simplify probe function using devm functions

Instead of of_clk_get_by_name() use devm_clk_get_prepared() which has
several advantages:

 - Combines getting the clock and a call to clk_prepare(). The latter
   can be dropped from sti_pwm_probe() accordingly.
 - Cares for calling clk_put() which is missing in both probe's error
   path and the remove function.
 - Cares for calling clk_unprepare() which can be dropped from the error
   paths and the remove function. (Note that not all error path got this
   right.)

With additionally using devm_pwmchip_add() instead of pwmchip_add() the
remove callback can be dropped completely. With it the last user of
platform_get_drvdata() goes away and so platform_set_drvdata() can be
dropped from the probe function, too.

Fixes: 378fe115d19d ("pwm: sti: Add new driver for ST's PWM IP")
Link: https://lore.kernel.org/r/81f0e1d173652f435afda6719adaed1922fe059a.1710068192.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
drivers/pwm/pwm-sti.c