|
15 | 15 | #include <linux/i2c.h>
|
16 | 16 | #include <linux/init.h>
|
17 | 17 | #include <linux/module.h>
|
18 |
| -#include <linux/of_device.h> |
19 |
| -#include <linux/of_irq.h> |
20 |
| -#include <linux/pm_wakeirq.h> |
21 | 18 | #include <linux/rtc/ds1307.h>
|
22 | 19 | #include <linux/rtc.h>
|
23 | 20 | #include <linux/slab.h>
|
@@ -117,7 +114,6 @@ struct ds1307 {
|
117 | 114 | #define HAS_ALARM 1 /* bit 1 == irq claimed */
|
118 | 115 | struct i2c_client *client;
|
119 | 116 | struct rtc_device *rtc;
|
120 |
| - int wakeirq; |
121 | 117 | s32 (*read_block_data)(const struct i2c_client *client, u8 command,
|
122 | 118 | u8 length, u8 *values);
|
123 | 119 | s32 (*write_block_data)(const struct i2c_client *client, u8 command,
|
@@ -1138,51 +1134,30 @@ static int ds1307_probe(struct i2c_client *client,
|
1138 | 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 | 1141 | ds1307->rtc = devm_rtc_device_register(&client->dev, client->name,
|
1143 | 1142 | rtc_ops, THIS_MODULE);
|
1144 | 1143 | if (IS_ERR(ds1307->rtc)) {
|
1145 | 1144 | return PTR_ERR(ds1307->rtc);
|
1146 | 1145 | }
|
1147 | 1146 |
|
1148 | 1147 | if (want_irq) {
|
1149 |
| - struct device_node *node = client->dev.of_node; |
1150 |
| - |
1151 | 1148 | err = devm_request_threaded_irq(&client->dev,
|
1152 | 1149 | client->irq, NULL, irq_handler,
|
1153 | 1150 | IRQF_SHARED | IRQF_ONESHOT,
|
1154 | 1151 | ds1307->rtc->name, client);
|
1155 | 1152 | if (err) {
|
1156 | 1153 | client->irq = 0;
|
| 1154 | + device_set_wakeup_capable(&client->dev, false); |
| 1155 | + clear_bit(HAS_ALARM, &ds1307->flags); |
1157 | 1156 | dev_err(&client->dev, "unable to request IRQ!\n");
|
1158 |
| - goto no_irq; |
1159 |
| - } |
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 |
| - } |
| 1157 | + } else |
| 1158 | + dev_dbg(&client->dev, "got IRQ %d\n", client->irq); |
1183 | 1159 | }
|
1184 | 1160 |
|
1185 |
| -no_irq: |
1186 | 1161 | if (chip->nvram_size) {
|
1187 | 1162 |
|
1188 | 1163 | ds1307->nvram = devm_kzalloc(&client->dev,
|
@@ -1226,9 +1201,6 @@ static int ds1307_remove(struct i2c_client *client)
|
1226 | 1201 | {
|
1227 | 1202 | struct ds1307 *ds1307 = i2c_get_clientdata(client);
|
1228 | 1203 |
|
1229 |
| - if (ds1307->wakeirq) |
1230 |
| - dev_pm_clear_wake_irq(&client->dev); |
1231 |
| - |
1232 | 1204 | if (test_and_clear_bit(HAS_NVRAM, &ds1307->flags))
|
1233 | 1205 | sysfs_remove_bin_file(&client->dev.kobj, ds1307->nvram);
|
1234 | 1206 |
|
|
0 commit comments