w1: add fast search for single slave bus
authorEvgeniy Polyakov <zbr@ioremap.net>
Sat, 10 Dec 2011 01:36:11 +0000 (04:36 +0300)
committerGreg Kroah-Hartman <gregkh@suse.de>
Sat, 10 Dec 2011 03:19:18 +0000 (19:19 -0800)
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 <h.feurstein@gmail.com>
Acked-by: Evgeniy Polyakov <zbr@ioremap.net>
index c374978..9761950 100644
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/w1/w1.c

index c374978238515cd6a0e23b464076be91a9fcb744..9761950697b4775b484f3651920e6a44cd7171b1 100644 (file)
@@ -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) {