Skip to content

Commit

Permalink
rtc: at91sam9: properly handle error case
Browse files Browse the repository at this point in the history
In case of a probe error, it is possible to abort after issuing
clk_prepare_enable(). Ensure the clock is disabled and unprepared in that
case.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Acked-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
  • Loading branch information
Alexandre Belloni committed Sep 5, 2015
1 parent 27675ef commit ffe60fc
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions drivers/rtc/rtc-at91sam9.c
Original file line number Diff line number Diff line change
Expand Up @@ -451,16 +451,18 @@ static int at91_rtc_probe(struct platform_device *pdev)

rtc->rtcdev = devm_rtc_device_register(&pdev->dev, pdev->name,
&at91_rtc_ops, THIS_MODULE);
if (IS_ERR(rtc->rtcdev))
return PTR_ERR(rtc->rtcdev);
if (IS_ERR(rtc->rtcdev)) {
ret = PTR_ERR(rtc->rtcdev);
goto err_clk;
}

/* register irq handler after we know what name we'll use */
ret = devm_request_irq(&pdev->dev, rtc->irq, at91_rtc_interrupt,
IRQF_SHARED | IRQF_COND_SUSPEND,
dev_name(&rtc->rtcdev->dev), rtc);
if (ret) {
dev_dbg(&pdev->dev, "can't share IRQ %d?\n", rtc->irq);
return ret;
goto err_clk;
}

/* NOTE: sam9260 rev A silicon has a ROM bug which resets the
Expand All @@ -474,6 +476,11 @@ static int at91_rtc_probe(struct platform_device *pdev)
dev_name(&rtc->rtcdev->dev));

return 0;

err_clk:
clk_disable_unprepare(rtc->sclk);

return ret;
}

/*
Expand Down

0 comments on commit ffe60fc

Please sign in to comment.