drivers/rtc/rtc-sirfsoc.c: move hardware initilization earlier in probe
authorGuo Zeng <guo.zeng@csr.com>
Wed, 10 Dec 2014 23:52:24 +0000 (15:52 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 11 Dec 2014 01:41:13 +0000 (17:41 -0800)
Move rtc register to be later than hardware initialization.  The reason
is that devm_rtc_device_register() will do read_time() which is a
callback accessing hardware.  This sometimes causes a hang in the
hardware related callback.

Signed-off-by: Guo Zeng <guo.zeng@csr.com>
Signed-off-by: Barry Song <Baohua.Song@csr.com>
Cc: Alessandro Zummo <a.zummo@towertech.it>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
drivers/rtc/rtc-sirfsoc.c

index 76e38007ba90a5ae30c4d232f6477ea027f8045a..24ba97d3286e6c9cce18187e1fd78ac4a467be50 100644 (file)
@@ -286,14 +286,6 @@ static int sirfsoc_rtc_probe(struct platform_device *pdev)
        rtc_div = ((32768 / RTC_HZ) / 2) - 1;
        sirfsoc_rtc_iobrg_writel(rtc_div, rtcdrv->rtc_base + RTC_DIV);
 
-       rtcdrv->rtc = devm_rtc_device_register(&pdev->dev, pdev->name,
-                       &sirfsoc_rtc_ops, THIS_MODULE);
-       if (IS_ERR(rtcdrv->rtc)) {
-               err = PTR_ERR(rtcdrv->rtc);
-               dev_err(&pdev->dev, "can't register RTC device\n");
-               return err;
-       }
-
        /* 0x3 -> RTC_CLK */
        sirfsoc_rtc_iobrg_writel(SIRFSOC_RTC_CLK,
                        rtcdrv->rtc_base + RTC_CLOCK_SWITCH);
@@ -308,6 +300,14 @@ static int sirfsoc_rtc_probe(struct platform_device *pdev)
        rtcdrv->overflow_rtc =
                sirfsoc_rtc_iobrg_readl(rtcdrv->rtc_base + RTC_SW_VALUE);
 
+       rtcdrv->rtc = devm_rtc_device_register(&pdev->dev, pdev->name,
+                       &sirfsoc_rtc_ops, THIS_MODULE);
+       if (IS_ERR(rtcdrv->rtc)) {
+               err = PTR_ERR(rtcdrv->rtc);
+               dev_err(&pdev->dev, "can't register RTC device\n");
+               return err;
+       }
+
        rtcdrv->irq = platform_get_irq(pdev, 0);
        err = devm_request_irq(
                        &pdev->dev,