summaryrefslogtreecommitdiff
path: root/drivers/rtc/rtc-mc13xxx.c
diff options
context:
space:
mode:
authorAlexander Shiyan <shc_work@mail.ru>2014-04-04 01:50:15 +0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-04-04 03:21:23 +0400
commit5ab9a52a3af613b74a7cda033c1623c7913c50d9 (patch)
treeb338efd146a165d320740912d779d94f3159f341 /drivers/rtc/rtc-mc13xxx.c
parentfda9909ddaab13fb7b35b94f204623c1f9571fc7 (diff)
downloadlinux-5ab9a52a3af613b74a7cda033c1623c7913c50d9.tar.xz
drivers/rtc/rtc-mc13xxx.c: fix potential race condition
RTC drivers must not return an error after device registration. This patch makes RTC registration as the last action. Signed-off-by: Alexander Shiyan <shc_work@mail.ru> Acked-by: Alessandro Zummo <a.zummo@towertech.it> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/rtc/rtc-mc13xxx.c')
-rw-r--r--drivers/rtc/rtc-mc13xxx.c30
1 files changed, 13 insertions, 17 deletions
diff --git a/drivers/rtc/rtc-mc13xxx.c b/drivers/rtc/rtc-mc13xxx.c
index 9b1a77eb91a9..0765606a2d14 100644
--- a/drivers/rtc/rtc-mc13xxx.c
+++ b/drivers/rtc/rtc-mc13xxx.c
@@ -247,8 +247,6 @@ static irqreturn_t mc13xxx_rtc_alarm_handler(int irq, void *dev)
struct mc13xxx_rtc *priv = dev;
struct mc13xxx *mc13xxx = priv->mc13xxx;
- dev_dbg(&priv->rtc->dev, "Alarm\n");
-
rtc_update_irq(priv->rtc, 1, RTC_IRQF | RTC_AF);
mc13xxx_irq_ack(mc13xxx, irq);
@@ -261,8 +259,6 @@ static irqreturn_t mc13xxx_rtc_update_handler(int irq, void *dev)
struct mc13xxx_rtc *priv = dev;
struct mc13xxx *mc13xxx = priv->mc13xxx;
- dev_dbg(&priv->rtc->dev, "1HZ\n");
-
rtc_update_irq(priv->rtc, 1, RTC_IRQF | RTC_UF);
mc13xxx_irq_ack(mc13xxx, irq);
@@ -283,7 +279,6 @@ static irqreturn_t mc13xxx_rtc_reset_handler(int irq, void *dev)
struct mc13xxx_rtc *priv = dev;
struct mc13xxx *mc13xxx = priv->mc13xxx;
- dev_warn(&priv->rtc->dev, "Contents of the RTC are no longer valid\n");
priv->valid = 0;
mc13xxx_irq_mask(mc13xxx, irq);
@@ -307,11 +302,6 @@ static int __init mc13xxx_rtc_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, priv);
- priv->rtc = devm_rtc_device_register(&pdev->dev, pdev->name,
- &mc13xxx_rtc_ops, THIS_MODULE);
- if (IS_ERR(priv->rtc))
- return PTR_ERR(priv->rtc);
-
mc13xxx_lock(mc13xxx);
mc13xxx_irq_ack(mc13xxx, MC13XXX_IRQ_RTCRST);
@@ -319,24 +309,30 @@ static int __init mc13xxx_rtc_probe(struct platform_device *pdev)
ret = mc13xxx_irq_request(mc13xxx, MC13XXX_IRQ_RTCRST,
mc13xxx_rtc_reset_handler, DRIVER_NAME, priv);
if (ret)
- goto err_reset_irq_request;
+ goto err_irq_request;
ret = mc13xxx_irq_request(mc13xxx, MC13XXX_IRQ_1HZ,
mc13xxx_rtc_update_handler, DRIVER_NAME, priv);
if (ret)
- goto err_reset_irq_status;
+ goto err_irq_request;
ret = mc13xxx_irq_request_nounmask(mc13xxx, MC13XXX_IRQ_TODA,
mc13xxx_rtc_alarm_handler, DRIVER_NAME, priv);
- if (!ret)
- goto err_reset_irq_request;
+ if (ret)
+ goto err_irq_request;
- mc13xxx_irq_free(mc13xxx, MC13XXX_IRQ_1HZ, priv);
+ mc13xxx_unlock(mc13xxx);
+
+ priv->rtc = devm_rtc_device_register(&pdev->dev, pdev->name,
+ &mc13xxx_rtc_ops, THIS_MODULE);
-err_reset_irq_status:
+ return 0;
+
+err_irq_request:
+ mc13xxx_irq_free(mc13xxx, MC13XXX_IRQ_TODA, priv);
+ mc13xxx_irq_free(mc13xxx, MC13XXX_IRQ_1HZ, priv);
mc13xxx_irq_free(mc13xxx, MC13XXX_IRQ_RTCRST, priv);
-err_reset_irq_request:
mc13xxx_unlock(mc13xxx);
return ret;