From patchwork Thu May 5 09:46:15 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [2/2] rtc: ep93xx: fix crash on boot Date: Wed, 04 May 2011 23:46:15 -0000 From: Wolfram Sang X-Patchwork-Id: 94215 Message-Id: <1304588775-30408-2-git-send-email-w.sang@pengutronix.de> To: rtc-linux@googlegroups.com Cc: Wolfram Sang , john stultz , Alessandro Zummo (maintainer:REAL TIME CLOCK (...), linux-kernel@vger.kernel.org (open list) Commit f44f7f96a20 ("RTC: Initialize kernel state from RTC") caused a crash when initializing the driver. The reason is that rtc_device_register() calls rtc_read_alarm() after that change, when the driver does not have all driver data set up yet. Signed-off-by: Wolfram Sang Cc: john stultz Acked-by: John Stultz --- drivers/rtc/rtc-ep93xx.c | 5 ++--- 1 files changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/rtc/rtc-ep93xx.c b/drivers/rtc/rtc-ep93xx.c index 11ae64d..335551d 100644 --- a/drivers/rtc/rtc-ep93xx.c +++ b/drivers/rtc/rtc-ep93xx.c @@ -151,6 +151,7 @@ static int __init ep93xx_rtc_probe(struct platform_device *pdev) return -ENXIO; pdev->dev.platform_data = ep93xx_rtc; + platform_set_drvdata(pdev, rtc); rtc = rtc_device_register(pdev->name, &pdev->dev, &ep93xx_rtc_ops, THIS_MODULE); @@ -159,8 +160,6 @@ static int __init ep93xx_rtc_probe(struct platform_device *pdev) goto exit; } - platform_set_drvdata(pdev, rtc); - err = sysfs_create_group(&pdev->dev.kobj, &ep93xx_rtc_sysfs_files); if (err) goto fail; @@ -168,9 +167,9 @@ static int __init ep93xx_rtc_probe(struct platform_device *pdev) return 0; fail: - platform_set_drvdata(pdev, NULL); rtc_device_unregister(rtc); exit: + platform_set_drvdata(pdev, NULL); pdev->dev.platform_data = NULL; return err; }