diff options
author | Evgeniy Polyakov <johnpol@2ka.mipt.ru> | 2005-06-04 01:30:43 +0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2005-06-21 21:43:11 -0700 |
commit | 6b729861831177b270a2932a13e79cb41d673146 (patch) | |
tree | 443c86578d04ba42d9b4e483d6ebee91ba30d25e /drivers/w1/w1_io.c | |
parent | be57ce267fd558c52d2389530c15618681b7cfa7 (diff) | |
download | op-kernel-dev-6b729861831177b270a2932a13e79cb41d673146.zip op-kernel-dev-6b729861831177b270a2932a13e79cb41d673146.tar.gz |
[PATCH] w1: Added the triplet w1 master method and changes w1_search() to use it.
Adds the triplet w1 master method and changes w1_search() to use it.
Signed-off-by: Ben Gardner <bgardner@wabtec.com>
Signed-off-by: Evgeniy Polyakov <johnpol@2ka.mipt.ru>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/w1/w1_io.c')
-rw-r--r-- | drivers/w1/w1_io.c | 43 |
1 files changed, 42 insertions, 1 deletions
diff --git a/drivers/w1/w1_io.c b/drivers/w1/w1_io.c index 2173336..00f0322 100644 --- a/drivers/w1/w1_io.c +++ b/drivers/w1/w1_io.c @@ -130,6 +130,47 @@ static u8 w1_read_bit(struct w1_master *dev) } /** + * Does a triplet - used for searching ROM addresses. + * Return bits: + * bit 0 = id_bit + * bit 1 = comp_bit + * bit 2 = dir_taken + * If both bits 0 & 1 are set, the search should be restarted. + * + * @param dev the master device + * @param bdir the bit to write if both id_bit and comp_bit are 0 + * @return bit fields - see above + */ +u8 w1_triplet(struct w1_master *dev, int bdir) +{ + if ( dev->bus_master->triplet ) + return(dev->bus_master->triplet(dev->bus_master->data, bdir)); + else { + u8 id_bit = w1_touch_bit(dev, 1); + u8 comp_bit = w1_touch_bit(dev, 1); + u8 retval; + + if ( id_bit && comp_bit ) + return(0x03); /* error */ + + if ( !id_bit && !comp_bit ) { + /* Both bits are valid, take the direction given */ + retval = bdir ? 0x04 : 0; + } else { + /* Only one bit is valid, take that direction */ + bdir = id_bit; + retval = id_bit ? 0x05 : 0x02; + } + + if ( dev->bus_master->touch_bit ) + w1_touch_bit(dev, bdir); + else + w1_write_bit(dev, bdir); + return(retval); + } +} + +/** * Reads 8 bits. * * @param dev the master device @@ -233,7 +274,7 @@ void w1_search_devices(struct w1_master *dev, w1_slave_found_callback cb) if (dev->bus_master->search) dev->bus_master->search(dev->bus_master->data, cb); else - w1_search(dev); + w1_search(dev, cb); } EXPORT_SYMBOL(w1_touch_bit); |