Patchwork Separate Alarm from IRQ.

login
register
mail settings
Submitter Sachin Sanap
Date Dec. 22, 2010, 12:30 p.m.
Message ID <1293021012.2457.7.camel@pe-lt522.marvell.com>
Download mbox | patch
Permalink /patch/76397/
State New
Headers show

Comments

Sachin Sanap - Dec. 22, 2010, 12:30 p.m.
Some RTC chips that support Alarm might not always be connected
to IRQ. The alarm interrupt of RTC might be connected to the
WAKEUP pin of the CPU, which gets CPU out of suspend to RAM
state.

Signed-off-by: Sachin Sanap <ssanap@marvell.com>
---
 drivers/rtc/rtc-ds1307.c |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)

Patch

diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
index d827ce5..4b79bdb 100644
--- a/drivers/rtc/rtc-ds1307.c
+++ b/drivers/rtc/rtc-ds1307.c
@@ -102,7 +102,8 @@  struct ds1307 {
 	enum ds_type		type;
 	unsigned long		flags;
 #define HAS_NVRAM	0		/* bit 0 == sysfs file active */
-#define HAS_ALARM	1		/* bit 1 == irq claimed */
+#define HAS_ALARM	1		/* bit 1 == has alarm */
+#define HAS_IRQ		2		/* bit 2 == irq claimed */
 	struct i2c_client	*client;
 	struct rtc_device	*rtc;
 	struct work_struct	work;
@@ -271,7 +272,7 @@  static void ds1307_work(struct work_struct *work)
 	}
 
 out:
-	if (test_bit(HAS_ALARM, &ds1307->flags))
+	if (test_bit(HAS_IRQ, &ds1307->flags))
 		enable_irq(client->irq);
 	mutex_unlock(lock);
 }
@@ -885,10 +886,14 @@  read_rtc:
 		}
 
 		device_set_wakeup_capable(&client->dev, 1);
-		set_bit(HAS_ALARM, &ds1307->flags);
+		set_bit(HAS_IRQ, &ds1307->flags);
 		dev_dbg(&client->dev, "got IRQ %d\n", client->irq);
 	}
 
+	/* has Alarm? */
+	if (chip->alarm)
+		set_bit(HAS_ALARM, &ds1307->flags);
+
 	if (chip->nvram56) {
 		err = sysfs_create_bin_file(&client->dev.kobj, &nvram);
 		if (err == 0) {
@@ -910,7 +915,7 @@  static int __devexit ds1307_remove(struct i2c_client *client)
 {
 	struct ds1307		*ds1307 = i2c_get_clientdata(client);
 
-	if (test_and_clear_bit(HAS_ALARM, &ds1307->flags)) {
+	if (test_and_clear_bit(HAS_IRQ, &ds1307->flags)) {
 		free_irq(client->irq, client);
 		cancel_work_sync(&ds1307->work);
 	}