Skip to content

Commit 6dc0048

Browse files
ArvindYadavCsLinus Walleij
authored andcommitted
gpio: davinci: Handle return value of clk_prepare_enable
clk_prepare_enable() can fail here and we must check its return value. Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
1 parent f37e335 commit 6dc0048

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

‎drivers/gpio/gpio-davinci.c‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,7 @@ static int davinci_gpio_irq_setup(struct platform_device *pdev)
437437
{
438438
unsigned gpio, bank;
439439
int irq;
440+
int ret;
440441
struct clk *clk;
441442
u32 binten = 0;
442443
unsigned ngpio, bank_irq;
@@ -480,12 +481,15 @@ static int davinci_gpio_irq_setup(struct platform_device *pdev)
480481
PTR_ERR(clk));
481482
return PTR_ERR(clk);
482483
}
483-
clk_prepare_enable(clk);
484+
ret = clk_prepare_enable(clk);
485+
if (ret)
486+
return ret;
484487

485488
if (!pdata->gpio_unbanked) {
486489
irq = devm_irq_alloc_descs(dev, -1, 0, ngpio, 0);
487490
if (irq < 0) {
488491
dev_err(dev, "Couldn't allocate IRQ numbers\n");
492+
clk_disable_unprepare(clk);
489493
return irq;
490494
}
491495

@@ -494,6 +498,7 @@ static int davinci_gpio_irq_setup(struct platform_device *pdev)
494498
chips);
495499
if (!irq_domain) {
496500
dev_err(dev, "Couldn't register an IRQ domain\n");
501+
clk_disable_unprepare(clk);
497502
return -ENODEV;
498503
}
499504
}
@@ -562,8 +567,10 @@ static int davinci_gpio_irq_setup(struct platform_device *pdev)
562567
sizeof(struct
563568
davinci_gpio_irq_data),
564569
GFP_KERNEL);
565-
if (!irqdata)
570+
if (!irqdata) {
571+
clk_disable_unprepare(clk);
566572
return -ENOMEM;
573+
}
567574

568575
irqdata->regs = g;
569576
irqdata->bank_num = bank;

0 commit comments

Comments
 (0)