Skip to content

Commit 14b9dc6

Browse files
ukleinekUwe Kleine-König
authored andcommitted
pwm: xilinx: Simplify using devm_ functions
There are devm variants for clk_prepare_enable() and pwmchip_add(); and clk_prepare_enable() can be done together with devm_clk_get(). This allows to simplify the error paths in .probe() and drop .remove() completely. With the remove callback gone, the last user of platform_get_drvdata() is gone and so the call to platform_set_drvdata() can be dropped, too. Signed-off-by: Uwe Kleine-König <[email protected]> Reviewed-by: Sean Anderson <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Uwe Kleine-König <[email protected]>
1 parent 0007fa1 commit 14b9dc6

File tree

1 file changed

+6
-21
lines changed

1 file changed

+6
-21
lines changed

drivers/pwm/pwm-xilinx.c

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,6 @@ static int xilinx_pwm_probe(struct platform_device *pdev)
224224
if (IS_ERR(chip))
225225
return PTR_ERR(chip);
226226
priv = xilinx_pwm_chip_to_priv(chip);
227-
platform_set_drvdata(pdev, chip);
228227

229228
regs = devm_platform_ioremap_resource(pdev, 0);
230229
if (IS_ERR(regs))
@@ -263,37 +262,24 @@ static int xilinx_pwm_probe(struct platform_device *pdev)
263262
* alas, such properties are not allowed to be used.
264263
*/
265264

266-
priv->clk = devm_clk_get(dev, "s_axi_aclk");
265+
priv->clk = devm_clk_get_enabled(dev, "s_axi_aclk");
267266
if (IS_ERR(priv->clk))
268267
return dev_err_probe(dev, PTR_ERR(priv->clk),
269268
"Could not get clock\n");
270269

271-
ret = clk_prepare_enable(priv->clk);
270+
ret = devm_clk_rate_exclusive_get(dev, priv->clk);
272271
if (ret)
273-
return dev_err_probe(dev, ret, "Clock enable failed\n");
274-
clk_rate_exclusive_get(priv->clk);
272+
return dev_err_probe(dev, ret,
273+
"Failed to lock clock rate\n");
275274

276275
chip->ops = &xilinx_pwm_ops;
277-
ret = pwmchip_add(chip);
278-
if (ret) {
279-
clk_rate_exclusive_put(priv->clk);
280-
clk_disable_unprepare(priv->clk);
276+
ret = devm_pwmchip_add(dev, chip);
277+
if (ret)
281278
return dev_err_probe(dev, ret, "Could not register PWM chip\n");
282-
}
283279

284280
return 0;
285281
}
286282

287-
static void xilinx_pwm_remove(struct platform_device *pdev)
288-
{
289-
struct pwm_chip *chip = platform_get_drvdata(pdev);
290-
struct xilinx_timer_priv *priv = xilinx_pwm_chip_to_priv(chip);
291-
292-
pwmchip_remove(chip);
293-
clk_rate_exclusive_put(priv->clk);
294-
clk_disable_unprepare(priv->clk);
295-
}
296-
297283
static const struct of_device_id xilinx_pwm_of_match[] = {
298284
{ .compatible = "xlnx,xps-timer-1.00.a", },
299285
{},
@@ -302,7 +288,6 @@ MODULE_DEVICE_TABLE(of, xilinx_pwm_of_match);
302288

303289
static struct platform_driver xilinx_pwm_driver = {
304290
.probe = xilinx_pwm_probe,
305-
.remove_new = xilinx_pwm_remove,
306291
.driver = {
307292
.name = "xilinx-pwm",
308293
.of_match_table = of_match_ptr(xilinx_pwm_of_match),

0 commit comments

Comments
 (0)