Skip to content

Commit 8abc67a

Browse files
Zhang ZekunBartosz Golaszewski
authored andcommitted
gpio: lpc18xx: Use helper function devm_clk_get_enabled()
devm_clk_get() and clk_prepare_enable() can be replaced by helper function devm_clk_get_enabled(). Let's use devm_clk_get_enabled() to simplify code and avoid calling clk_disable_unprepare(). Signed-off-by: Zhang Zekun <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Bartosz Golaszewski <[email protected]>
1 parent da426ed commit 8abc67a

File tree

1 file changed

+6
-17
lines changed

1 file changed

+6
-17
lines changed

drivers/gpio/gpio-lpc18xx.c

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ struct lpc18xx_gpio_pin_ic {
4747
struct lpc18xx_gpio_chip {
4848
struct gpio_chip gpio;
4949
void __iomem *base;
50-
struct clk *clk;
5150
struct lpc18xx_gpio_pin_ic *pin_ic;
5251
spinlock_t lock;
5352
};
@@ -328,6 +327,7 @@ static int lpc18xx_gpio_probe(struct platform_device *pdev)
328327
struct device *dev = &pdev->dev;
329328
struct lpc18xx_gpio_chip *gc;
330329
int index, ret;
330+
struct clk *clk;
331331

332332
gc = devm_kzalloc(dev, sizeof(*gc), GFP_KERNEL);
333333
if (!gc)
@@ -352,28 +352,19 @@ static int lpc18xx_gpio_probe(struct platform_device *pdev)
352352
if (IS_ERR(gc->base))
353353
return PTR_ERR(gc->base);
354354

355-
gc->clk = devm_clk_get(dev, NULL);
356-
if (IS_ERR(gc->clk)) {
355+
clk = devm_clk_get_enabled(dev, NULL);
356+
if (IS_ERR(clk)) {
357357
dev_err(dev, "input clock not found\n");
358-
return PTR_ERR(gc->clk);
359-
}
360-
361-
ret = clk_prepare_enable(gc->clk);
362-
if (ret) {
363-
dev_err(dev, "unable to enable clock\n");
364-
return ret;
358+
return PTR_ERR(clk);
365359
}
366360

367361
spin_lock_init(&gc->lock);
368362

369363
gc->gpio.parent = dev;
370364

371365
ret = devm_gpiochip_add_data(dev, &gc->gpio, gc);
372-
if (ret) {
373-
dev_err(dev, "failed to add gpio chip\n");
374-
clk_disable_unprepare(gc->clk);
375-
return ret;
376-
}
366+
if (ret)
367+
return dev_err_probe(dev, ret, "failed to add gpio chip\n");
377368

378369
/* On error GPIO pin interrupt controller just won't be registered */
379370
lpc18xx_gpio_pin_ic_probe(gc);
@@ -387,8 +378,6 @@ static void lpc18xx_gpio_remove(struct platform_device *pdev)
387378

388379
if (gc->pin_ic)
389380
irq_domain_remove(gc->pin_ic->domain);
390-
391-
clk_disable_unprepare(gc->clk);
392381
}
393382

394383
static const struct of_device_id lpc18xx_gpio_match[] = {

0 commit comments

Comments
 (0)