Commit 3abb1ada authored by Simon Guinot's avatar Simon Guinot Committed by Alexandre Belloni

rtc: ds1307: fix alarm reading at probe time

With the actual code, read_alarm() always returns -EINVAL when called
during the RTC device registration. This prevents from retrieving an
already configured alarm in hardware.

This patch fixes the issue by moving the HAS_ALARM bit configuration
(if supported by the hardware) above the rtc_device_register() call.
Signed-off-by: default avatarSimon Guinot <simon.guinot@sequanux.org>
Signed-off-by: default avatarAlexandre Belloni <alexandre.belloni@free-electrons.com>
parent 51c4cfef
...@@ -1134,7 +1134,10 @@ static int ds1307_probe(struct i2c_client *client, ...@@ -1134,7 +1134,10 @@ static int ds1307_probe(struct i2c_client *client,
bin2bcd(tmp)); bin2bcd(tmp));
} }
device_set_wakeup_capable(&client->dev, want_irq); if (want_irq) {
device_set_wakeup_capable(&client->dev, true);
set_bit(HAS_ALARM, &ds1307->flags);
}
ds1307->rtc = devm_rtc_device_register(&client->dev, client->name, ds1307->rtc = devm_rtc_device_register(&client->dev, client->name,
rtc_ops, THIS_MODULE); rtc_ops, THIS_MODULE);
if (IS_ERR(ds1307->rtc)) { if (IS_ERR(ds1307->rtc)) {
...@@ -1148,13 +1151,12 @@ static int ds1307_probe(struct i2c_client *client, ...@@ -1148,13 +1151,12 @@ static int ds1307_probe(struct i2c_client *client,
ds1307->rtc->name, client); ds1307->rtc->name, client);
if (err) { if (err) {
client->irq = 0; client->irq = 0;
device_set_wakeup_capable(&client->dev, false);
clear_bit(HAS_ALARM, &ds1307->flags);
dev_err(&client->dev, "unable to request IRQ!\n"); dev_err(&client->dev, "unable to request IRQ!\n");
} else { } else
set_bit(HAS_ALARM, &ds1307->flags);
dev_dbg(&client->dev, "got IRQ %d\n", client->irq); dev_dbg(&client->dev, "got IRQ %d\n", client->irq);
} }
}
if (chip->nvram_size) { if (chip->nvram_size) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment