Commit 3fd306c8 authored by Jan Weitzel's avatar Jan Weitzel Committed by Linus Torvalds

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: default avatarJan Weitzel <j.weitzel@phytec.de>
Acked-by: default avatarEvgeniy Polyakov <zbr@ioremap.net>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 68a436ae
...@@ -158,13 +158,18 @@ EXPORT_SYMBOL_GPL(w1_write_8); ...@@ -158,13 +158,18 @@ EXPORT_SYMBOL_GPL(w1_write_8);
static u8 w1_read_bit(struct w1_master *dev) static u8 w1_read_bit(struct w1_master *dev)
{ {
int result; int result;
unsigned long flags;
/* sample timing is critical here */
local_irq_save(flags);
dev->bus_master->write_bit(dev->bus_master->data, 0); dev->bus_master->write_bit(dev->bus_master->data, 0);
w1_delay(6); w1_delay(6);
dev->bus_master->write_bit(dev->bus_master->data, 1); dev->bus_master->write_bit(dev->bus_master->data, 1);
w1_delay(9); w1_delay(9);
result = dev->bus_master->read_bit(dev->bus_master->data); result = dev->bus_master->read_bit(dev->bus_master->data);
local_irq_restore(flags);
w1_delay(55); w1_delay(55);
return result & 0x1; return result & 0x1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment