diff options
author | Evgeniy Polyakov <johnpol@2ka.mipt.ru> | 2005-06-03 17:30:43 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2005-06-22 00:43:11 -0400 |
commit | 6b729861831177b270a2932a13e79cb41d673146 (patch) | |
tree | 443c86578d04ba42d9b4e483d6ebee91ba30d25e /drivers/w1/w1_io.c | |
parent | be57ce267fd558c52d2389530c15618681b7cfa7 (diff) |
[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 2173336b60a7..00f032220173 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) | |||
130 | } | 130 | } |
131 | 131 | ||
132 | /** | 132 | /** |
133 | * Does a triplet - used for searching ROM addresses. | ||
134 | * Return bits: | ||
135 | * bit 0 = id_bit | ||
136 | * bit 1 = comp_bit | ||
137 | * bit 2 = dir_taken | ||
138 | * If both bits 0 & 1 are set, the search should be restarted. | ||
139 | * | ||
140 | * @param dev the master device | ||
141 | * @param bdir the bit to write if both id_bit and comp_bit are 0 | ||
142 | * @return bit fields - see above | ||
143 | */ | ||
144 | u8 w1_triplet(struct w1_master *dev, int bdir) | ||
145 | { | ||
146 | if ( dev->bus_master->triplet ) | ||
147 | return(dev->bus_master->triplet(dev->bus_master->data, bdir)); | ||
148 | else { | ||
149 | u8 id_bit = w1_touch_bit(dev, 1); | ||
150 | u8 comp_bit = w1_touch_bit(dev, 1); | ||
151 | u8 retval; | ||
152 | |||
153 | if ( id_bit && comp_bit ) | ||
154 | return(0x03); /* error */ | ||
155 | |||
156 | if ( !id_bit && !comp_bit ) { | ||
157 | /* Both bits are valid, take the direction given */ | ||
158 | retval = bdir ? 0x04 : 0; | ||
159 | } else { | ||
160 | /* Only one bit is valid, take that direction */ | ||
161 | bdir = id_bit; | ||
162 | retval = id_bit ? 0x05 : 0x02; | ||
163 | } | ||
164 | |||
165 | if ( dev->bus_master->touch_bit ) | ||
166 | w1_touch_bit(dev, bdir); | ||
167 | else | ||
168 | w1_write_bit(dev, bdir); | ||
169 | return(retval); | ||
170 | } | ||
171 | } | ||
172 | |||
173 | /** | ||
133 | * Reads 8 bits. | 174 | * Reads 8 bits. |
134 | * | 175 | * |
135 | * @param dev the master device | 176 | * @param dev the master device |
@@ -233,7 +274,7 @@ void w1_search_devices(struct w1_master *dev, w1_slave_found_callback cb) | |||
233 | if (dev->bus_master->search) | 274 | if (dev->bus_master->search) |
234 | dev->bus_master->search(dev->bus_master->data, cb); | 275 | dev->bus_master->search(dev->bus_master->data, cb); |
235 | else | 276 | else |
236 | w1_search(dev); | 277 | w1_search(dev, cb); |
237 | } | 278 | } |
238 | 279 | ||
239 | EXPORT_SYMBOL(w1_touch_bit); | 280 | EXPORT_SYMBOL(w1_touch_bit); |