Skip to content

Commit 21c0e1a

Browse files
Uwe Kleine-Königthierryreding
authored andcommitted
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/[email protected] Signed-off-by: Uwe Kleine-König <[email protected]> Signed-off-by: Thierry Reding <[email protected]>
1 parent d8a2f6f commit 21c0e1a

File tree

1 file changed

+3
-14
lines changed

1 file changed

+3
-14
lines changed

drivers/pwm/pwm-sprd.c

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -242,10 +242,8 @@ static int sprd_pwm_clk_init(struct sprd_pwm_chip *spc)
242242
chn->clk_rate = clk_get_rate(clk_pwm);
243243
}
244244

245-
if (!i) {
246-
dev_err(spc->dev, "no available PWM channels\n");
247-
return -ENODEV;
248-
}
245+
if (!i)
246+
return dev_err_probe(spc->dev, -ENODEV, "no available PWM channels\n");
249247

250248
spc->num_pwms = i;
251249

@@ -266,7 +264,6 @@ static int sprd_pwm_probe(struct platform_device *pdev)
266264
return PTR_ERR(spc->base);
267265

268266
spc->dev = &pdev->dev;
269-
platform_set_drvdata(pdev, spc);
270267

271268
ret = sprd_pwm_clk_init(spc);
272269
if (ret)
@@ -276,20 +273,13 @@ static int sprd_pwm_probe(struct platform_device *pdev)
276273
spc->chip.ops = &sprd_pwm_ops;
277274
spc->chip.npwm = spc->num_pwms;
278275

279-
ret = pwmchip_add(&spc->chip);
276+
ret = devm_pwmchip_add(&pdev->dev, &spc->chip);
280277
if (ret)
281278
dev_err(&pdev->dev, "failed to add PWM chip\n");
282279

283280
return ret;
284281
}
285282

286-
static void sprd_pwm_remove(struct platform_device *pdev)
287-
{
288-
struct sprd_pwm_chip *spc = platform_get_drvdata(pdev);
289-
290-
pwmchip_remove(&spc->chip);
291-
}
292-
293283
static const struct of_device_id sprd_pwm_of_match[] = {
294284
{ .compatible = "sprd,ums512-pwm", },
295285
{ },
@@ -302,7 +292,6 @@ static struct platform_driver sprd_pwm_driver = {
302292
.of_match_table = sprd_pwm_of_match,
303293
},
304294
.probe = sprd_pwm_probe,
305-
.remove_new = sprd_pwm_remove,
306295
};
307296

308297
module_platform_driver(sprd_pwm_driver);

0 commit comments

Comments
 (0)