From c9cbf558e7793d312a4dd5d839ad7eae1aa8bd12 Mon Sep 17 00:00:00 2001 From: Evgeniy Polyakov Date: Sat, 10 Dec 2011 04:36:11 +0300 Subject: w1: add fast search for single slave bus This enables a much more efficient way of device searching. It uses the 1-wire read-rom operation which allows the direct reading of the slave address. BUT this works only with exactly one slave on the bus. Signed-off-by: Hubert Feurstein Acked-by: Evgeniy Polyakov index c374978..9761950 100644 Signed-off-by: Greg Kroah-Hartman --- drivers/w1/w1.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'drivers/w1') diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c index c37497823851..9761950697b4 100644 --- a/drivers/w1/w1.c +++ b/drivers/w1/w1.c @@ -892,6 +892,16 @@ void w1_search(struct w1_master *dev, u8 search_type, w1_slave_found_callback cb break; } + /* Do fast search on single slave bus */ + if (dev->max_slave_count == 1) { + w1_write_8(dev, W1_READ_ROM); + + if (w1_read_block(dev, (u8 *)&rn, 8) == 8 && rn) + cb(dev, rn); + + break; + } + /* Start the search */ w1_write_8(dev, search_type); for (i = 0; i < 64; ++i) { -- cgit v1.2.3