Skip to content

Commit d14f6f4

Browse files
author
Bartosz Golaszewski
committed
gpio: davinci: use devm_clk_get_enabled()
Simplify the code in error paths by using the managed variant of the clock getter that controls the clock state as well. Reviewed-by: Linus Walleij <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Bartosz Golaszewski <[email protected]>
1 parent d29e741 commit d14f6f4

File tree

1 file changed

+2
-11
lines changed

1 file changed

+2
-11
lines changed

drivers/gpio/gpio-davinci.c

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,6 @@ static int davinci_gpio_irq_setup(struct platform_device *pdev)
446446
{
447447
unsigned gpio, bank;
448448
int irq;
449-
int ret;
450449
struct clk *clk;
451450
u32 binten = 0;
452451
unsigned ngpio;
@@ -467,21 +466,16 @@ static int davinci_gpio_irq_setup(struct platform_device *pdev)
467466

468467
ngpio = chips->chip.ngpio;
469468

470-
clk = devm_clk_get(dev, "gpio");
469+
clk = devm_clk_get_enabled(dev, "gpio");
471470
if (IS_ERR(clk)) {
472471
dev_err(dev, "Error %ld getting gpio clock\n", PTR_ERR(clk));
473472
return PTR_ERR(clk);
474473
}
475474

476-
ret = clk_prepare_enable(clk);
477-
if (ret)
478-
return ret;
479-
480475
if (chips->gpio_unbanked) {
481476
irq = devm_irq_alloc_descs(dev, -1, 0, ngpio, 0);
482477
if (irq < 0) {
483478
dev_err(dev, "Couldn't allocate IRQ numbers\n");
484-
clk_disable_unprepare(clk);
485479
return irq;
486480
}
487481

@@ -490,7 +484,6 @@ static int davinci_gpio_irq_setup(struct platform_device *pdev)
490484
chips);
491485
if (!irq_domain) {
492486
dev_err(dev, "Couldn't register an IRQ domain\n");
493-
clk_disable_unprepare(clk);
494487
return -ENODEV;
495488
}
496489
}
@@ -559,10 +552,8 @@ static int davinci_gpio_irq_setup(struct platform_device *pdev)
559552
sizeof(struct
560553
davinci_gpio_irq_data),
561554
GFP_KERNEL);
562-
if (!irqdata) {
563-
clk_disable_unprepare(clk);
555+
if (!irqdata)
564556
return -ENOMEM;
565-
}
566557

567558
irqdata->regs = g;
568559
irqdata->bank_num = bank;

0 commit comments

Comments
 (0)