diff options
author | Alessandro Zummo <alessandro.zummo@towertech.it> | 2009-12-15 19:45:53 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-12-16 10:19:58 -0500 |
commit | b74d2caa64f8e542e9c6716ae6ed4a60d681ea9f (patch) | |
tree | 3d34fb87043b4a800bd35455725ba81638541cc3 /drivers/rtc/rtc-ds1305.c | |
parent | d1b2efa83fbf7b33919238fa29ef6ab935820103 (diff) |
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>
Diffstat (limited to 'drivers/rtc/rtc-ds1305.c')
-rw-r--r-- | drivers/rtc/rtc-ds1305.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/drivers/rtc/rtc-ds1305.c b/drivers/rtc/rtc-ds1305.c index 2736b11a1b1e..259db7f3535b 100644 --- a/drivers/rtc/rtc-ds1305.c +++ b/drivers/rtc/rtc-ds1305.c | |||
@@ -617,7 +617,6 @@ static struct bin_attribute nvram = { | |||
617 | static int __devinit ds1305_probe(struct spi_device *spi) | 617 | static int __devinit ds1305_probe(struct spi_device *spi) |
618 | { | 618 | { |
619 | struct ds1305 *ds1305; | 619 | struct ds1305 *ds1305; |
620 | struct rtc_device *rtc; | ||
621 | int status; | 620 | int status; |
622 | u8 addr, value; | 621 | u8 addr, value; |
623 | struct ds1305_platform_data *pdata = spi->dev.platform_data; | 622 | struct ds1305_platform_data *pdata = spi->dev.platform_data; |
@@ -756,14 +755,13 @@ static int __devinit ds1305_probe(struct spi_device *spi) | |||
756 | dev_dbg(&spi->dev, "AM/PM\n"); | 755 | dev_dbg(&spi->dev, "AM/PM\n"); |
757 | 756 | ||
758 | /* register RTC ... from here on, ds1305->ctrl needs locking */ | 757 | /* register RTC ... from here on, ds1305->ctrl needs locking */ |
759 | rtc = rtc_device_register("ds1305", &spi->dev, | 758 | ds1305->rtc = rtc_device_register("ds1305", &spi->dev, |
760 | &ds1305_ops, THIS_MODULE); | 759 | &ds1305_ops, THIS_MODULE); |
761 | if (IS_ERR(rtc)) { | 760 | if (IS_ERR(ds1305->rtc)) { |
762 | status = PTR_ERR(rtc); | 761 | status = PTR_ERR(ds1305->rtc); |
763 | dev_dbg(&spi->dev, "register rtc --> %d\n", status); | 762 | dev_dbg(&spi->dev, "register rtc --> %d\n", status); |
764 | goto fail0; | 763 | goto fail0; |
765 | } | 764 | } |
766 | ds1305->rtc = rtc; | ||
767 | 765 | ||
768 | /* Maybe set up alarm IRQ; be ready to handle it triggering right | 766 | /* Maybe set up alarm IRQ; be ready to handle it triggering right |
769 | * away. NOTE that we don't share this. The signal is active low, | 767 | * away. NOTE that we don't share this. The signal is active low, |
@@ -774,7 +772,7 @@ static int __devinit ds1305_probe(struct spi_device *spi) | |||
774 | if (spi->irq) { | 772 | if (spi->irq) { |
775 | INIT_WORK(&ds1305->work, ds1305_work); | 773 | INIT_WORK(&ds1305->work, ds1305_work); |
776 | status = request_irq(spi->irq, ds1305_irq, | 774 | status = request_irq(spi->irq, ds1305_irq, |
777 | 0, dev_name(&rtc->dev), ds1305); | 775 | 0, dev_name(&ds1305->rtc->dev), ds1305); |
778 | if (status < 0) { | 776 | if (status < 0) { |
779 | dev_dbg(&spi->dev, "request_irq %d --> %d\n", | 777 | dev_dbg(&spi->dev, "request_irq %d --> %d\n", |
780 | spi->irq, status); | 778 | spi->irq, status); |
@@ -794,7 +792,7 @@ static int __devinit ds1305_probe(struct spi_device *spi) | |||
794 | fail2: | 792 | fail2: |
795 | free_irq(spi->irq, ds1305); | 793 | free_irq(spi->irq, ds1305); |
796 | fail1: | 794 | fail1: |
797 | rtc_device_unregister(rtc); | 795 | rtc_device_unregister(ds1305->rtc); |
798 | fail0: | 796 | fail0: |
799 | kfree(ds1305); | 797 | kfree(ds1305); |
800 | return status; | 798 | return status; |
@@ -802,7 +800,7 @@ fail0: | |||
802 | 800 | ||
803 | static int __devexit ds1305_remove(struct spi_device *spi) | 801 | static int __devexit ds1305_remove(struct spi_device *spi) |
804 | { | 802 | { |
805 | struct ds1305 *ds1305 = spi_get_drvdata(spi); | 803 | struct ds1305 *ds1305 = spi_get_drvdata(spi); |
806 | 804 | ||
807 | sysfs_remove_bin_file(&spi->dev.kobj, &nvram); | 805 | sysfs_remove_bin_file(&spi->dev.kobj, &nvram); |
808 | 806 | ||