From: Jan Weitzel <j.weitzel@phytec.de>
To: linux-kernel@vger.kernel.org
Cc: zbr@ioremap.net, Jan Weitzel <j.weitzel@phytec.de>
Subject: [RFC] w1: Disable irqs in critical section
Date: Wed, 7 Sep 2011 10:48:32 +0200 [thread overview]
Message-ID: <1315385312-1176-1-git-send-email-j.weitzel@phytec.de> (raw)
Interrupting w1_delay in w1_read_bit results in missing the low level
on the w1 line and receiving "1" instead of "0".
Adding local_irq_save / local_irq_restore around the critical section
Signed-off-by: Jan Weitzel <j.weitzel@phytec.de>
---
drivers/w1/w1_io.c | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/drivers/w1/w1_io.c b/drivers/w1/w1_io.c
index 8e8b64c..a059eaa 100644
--- a/drivers/w1/w1_io.c
+++ b/drivers/w1/w1_io.c
@@ -158,13 +158,18 @@ EXPORT_SYMBOL_GPL(w1_write_8);
static u8 w1_read_bit(struct w1_master *dev)
{
int result;
+ unsigned long flags;
+ /* sample timing is critical here */
+ local_irq_save(flags);
dev->bus_master->write_bit(dev->bus_master->data, 0);
w1_delay(6);
dev->bus_master->write_bit(dev->bus_master->data, 1);
w1_delay(9);
result = dev->bus_master->read_bit(dev->bus_master->data);
+ local_irq_restore(flags);
+
w1_delay(55);
return result & 0x1;
--
1.7.0.4
next reply other threads:[~2011-09-07 17:43 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-07 8:48 Jan Weitzel [this message]
2011-09-07 17:50 ` Evgeniy Polyakov
2011-09-08 5:46 ` Jan Weitzel
2011-09-13 22:41 ` Andrew Morton
2011-09-14 12:23 ` Jan Weitzel
2011-09-14 19:45 ` Evgeniy Polyakov
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=1315385312-1176-1-git-send-email-j.weitzel@phytec.de \
--to=j.weitzel@phytec.de \
--cc=linux-kernel@vger.kernel.org \
--cc=zbr@ioremap.net \
/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
all inboxes | Powered by JetHome®