diff options
Diffstat (limited to 'drivers/rtc/rtc-ds1307.c')
-rw-r--r-- | drivers/rtc/rtc-ds1307.c | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c index 47a93c022d91..0d559b6416dd 100644 --- a/drivers/rtc/rtc-ds1307.c +++ b/drivers/rtc/rtc-ds1307.c | |||
@@ -106,9 +106,9 @@ struct ds1307 { | |||
106 | struct i2c_client *client; | 106 | struct i2c_client *client; |
107 | struct rtc_device *rtc; | 107 | struct rtc_device *rtc; |
108 | struct work_struct work; | 108 | struct work_struct work; |
109 | s32 (*read_block_data)(struct i2c_client *client, u8 command, | 109 | s32 (*read_block_data)(const struct i2c_client *client, u8 command, |
110 | u8 length, u8 *values); | 110 | u8 length, u8 *values); |
111 | s32 (*write_block_data)(struct i2c_client *client, u8 command, | 111 | s32 (*write_block_data)(const struct i2c_client *client, u8 command, |
112 | u8 length, const u8 *values); | 112 | u8 length, const u8 *values); |
113 | }; | 113 | }; |
114 | 114 | ||
@@ -158,8 +158,8 @@ MODULE_DEVICE_TABLE(i2c, ds1307_id); | |||
158 | 158 | ||
159 | #define BLOCK_DATA_MAX_TRIES 10 | 159 | #define BLOCK_DATA_MAX_TRIES 10 |
160 | 160 | ||
161 | static s32 ds1307_read_block_data_once(struct i2c_client *client, u8 command, | 161 | static s32 ds1307_read_block_data_once(const struct i2c_client *client, |
162 | u8 length, u8 *values) | 162 | u8 command, u8 length, u8 *values) |
163 | { | 163 | { |
164 | s32 i, data; | 164 | s32 i, data; |
165 | 165 | ||
@@ -172,7 +172,7 @@ static s32 ds1307_read_block_data_once(struct i2c_client *client, u8 command, | |||
172 | return i; | 172 | return i; |
173 | } | 173 | } |
174 | 174 | ||
175 | static s32 ds1307_read_block_data(struct i2c_client *client, u8 command, | 175 | static s32 ds1307_read_block_data(const struct i2c_client *client, u8 command, |
176 | u8 length, u8 *values) | 176 | u8 length, u8 *values) |
177 | { | 177 | { |
178 | u8 oldvalues[I2C_SMBUS_BLOCK_MAX]; | 178 | u8 oldvalues[I2C_SMBUS_BLOCK_MAX]; |
@@ -198,7 +198,7 @@ static s32 ds1307_read_block_data(struct i2c_client *client, u8 command, | |||
198 | return length; | 198 | return length; |
199 | } | 199 | } |
200 | 200 | ||
201 | static s32 ds1307_write_block_data(struct i2c_client *client, u8 command, | 201 | static s32 ds1307_write_block_data(const struct i2c_client *client, u8 command, |
202 | u8 length, const u8 *values) | 202 | u8 length, const u8 *values) |
203 | { | 203 | { |
204 | u8 currvalues[I2C_SMBUS_BLOCK_MAX]; | 204 | u8 currvalues[I2C_SMBUS_BLOCK_MAX]; |
@@ -556,7 +556,8 @@ static const struct rtc_class_ops ds13xx_rtc_ops = { | |||
556 | #define NVRAM_SIZE 56 | 556 | #define NVRAM_SIZE 56 |
557 | 557 | ||
558 | static ssize_t | 558 | static ssize_t |
559 | ds1307_nvram_read(struct kobject *kobj, struct bin_attribute *attr, | 559 | ds1307_nvram_read(struct file *filp, struct kobject *kobj, |
560 | struct bin_attribute *attr, | ||
560 | char *buf, loff_t off, size_t count) | 561 | char *buf, loff_t off, size_t count) |
561 | { | 562 | { |
562 | struct i2c_client *client; | 563 | struct i2c_client *client; |
@@ -580,7 +581,8 @@ ds1307_nvram_read(struct kobject *kobj, struct bin_attribute *attr, | |||
580 | } | 581 | } |
581 | 582 | ||
582 | static ssize_t | 583 | static ssize_t |
583 | ds1307_nvram_write(struct kobject *kobj, struct bin_attribute *attr, | 584 | ds1307_nvram_write(struct file *filp, struct kobject *kobj, |
585 | struct bin_attribute *attr, | ||
584 | char *buf, loff_t off, size_t count) | 586 | char *buf, loff_t off, size_t count) |
585 | { | 587 | { |
586 | struct i2c_client *client; | 588 | struct i2c_client *client; |
@@ -775,7 +777,7 @@ static int __devinit ds1307_probe(struct i2c_client *client, | |||
775 | 777 | ||
776 | read_rtc: | 778 | read_rtc: |
777 | /* read RTC registers */ | 779 | /* read RTC registers */ |
778 | tmp = ds1307->read_block_data(ds1307->client, 0, 8, buf); | 780 | tmp = ds1307->read_block_data(ds1307->client, ds1307->offset, 8, buf); |
779 | if (tmp != 8) { | 781 | if (tmp != 8) { |
780 | pr_debug("read error %d\n", tmp); | 782 | pr_debug("read error %d\n", tmp); |
781 | err = -EIO; | 783 | err = -EIO; |
@@ -860,7 +862,7 @@ read_rtc: | |||
860 | if (ds1307->regs[DS1307_REG_HOUR] & DS1307_BIT_PM) | 862 | if (ds1307->regs[DS1307_REG_HOUR] & DS1307_BIT_PM) |
861 | tmp += 12; | 863 | tmp += 12; |
862 | i2c_smbus_write_byte_data(client, | 864 | i2c_smbus_write_byte_data(client, |
863 | DS1307_REG_HOUR, | 865 | ds1307->offset + DS1307_REG_HOUR, |
864 | bin2bcd(tmp)); | 866 | bin2bcd(tmp)); |
865 | } | 867 | } |
866 | 868 | ||
@@ -874,13 +876,15 @@ read_rtc: | |||
874 | } | 876 | } |
875 | 877 | ||
876 | if (want_irq) { | 878 | if (want_irq) { |
877 | err = request_irq(client->irq, ds1307_irq, 0, | 879 | err = request_irq(client->irq, ds1307_irq, IRQF_SHARED, |
878 | ds1307->rtc->name, client); | 880 | ds1307->rtc->name, client); |
879 | if (err) { | 881 | if (err) { |
880 | dev_err(&client->dev, | 882 | dev_err(&client->dev, |
881 | "unable to request IRQ!\n"); | 883 | "unable to request IRQ!\n"); |
882 | goto exit_irq; | 884 | goto exit_irq; |
883 | } | 885 | } |
886 | |||
887 | device_set_wakeup_capable(&client->dev, 1); | ||
884 | set_bit(HAS_ALARM, &ds1307->flags); | 888 | set_bit(HAS_ALARM, &ds1307->flags); |
885 | dev_dbg(&client->dev, "got IRQ %d\n", client->irq); | 889 | dev_dbg(&client->dev, "got IRQ %d\n", client->irq); |
886 | } | 890 | } |
@@ -896,8 +900,7 @@ read_rtc: | |||
896 | return 0; | 900 | return 0; |
897 | 901 | ||
898 | exit_irq: | 902 | exit_irq: |
899 | if (ds1307->rtc) | 903 | rtc_device_unregister(ds1307->rtc); |
900 | rtc_device_unregister(ds1307->rtc); | ||
901 | exit_free: | 904 | exit_free: |
902 | kfree(ds1307); | 905 | kfree(ds1307); |
903 | return err; | 906 | return err; |