aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/w1
diff options
context:
space:
mode:
authorJan Weitzel <j.weitzel@phytec.de>2011-11-02 16:40:02 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2011-11-02 19:07:03 -0400
commit3fd306c85adcde7209281cb663dd8ea247e97cc3 (patch)
tree67bd829e0ef4e8e350af7fd06e4936bec616b49a /drivers/w1
parent68a436aec345c2bcd05dbdafae1f5f608ff8f61f (diff)
w1: disable irqs in critical section
Interrupting w1_delay() in w1_read_bit() results in missing the low level on the w1 line and receiving "1" instead of "0". Add local_irq_save()/local_irq_restore() around the critical section Signed-off-by: Jan Weitzel <j.weitzel@phytec.de> Acked-by: Evgeniy Polyakov <zbr@ioremap.net> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/w1')
-rw-r--r--drivers/w1/w1_io.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/w1/w1_io.c b/drivers/w1/w1_io.c
index 765b37b62a4f..3135b2c63998 100644
--- a/drivers/w1/w1_io.c
+++ b/drivers/w1/w1_io.c
@@ -158,13 +158,18 @@ EXPORT_SYMBOL_GPL(w1_write_8);
158static u8 w1_read_bit(struct w1_master *dev) 158static u8 w1_read_bit(struct w1_master *dev)
159{ 159{
160 int result; 160 int result;
161 unsigned long flags;
161 162
163 /* sample timing is critical here */
164 local_irq_save(flags);
162 dev->bus_master->write_bit(dev->bus_master->data, 0); 165 dev->bus_master->write_bit(dev->bus_master->data, 0);
163 w1_delay(6); 166 w1_delay(6);
164 dev->bus_master->write_bit(dev->bus_master->data, 1); 167 dev->bus_master->write_bit(dev->bus_master->data, 1);
165 w1_delay(9); 168 w1_delay(9);
166 169
167 result = dev->bus_master->read_bit(dev->bus_master->data); 170 result = dev->bus_master->read_bit(dev->bus_master->data);
171 local_irq_restore(flags);
172
168 w1_delay(55); 173 w1_delay(55);
169 174
170 return result & 0x1; 175 return result & 0x1;