Skip to content

Commit

Permalink
w1: disable irqs in critical section
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Jan Weitzel authored and Linus Torvalds committed Nov 2, 2011
1 parent 68a436a commit 3fd306c
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions drivers/w1/w1_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 3fd306c

Please sign in to comment.