Commit 818aba30 authored by Linus Torvalds's avatar Linus Torvalds

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
parents 00fd6a71 3abb1ada
...@@ -604,6 +604,7 @@ mcp_rtc: rtc@6f { ...@@ -604,6 +604,7 @@ mcp_rtc: rtc@6f {
reg = <0x6f>; reg = <0x6f>;
interrupts-extended = <&crossbar_mpu GIC_SPI 2 IRQ_TYPE_EDGE_RISING>, interrupts-extended = <&crossbar_mpu GIC_SPI 2 IRQ_TYPE_EDGE_RISING>,
<&dra7_pmx_core 0x424>; <&dra7_pmx_core 0x424>;
interrupt-names = "irq", "wakeup";
pinctrl-names = "default"; pinctrl-names = "default";
pinctrl-0 = <&mcp79410_pins_default>; pinctrl-0 = <&mcp79410_pins_default>;
......
...@@ -15,9 +15,6 @@ ...@@ -15,9 +15,6 @@
#include <linux/i2c.h> #include <linux/i2c.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/of_device.h>
#include <linux/of_irq.h>
#include <linux/pm_wakeirq.h>
#include <linux/rtc/ds1307.h> #include <linux/rtc/ds1307.h>
#include <linux/rtc.h> #include <linux/rtc.h>
#include <linux/slab.h> #include <linux/slab.h>
...@@ -117,7 +114,6 @@ struct ds1307 { ...@@ -117,7 +114,6 @@ struct ds1307 {
#define HAS_ALARM 1 /* bit 1 == irq claimed */ #define HAS_ALARM 1 /* bit 1 == irq claimed */
struct i2c_client *client; struct i2c_client *client;
struct rtc_device *rtc; struct rtc_device *rtc;
int wakeirq;
s32 (*read_block_data)(const struct i2c_client *client, u8 command, s32 (*read_block_data)(const struct i2c_client *client, u8 command,
u8 length, u8 *values); u8 length, u8 *values);
s32 (*write_block_data)(const struct i2c_client *client, u8 command, s32 (*write_block_data)(const struct i2c_client *client, u8 command,
...@@ -1138,7 +1134,10 @@ static int ds1307_probe(struct i2c_client *client, ...@@ -1138,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)) {
...@@ -1146,43 +1145,19 @@ static int ds1307_probe(struct i2c_client *client, ...@@ -1146,43 +1145,19 @@ static int ds1307_probe(struct i2c_client *client,
} }
if (want_irq) { if (want_irq) {
struct device_node *node = client->dev.of_node;
err = devm_request_threaded_irq(&client->dev, err = devm_request_threaded_irq(&client->dev,
client->irq, NULL, irq_handler, client->irq, NULL, irq_handler,
IRQF_SHARED | IRQF_ONESHOT, IRQF_SHARED | IRQF_ONESHOT,
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");
goto no_irq; } 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);
/* Currently supported by OF code only! */
if (!node)
goto no_irq;
err = of_irq_get(node, 1);
if (err <= 0) {
if (err == -EPROBE_DEFER)
goto exit;
goto no_irq;
}
ds1307->wakeirq = err;
err = dev_pm_set_dedicated_wake_irq(&client->dev,
ds1307->wakeirq);
if (err) {
dev_err(&client->dev, "unable to setup wakeIRQ %d!\n",
err);
goto exit;
}
} }
no_irq:
if (chip->nvram_size) { if (chip->nvram_size) {
ds1307->nvram = devm_kzalloc(&client->dev, ds1307->nvram = devm_kzalloc(&client->dev,
...@@ -1226,9 +1201,6 @@ static int ds1307_remove(struct i2c_client *client) ...@@ -1226,9 +1201,6 @@ static int ds1307_remove(struct i2c_client *client)
{ {
struct ds1307 *ds1307 = i2c_get_clientdata(client); struct ds1307 *ds1307 = i2c_get_clientdata(client);
if (ds1307->wakeirq)
dev_pm_clear_wake_irq(&client->dev);
if (test_and_clear_bit(HAS_NVRAM, &ds1307->flags)) if (test_and_clear_bit(HAS_NVRAM, &ds1307->flags))
sysfs_remove_bin_file(&client->dev.kobj, ds1307->nvram); sysfs_remove_bin_file(&client->dev.kobj, ds1307->nvram);
......
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