Skip to content

Commit 818aba3

Browse files
committed
Merge tag 'rtc-4.4-2' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux
Pull RTC fixes from Alexandre Belloni: "Two fixes for the ds1307 alarm and wakeup" * tag 'rtc-4.4-2' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux: rtc: ds1307: fix alarm reading at probe time rtc: ds1307: fix kernel splat due to wakeup irq handling
2 parents 00fd6a7 + 3abb1ad commit 818aba3

File tree

2 files changed

+9
-36
lines changed

2 files changed

+9
-36
lines changed

arch/arm/boot/dts/am57xx-beagle-x15.dts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,7 @@
604604
reg = <0x6f>;
605605
interrupts-extended = <&crossbar_mpu GIC_SPI 2 IRQ_TYPE_EDGE_RISING>,
606606
<&dra7_pmx_core 0x424>;
607+
interrupt-names = "irq", "wakeup";
607608

608609
pinctrl-names = "default";
609610
pinctrl-0 = <&mcp79410_pins_default>;

drivers/rtc/rtc-ds1307.c

Lines changed: 8 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@
1515
#include <linux/i2c.h>
1616
#include <linux/init.h>
1717
#include <linux/module.h>
18-
#include <linux/of_device.h>
19-
#include <linux/of_irq.h>
20-
#include <linux/pm_wakeirq.h>
2118
#include <linux/rtc/ds1307.h>
2219
#include <linux/rtc.h>
2320
#include <linux/slab.h>
@@ -117,7 +114,6 @@ struct ds1307 {
117114
#define HAS_ALARM 1 /* bit 1 == irq claimed */
118115
struct i2c_client *client;
119116
struct rtc_device *rtc;
120-
int wakeirq;
121117
s32 (*read_block_data)(const struct i2c_client *client, u8 command,
122118
u8 length, u8 *values);
123119
s32 (*write_block_data)(const struct i2c_client *client, u8 command,
@@ -1138,51 +1134,30 @@ static int ds1307_probe(struct i2c_client *client,
11381134
bin2bcd(tmp));
11391135
}
11401136

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+
}
11421141
ds1307->rtc = devm_rtc_device_register(&client->dev, client->name,
11431142
rtc_ops, THIS_MODULE);
11441143
if (IS_ERR(ds1307->rtc)) {
11451144
return PTR_ERR(ds1307->rtc);
11461145
}
11471146

11481147
if (want_irq) {
1149-
struct device_node *node = client->dev.of_node;
1150-
11511148
err = devm_request_threaded_irq(&client->dev,
11521149
client->irq, NULL, irq_handler,
11531150
IRQF_SHARED | IRQF_ONESHOT,
11541151
ds1307->rtc->name, client);
11551152
if (err) {
11561153
client->irq = 0;
1154+
device_set_wakeup_capable(&client->dev, false);
1155+
clear_bit(HAS_ALARM, &ds1307->flags);
11571156
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);
11831159
}
11841160

1185-
no_irq:
11861161
if (chip->nvram_size) {
11871162

11881163
ds1307->nvram = devm_kzalloc(&client->dev,
@@ -1226,9 +1201,6 @@ static int ds1307_remove(struct i2c_client *client)
12261201
{
12271202
struct ds1307 *ds1307 = i2c_get_clientdata(client);
12281203

1229-
if (ds1307->wakeirq)
1230-
dev_pm_clear_wake_irq(&client->dev);
1231-
12321204
if (test_and_clear_bit(HAS_NVRAM, &ds1307->flags))
12331205
sysfs_remove_bin_file(&client->dev.kobj, ds1307->nvram);
12341206

0 commit comments

Comments
 (0)