From patchwork Wed Dec 22 12:30:12 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: Separate Alarm from IRQ. From: Sachin Sanap X-Patchwork-Id: 76397 Message-Id: <1293021012.2457.7.camel@pe-lt522.marvell.com> To: Cc: , , , Date: Wed, 22 Dec 2010 18:00:12 +0530 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 --- drivers/rtc/rtc-ds1307.c | 13 +++++++++---- 1 files changed, 9 insertions(+), 4 deletions(-) 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); }