diff options
Diffstat (limited to 'drivers/rtc/rtc-ds1305.c')
-rw-r--r-- | drivers/rtc/rtc-ds1305.c | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/drivers/rtc/rtc-ds1305.c b/drivers/rtc/rtc-ds1305.c index 8f410e59d9f5..077af1d7b9e4 100644 --- a/drivers/rtc/rtc-ds1305.c +++ b/drivers/rtc/rtc-ds1305.c | |||
@@ -11,6 +11,7 @@ | |||
11 | #include <linux/kernel.h> | 11 | #include <linux/kernel.h> |
12 | #include <linux/init.h> | 12 | #include <linux/init.h> |
13 | #include <linux/bcd.h> | 13 | #include <linux/bcd.h> |
14 | #include <linux/slab.h> | ||
14 | #include <linux/rtc.h> | 15 | #include <linux/rtc.h> |
15 | #include <linux/workqueue.h> | 16 | #include <linux/workqueue.h> |
16 | 17 | ||
@@ -541,7 +542,8 @@ static void msg_init(struct spi_message *m, struct spi_transfer *x, | |||
541 | } | 542 | } |
542 | 543 | ||
543 | static ssize_t | 544 | static ssize_t |
544 | ds1305_nvram_read(struct kobject *kobj, struct bin_attribute *attr, | 545 | ds1305_nvram_read(struct file *filp, struct kobject *kobj, |
546 | struct bin_attribute *attr, | ||
545 | char *buf, loff_t off, size_t count) | 547 | char *buf, loff_t off, size_t count) |
546 | { | 548 | { |
547 | struct spi_device *spi; | 549 | struct spi_device *spi; |
@@ -571,7 +573,8 @@ ds1305_nvram_read(struct kobject *kobj, struct bin_attribute *attr, | |||
571 | } | 573 | } |
572 | 574 | ||
573 | static ssize_t | 575 | static ssize_t |
574 | ds1305_nvram_write(struct kobject *kobj, struct bin_attribute *attr, | 576 | ds1305_nvram_write(struct file *filp, struct kobject *kobj, |
577 | struct bin_attribute *attr, | ||
575 | char *buf, loff_t off, size_t count) | 578 | char *buf, loff_t off, size_t count) |
576 | { | 579 | { |
577 | struct spi_device *spi; | 580 | struct spi_device *spi; |
@@ -617,7 +620,6 @@ static struct bin_attribute nvram = { | |||
617 | static int __devinit ds1305_probe(struct spi_device *spi) | 620 | static int __devinit ds1305_probe(struct spi_device *spi) |
618 | { | 621 | { |
619 | struct ds1305 *ds1305; | 622 | struct ds1305 *ds1305; |
620 | struct rtc_device *rtc; | ||
621 | int status; | 623 | int status; |
622 | u8 addr, value; | 624 | u8 addr, value; |
623 | struct ds1305_platform_data *pdata = spi->dev.platform_data; | 625 | struct ds1305_platform_data *pdata = spi->dev.platform_data; |
@@ -756,14 +758,13 @@ static int __devinit ds1305_probe(struct spi_device *spi) | |||
756 | dev_dbg(&spi->dev, "AM/PM\n"); | 758 | dev_dbg(&spi->dev, "AM/PM\n"); |
757 | 759 | ||
758 | /* register RTC ... from here on, ds1305->ctrl needs locking */ | 760 | /* register RTC ... from here on, ds1305->ctrl needs locking */ |
759 | rtc = rtc_device_register("ds1305", &spi->dev, | 761 | ds1305->rtc = rtc_device_register("ds1305", &spi->dev, |
760 | &ds1305_ops, THIS_MODULE); | 762 | &ds1305_ops, THIS_MODULE); |
761 | if (IS_ERR(rtc)) { | 763 | if (IS_ERR(ds1305->rtc)) { |
762 | status = PTR_ERR(rtc); | 764 | status = PTR_ERR(ds1305->rtc); |
763 | dev_dbg(&spi->dev, "register rtc --> %d\n", status); | 765 | dev_dbg(&spi->dev, "register rtc --> %d\n", status); |
764 | goto fail0; | 766 | goto fail0; |
765 | } | 767 | } |
766 | ds1305->rtc = rtc; | ||
767 | 768 | ||
768 | /* Maybe set up alarm IRQ; be ready to handle it triggering right | 769 | /* 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, | 770 | * away. NOTE that we don't share this. The signal is active low, |
@@ -774,12 +775,14 @@ static int __devinit ds1305_probe(struct spi_device *spi) | |||
774 | if (spi->irq) { | 775 | if (spi->irq) { |
775 | INIT_WORK(&ds1305->work, ds1305_work); | 776 | INIT_WORK(&ds1305->work, ds1305_work); |
776 | status = request_irq(spi->irq, ds1305_irq, | 777 | status = request_irq(spi->irq, ds1305_irq, |
777 | 0, dev_name(&rtc->dev), ds1305); | 778 | 0, dev_name(&ds1305->rtc->dev), ds1305); |
778 | if (status < 0) { | 779 | if (status < 0) { |
779 | dev_dbg(&spi->dev, "request_irq %d --> %d\n", | 780 | dev_dbg(&spi->dev, "request_irq %d --> %d\n", |
780 | spi->irq, status); | 781 | spi->irq, status); |
781 | goto fail1; | 782 | goto fail1; |
782 | } | 783 | } |
784 | |||
785 | device_set_wakeup_capable(&spi->dev, 1); | ||
783 | } | 786 | } |
784 | 787 | ||
785 | /* export NVRAM */ | 788 | /* export NVRAM */ |
@@ -794,7 +797,7 @@ static int __devinit ds1305_probe(struct spi_device *spi) | |||
794 | fail2: | 797 | fail2: |
795 | free_irq(spi->irq, ds1305); | 798 | free_irq(spi->irq, ds1305); |
796 | fail1: | 799 | fail1: |
797 | rtc_device_unregister(rtc); | 800 | rtc_device_unregister(ds1305->rtc); |
798 | fail0: | 801 | fail0: |
799 | kfree(ds1305); | 802 | kfree(ds1305); |
800 | return status; | 803 | return status; |
@@ -802,7 +805,7 @@ fail0: | |||
802 | 805 | ||
803 | static int __devexit ds1305_remove(struct spi_device *spi) | 806 | static int __devexit ds1305_remove(struct spi_device *spi) |
804 | { | 807 | { |
805 | struct ds1305 *ds1305 = spi_get_drvdata(spi); | 808 | struct ds1305 *ds1305 = spi_get_drvdata(spi); |
806 | 809 | ||
807 | sysfs_remove_bin_file(&spi->dev.kobj, &nvram); | 810 | sysfs_remove_bin_file(&spi->dev.kobj, &nvram); |
808 | 811 | ||
@@ -810,7 +813,7 @@ static int __devexit ds1305_remove(struct spi_device *spi) | |||
810 | if (spi->irq) { | 813 | if (spi->irq) { |
811 | set_bit(FLAG_EXITING, &ds1305->flags); | 814 | set_bit(FLAG_EXITING, &ds1305->flags); |
812 | free_irq(spi->irq, ds1305); | 815 | free_irq(spi->irq, ds1305); |
813 | flush_scheduled_work(); | 816 | cancel_work_sync(&ds1305->work); |
814 | } | 817 | } |
815 | 818 | ||
816 | rtc_device_unregister(ds1305->rtc); | 819 | rtc_device_unregister(ds1305->rtc); |
@@ -841,3 +844,4 @@ module_exit(ds1305_exit); | |||
841 | 844 | ||
842 | MODULE_DESCRIPTION("RTC driver for DS1305 and DS1306 chips"); | 845 | MODULE_DESCRIPTION("RTC driver for DS1305 and DS1306 chips"); |
843 | MODULE_LICENSE("GPL"); | 846 | MODULE_LICENSE("GPL"); |
847 | MODULE_ALIAS("spi:rtc-ds1305"); | ||