diff options
author | Evgeniy Polyakov <johnpol@2ka.mipt.ru> | 2005-08-11 09:27:49 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2005-09-08 17:41:26 -0400 |
commit | ea7d8f65c865ebfa1d7cd67c360a87333ff013c1 (patch) | |
tree | 1e687c32d53a92c10a61fb23ab14763459ff5779 /drivers/w1/w1_io.c | |
parent | db2d0008de519c5db6baec45f7831e08790301cf (diff) |
[PATCH] w1: Added w1_reset_select_slave() - Resets the bus and then selects the slave by
sending either a skip rom or a rom match.
Patch from 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 | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/drivers/w1/w1_io.c b/drivers/w1/w1_io.c index 00f032220173..e2a043354ddf 100644 --- a/drivers/w1/w1_io.c +++ b/drivers/w1/w1_io.c | |||
@@ -277,6 +277,29 @@ void w1_search_devices(struct w1_master *dev, w1_slave_found_callback cb) | |||
277 | w1_search(dev, cb); | 277 | w1_search(dev, cb); |
278 | } | 278 | } |
279 | 279 | ||
280 | /** | ||
281 | * Resets the bus and then selects the slave by sending either a skip rom | ||
282 | * or a rom match. | ||
283 | * The w1 master lock must be held. | ||
284 | * | ||
285 | * @param sl the slave to select | ||
286 | * @return 0=success, anything else=error | ||
287 | */ | ||
288 | int w1_reset_select_slave(struct w1_slave *sl) | ||
289 | { | ||
290 | if (w1_reset_bus(sl->master)) | ||
291 | return -1; | ||
292 | |||
293 | if (sl->master->slave_count == 1) | ||
294 | w1_write_8(sl->master, W1_SKIP_ROM); | ||
295 | else { | ||
296 | u8 match[9] = {W1_MATCH_ROM, }; | ||
297 | memcpy(&match[1], (u8 *)&sl->reg_num, 8); | ||
298 | w1_write_block(sl->master, match, 9); | ||
299 | } | ||
300 | return 0; | ||
301 | } | ||
302 | |||
280 | EXPORT_SYMBOL(w1_touch_bit); | 303 | EXPORT_SYMBOL(w1_touch_bit); |
281 | EXPORT_SYMBOL(w1_write_8); | 304 | EXPORT_SYMBOL(w1_write_8); |
282 | EXPORT_SYMBOL(w1_read_8); | 305 | EXPORT_SYMBOL(w1_read_8); |
@@ -286,3 +309,4 @@ EXPORT_SYMBOL(w1_delay); | |||
286 | EXPORT_SYMBOL(w1_read_block); | 309 | EXPORT_SYMBOL(w1_read_block); |
287 | EXPORT_SYMBOL(w1_write_block); | 310 | EXPORT_SYMBOL(w1_write_block); |
288 | EXPORT_SYMBOL(w1_search_devices); | 311 | EXPORT_SYMBOL(w1_search_devices); |
312 | EXPORT_SYMBOL(w1_reset_select_slave); | ||