From: Nicolas Boullis <nboullis@debian.org>
To: Alessandro Zummo <a.zummo@towertech.it>,
Alexandre Belloni <alexandre.belloni@free-electrons.com>,
rtc-linux@googlegroups.com
Subject: [rtc-linux] [PATCH 2/2] rtc: ds1307: clear the interrupts on probe
Date: Sun, 3 Apr 2016 00:10:47 +0200 [thread overview]
Message-ID: <20160402221047.GB3600@haddock.home> (raw)
When the alarm is used to switch the computer on, the interrupts are
disabled, but the interrupt flags are not cleared.
When the alarm is set, later, the interrupt is enabled and the interrupt
flags are cleared. Unfortunately, at least with my DS1339 chip, it
behaves as if the interrupt was enabled before the flag was cleared, so
the interrupt is triggered.
With this patch, the interrupt flags are cleared when the chip is
probed, so an interrupt is not triggered when the alarm is set.
Signed-off-by: Nicolas Boullis <nboullis@debian.org>
---
Not sure if I should check for errors with (tmp != 2) to be consistent
with the check after reading the same block, a few lines above, or with
(tmp < 0)...
diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
index b2156ee..19e7353 100644
--- a/drivers/rtc/rtc-ds1307.c
+++ b/drivers/rtc/rtc-ds1307.c
@@ -1320,19 +1324,24 @@ static int ds1307_probe(struct i2c_client *client,
ds1307->regs[0] |= DS1337_BIT_INTCN
| bbsqi_bitpos[ds1307->type];
ds1307->regs[0] &= ~(DS1337_BIT_A2IE | DS1337_BIT_A1IE);
+ ds1307->regs[1] &= ~(DS1337_BIT_A2I | DS1337_BIT_A1I);
want_irq = true;
}
- i2c_smbus_write_byte_data(client, DS1337_REG_CONTROL,
- ds1307->regs[0]);
-
/* oscillator fault? clear flag, and warn */
if (ds1307->regs[1] & DS1337_BIT_OSF) {
- i2c_smbus_write_byte_data(client, DS1337_REG_STATUS,
- ds1307->regs[1] & ~DS1337_BIT_OSF);
dev_warn(&client->dev, "SET TIME!\n");
}
+
+ tmp = ds1307->write_block_data(ds1307->client,
+ DS1337_REG_CONTROL, 2, buf);
+ if (tmp != 2) {
+ dev_dbg(&client->dev, "write error %d\n", tmp);
+ err = -EIO;
+ goto exit;
+ }
+
break;
case rx_8025:
--
--
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
---
You received this message because you are subscribed to the Google Groups "rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rtc-linux+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
next reply other threads:[~2016-04-02 22:10 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-02 22:10 Nicolas Boullis [this message]
2016-04-10 11:23 ` [rtc-linux] [PATCH] rtc: ds1307: ensure that any pending alarm is cleared before a new alarm is enabled Nicolas Boullis
2016-04-18 22:28 ` [rtc-linux] " Alexandre Belloni
2016-04-21 21:19 ` Nicolas Boullis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160402221047.GB3600@haddock.home \
--to=nboullis@debian.org \
--cc=a.zummo@towertech.it \
--cc=alexandre.belloni@free-electrons.com \
--cc=rtc-linux@googlegroups.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox