Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 304028
b: refs/heads/master
c: 8f1e125
h: refs/heads/master
v: v3
  • Loading branch information
Markus Franke authored and Greg Kroah-Hartman committed Apr 11, 2012
1 parent cca34b3 commit c33bad9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: f19420c1acb0b573c88a12deb2d42035e22d4a17
refs/heads/master: 8f1e12512e9f1276b68c8b14a60961658c73336f
22 changes: 18 additions & 4 deletions trunk/drivers/w1/w1_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
static int w1_delay_parm = 1;
module_param_named(delay_coef, w1_delay_parm, int, 0);

static int w1_disable_irqs = 0;
module_param_named(disable_irqs, w1_disable_irqs, int, 0);

static u8 w1_crc8_table[] = {
0, 94, 188, 226, 97, 63, 221, 131, 194, 156, 126, 32, 163, 253, 31, 65,
157, 195, 33, 127, 252, 162, 64, 30, 95, 1, 227, 189, 62, 96, 130, 220,
Expand Down Expand Up @@ -79,6 +82,10 @@ static u8 w1_touch_bit(struct w1_master *dev, int bit)
*/
static void w1_write_bit(struct w1_master *dev, int bit)
{
unsigned long flags = 0;

if(w1_disable_irqs) local_irq_save(flags);

if (bit) {
dev->bus_master->write_bit(dev->bus_master->data, 0);
w1_delay(6);
Expand All @@ -90,6 +97,8 @@ static void w1_write_bit(struct w1_master *dev, int bit)
dev->bus_master->write_bit(dev->bus_master->data, 1);
w1_delay(10);
}

if(w1_disable_irqs) local_irq_restore(flags);
}

/**
Expand Down Expand Up @@ -158,7 +167,7 @@ EXPORT_SYMBOL_GPL(w1_write_8);
static u8 w1_read_bit(struct w1_master *dev)
{
int result;
unsigned long flags;
unsigned long flags = 0;

/* sample timing is critical here */
local_irq_save(flags);
Expand Down Expand Up @@ -318,6 +327,9 @@ EXPORT_SYMBOL_GPL(w1_read_block);
int w1_reset_bus(struct w1_master *dev)
{
int result;
unsigned long flags = 0;

if(w1_disable_irqs) local_irq_save(flags);

if (dev->bus_master->reset_bus)
result = dev->bus_master->reset_bus(dev->bus_master->data) & 0x1;
Expand All @@ -330,19 +342,21 @@ int w1_reset_bus(struct w1_master *dev)
* cpu for such a short amount of time AND get it back in
* the maximum amount of time.
*/
w1_delay(480);
w1_delay(500);
dev->bus_master->write_bit(dev->bus_master->data, 1);
w1_delay(70);

result = dev->bus_master->read_bit(dev->bus_master->data) & 0x1;
/* minmum 70 (above) + 410 = 480 us
/* minmum 70 (above) + 430 = 500 us
* There aren't any timing requirements between a reset and
* the following transactions. Sleeping is safe here.
*/
/* w1_delay(410); min required time */
/* w1_delay(430); min required time */
msleep(1);
}

if(w1_disable_irqs) local_irq_restore(flags);

return result;
}
EXPORT_SYMBOL_GPL(w1_reset_bus);
Expand Down

0 comments on commit c33bad9

Please sign in to comment.