aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/rtc/rtc-ds1307.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/rtc/rtc-ds1307.c')
-rw-r--r--drivers/rtc/rtc-ds1307.c44
1 files changed, 8 insertions, 36 deletions
diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
index 188006c55ce0..aa705bb4748c 100644
--- a/drivers/rtc/rtc-ds1307.c
+++ b/drivers/rtc/rtc-ds1307.c
@@ -15,9 +15,6 @@
15#include <linux/i2c.h> 15#include <linux/i2c.h>
16#include <linux/init.h> 16#include <linux/init.h>
17#include <linux/module.h> 17#include <linux/module.h>
18#include <linux/of_device.h>
19#include <linux/of_irq.h>
20#include <linux/pm_wakeirq.h>
21#include <linux/rtc/ds1307.h> 18#include <linux/rtc/ds1307.h>
22#include <linux/rtc.h> 19#include <linux/rtc.h>
23#include <linux/slab.h> 20#include <linux/slab.h>
@@ -117,7 +114,6 @@ struct ds1307 {
117#define HAS_ALARM 1 /* bit 1 == irq claimed */ 114#define HAS_ALARM 1 /* bit 1 == irq claimed */
118 struct i2c_client *client; 115 struct i2c_client *client;
119 struct rtc_device *rtc; 116 struct rtc_device *rtc;
120 int wakeirq;
121 s32 (*read_block_data)(const struct i2c_client *client, u8 command, 117 s32 (*read_block_data)(const struct i2c_client *client, u8 command,
122 u8 length, u8 *values); 118 u8 length, u8 *values);
123 s32 (*write_block_data)(const struct i2c_client *client, u8 command, 119 s32 (*write_block_data)(const struct i2c_client *client, u8 command,
@@ -1138,7 +1134,10 @@ read_rtc:
1138 bin2bcd(tmp)); 1134 bin2bcd(tmp));
1139 } 1135 }
1140 1136
1141 device_set_wakeup_capable(&client->dev, want_irq); 1137 if (want_irq) {
1138 device_set_wakeup_capable(&client->dev, true);
1139 set_bit(HAS_ALARM, &ds1307->flags);
1140 }
1142 ds1307->rtc = devm_rtc_device_register(&client->dev, client->name, 1141 ds1307->rtc = devm_rtc_device_register(&client->dev, client->name,
1143 rtc_ops, THIS_MODULE); 1142 rtc_ops, THIS_MODULE);
1144 if (IS_ERR(ds1307->rtc)) { 1143 if (IS_ERR(ds1307->rtc)) {
@@ -1146,43 +1145,19 @@ read_rtc:
1146 } 1145 }
1147 1146
1148 if (want_irq) { 1147 if (want_irq) {
1149 struct device_node *node = client->dev.of_node;
1150
1151 err = devm_request_threaded_irq(&client->dev, 1148 err = devm_request_threaded_irq(&client->dev,
1152 client->irq, NULL, irq_handler, 1149 client->irq, NULL, irq_handler,
1153 IRQF_SHARED | IRQF_ONESHOT, 1150 IRQF_SHARED | IRQF_ONESHOT,
1154 ds1307->rtc->name, client); 1151 ds1307->rtc->name, client);
1155 if (err) { 1152 if (err) {
1156 client->irq = 0; 1153 client->irq = 0;
1154 device_set_wakeup_capable(&client->dev, false);
1155 clear_bit(HAS_ALARM, &ds1307->flags);
1157 dev_err(&client->dev, "unable to request IRQ!\n"); 1156 dev_err(&client->dev, "unable to request IRQ!\n");
1158 goto no_irq; 1157 } else
1159 } 1158 dev_dbg(&client->dev, "got IRQ %d\n", client->irq);
1160
1161 set_bit(HAS_ALARM, &ds1307->flags);
1162 dev_dbg(&client->dev, "got IRQ %d\n", client->irq);
1163
1164 /* Currently supported by OF code only! */
1165 if (!node)
1166 goto no_irq;
1167
1168 err = of_irq_get(node, 1);
1169 if (err <= 0) {
1170 if (err == -EPROBE_DEFER)
1171 goto exit;
1172 goto no_irq;
1173 }
1174 ds1307->wakeirq = err;
1175
1176 err = dev_pm_set_dedicated_wake_irq(&client->dev,
1177 ds1307->wakeirq);
1178 if (err) {
1179 dev_err(&client->dev, "unable to setup wakeIRQ %d!\n",
1180 err);
1181 goto exit;
1182 }
1183 } 1159 }
1184 1160
1185no_irq:
1186 if (chip->nvram_size) { 1161 if (chip->nvram_size) {
1187 1162
1188 ds1307->nvram = devm_kzalloc(&client->dev, 1163 ds1307->nvram = devm_kzalloc(&client->dev,
@@ -1226,9 +1201,6 @@ static int ds1307_remove(struct i2c_client *client)
1226{ 1201{
1227 struct ds1307 *ds1307 = i2c_get_clientdata(client); 1202 struct ds1307 *ds1307 = i2c_get_clientdata(client);
1228 1203
1229 if (ds1307->wakeirq)
1230 dev_pm_clear_wake_irq(&client->dev);
1231
1232 if (test_and_clear_bit(HAS_NVRAM, &ds1307->flags)) 1204 if (test_and_clear_bit(HAS_NVRAM, &ds1307->flags))
1233 sysfs_remove_bin_file(&client->dev.kobj, ds1307->nvram); 1205 sysfs_remove_bin_file(&client->dev.kobj, ds1307->nvram);
1234 1206