Skip to content

Commit 2ce7b7f

Browse files
Uwe Kleine-Königthierryreding
authored andcommitted
pwm: bcm2835: Simplify using devm functions
With devm_clk_get_enabled() the call to clk_disable_unprepare() can be dropped from the error path and the remove callback. With devm_pwmchip_add() pwmchip_remove() can be dropped. Then the remove callback is empty and can go away, too. With bcm2835_pwm_remove() the only user of platform_get_drvdata() is gone and so platform_set_drvdata() can be dropped from .probe(), too. Also use dev_err_probe() for simplified (and improved) error reporting. 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 b498c14 commit 2ce7b7f

File tree

1 file changed

+4
-23
lines changed

1 file changed

+4
-23
lines changed

drivers/pwm/pwm-bcm2835.c

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -146,39 +146,21 @@ static int bcm2835_pwm_probe(struct platform_device *pdev)
146146
if (IS_ERR(pc->base))
147147
return PTR_ERR(pc->base);
148148

149-
pc->clk = devm_clk_get(&pdev->dev, NULL);
149+
pc->clk = devm_clk_get_enabled(&pdev->dev, NULL);
150150
if (IS_ERR(pc->clk))
151151
return dev_err_probe(&pdev->dev, PTR_ERR(pc->clk),
152152
"clock not found\n");
153153

154-
ret = clk_prepare_enable(pc->clk);
155-
if (ret)
156-
return ret;
157-
158154
pc->chip.dev = &pdev->dev;
159155
pc->chip.ops = &bcm2835_pwm_ops;
160156
pc->chip.npwm = 2;
161157

162-
platform_set_drvdata(pdev, pc);
163-
164-
ret = pwmchip_add(&pc->chip);
158+
ret = devm_pwmchip_add(&pdev->dev, &pc->chip);
165159
if (ret < 0)
166-
goto add_fail;
160+
return dev_err_probe(&pdev->dev, ret,
161+
"failed to add pwmchip\n");
167162

168163
return 0;
169-
170-
add_fail:
171-
clk_disable_unprepare(pc->clk);
172-
return ret;
173-
}
174-
175-
static void bcm2835_pwm_remove(struct platform_device *pdev)
176-
{
177-
struct bcm2835_pwm *pc = platform_get_drvdata(pdev);
178-
179-
pwmchip_remove(&pc->chip);
180-
181-
clk_disable_unprepare(pc->clk);
182164
}
183165

184166
static const struct of_device_id bcm2835_pwm_of_match[] = {
@@ -193,7 +175,6 @@ static struct platform_driver bcm2835_pwm_driver = {
193175
.of_match_table = bcm2835_pwm_of_match,
194176
},
195177
.probe = bcm2835_pwm_probe,
196-
.remove_new = bcm2835_pwm_remove,
197178
};
198179
module_platform_driver(bcm2835_pwm_driver);
199180

0 commit comments

Comments
 (0)