rtc: fix driver data issues in several rtc drivers
Herton Ronaldo Krzesinski recently raised up, and fixed, an issue with the
rtc_cmos driver, which was referring to an inconsistent driver data.
This patch ensures that driver data registration happens before
rtc_device_register().
Signed-off-by: Alessandro Zummo <a.zummo@towertech.it>
Acked-by: Thomas Hommel <thomas.hommel@gefanuc.com>
Acked-by: Hans-Christian Egtvedt <hcegtvedt@atmel.com>
Acked-by: Paul Mundt <lethal@linux-sh.org>
Cc: David S. Miller <davem@davemloft.net>
Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Cc: Andrew Sharp <andy.sharp@onstor.com>
Cc: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
Cc: Alexander Bigga <ab@mycable.de>
Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Cc: Mark Zhan <rongkai.zhan@windriver.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
diff --git a/drivers/rtc/rtc-stk17ta8.c b/drivers/rtc/rtc-stk17ta8.c
index d491eb2..62c2969 100644
--- a/drivers/rtc/rtc-stk17ta8.c
+++ b/drivers/rtc/rtc-stk17ta8.c
@@ -288,7 +288,6 @@
static int __devinit stk17ta8_rtc_probe(struct platform_device *pdev)
{
- struct rtc_device *rtc;
struct resource *res;
unsigned int cal;
unsigned int flags;
@@ -338,22 +337,23 @@
}
}
- rtc = rtc_device_register(pdev->name, &pdev->dev,
- &stk17ta8_rtc_ops, THIS_MODULE);
- if (IS_ERR(rtc)) {
- ret = PTR_ERR(rtc);
- goto out;
- }
- pdata->rtc = rtc;
pdata->last_jiffies = jiffies;
platform_set_drvdata(pdev, pdata);
- ret = sysfs_create_bin_file(&pdev->dev.kobj, &stk17ta8_nvram_attr);
- if (ret)
+
+ pdata->rtc = rtc_device_register(pdev->name, &pdev->dev,
+ &stk17ta8_rtc_ops, THIS_MODULE);
+ if (IS_ERR(pdata->rtc)) {
+ ret = PTR_ERR(pdata->rtc);
goto out;
+ }
+
+ ret = sysfs_create_bin_file(&pdev->dev.kobj, &stk17ta8_nvram_attr);
+ if (ret) {
+ rtc_device_unregister(pdata->rtc);
+ goto out;
+ }
return 0;
out:
- if (pdata->rtc)
- rtc_device_unregister(pdata->rtc);
if (pdata->irq > 0)
free_irq(pdata->irq, pdev);
if (ioaddr)