Skip to contentSkip to conversation

w1: add fast search for single slave bus

PATCH Superseded Hubert Feurstein 4 participants 7 messages Nov 28, 2011 – Dec 10, 2011 W1 dallas's 1-wire bus

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
 drivers/w1/Kconfig |    8 ++++++++
 drivers/w1/w1.c    |   11 +++++++++++
 2 files changed, 19 insertions(+), 0 deletions(-)
drivers/w1/Kconfig +8 -0
index fd2c7bd..e5006bc 100644
@@ -25,6 +25,14 @@ config W1_CON
 	  2. Userspace commands. Includes read/write and search/alarm search commands.
 	  3. Replies to userspace commands.
 
+config W1_FAST_SEARCH
+	bool "Fast search (single slave bus only!)"
+	---help---
+	  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.
+	  If unsure, say 'N'.
+
 source drivers/w1/masters/Kconfig
 source drivers/w1/slaves/Kconfig
 
drivers/w1/w1.c +11 -0
index c374978..7c648ec 100644
@@ -892,6 +892,17 @@ void w1_search(struct w1_master *dev, u8 search_type, w1_slave_found_callback cb
 			break;
 		}
 
+#ifdef CONFIG_W1_FAST_SEARCH
+		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;
+		}
+#endif
+
 		/* Start the search */
 		w1_write_8(dev, search_type);
 		for (i = 0; i < 64; ++i) {
Signature · 1 line
1.7.4.1
#1 lore raw

Hi

Quoted 3 lines · Hubert Feurstein

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.

Although idea may sound resonable, kernel is shipped with only one compiled option, and it is quite uncommon to recompile them. So this option will unlikely to be enabled. I would recommend to add either a module parameter to forbid multiple slave devices and use fast search, or use fast search when only one device exists and switch to common search when it fails (if it is possible to detect that there are multiple devices on the bus using fast search)

Signature · 1 line
	Evgeniy Polyakov
#2 lore raw
In reply to Hubert Feurstein
Quoted 16 lines · Hubert Feurstein

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.

---
drivers/w1/Kconfig | 8 ++++++++
drivers/w1/w1.c | 11 +++++++++++

2 files changed, 19 insertions(+), 0 deletions(-)
drivers/w1/Kconfig +0 -0
index fd2c7bd..e5006bc 100644
@@ -25,6 +25,14 @@ config W1_CON
 	  2. Userspace commands. Includes read/write and search/alarm search commands.

drivers/w1/Kconfig config W1_CON · line 35

Quoted 10 lines
drivers/w1/Kconfig +8 -0
 	  3. Replies to userspace commands.
 
+config W1_FAST_SEARCH
+	bool "Fast search (single slave bus only!)"
+	---help---
+	  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.
+	  If unsure, say 'N'.
+

Not needed I think, see below...

Quoted 12 lines

source drivers/w1/masters/Kconfig
source drivers/w1/slaves/Kconfig

drivers/w1/w1.c +1 -0
index c374978..7c648ec 100644
@@ -892,6 +892,17 @@ void w1_search(struct w1_master *dev, u8 search_type, w1_slave_found_callback cb
 			break;
 		}
 
+#ifdef CONFIG_W1_FAST_SEARCH

drivers/w1/w1.c void w1_search(struct w1_master *dev, u8 search_type, w1_slave_found_callback cb · line 905

Quoted 10 lines
drivers/w1/w1.c +10 -0
+		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;
+		}
+#endif
+

I would drop the CONFIG item and just add this "if" block to the search function unconditionnaly. Unless I am missing something, it wouldn't hurt multi-slave setups...

Quoted 11 lines
drivers/w1/w1.c +0 -0
 		/* Start the search */
 		w1_write_8(dev, search_type);
 		for (i = 0; i < 64; ++i) {
Signature · 7 lines
1.7.4.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
#3 lore raw

PATCH v2 1/1 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.

---
v2: remove config option

 drivers/w1/w1.c |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)
drivers/w1/w1.c +10 -0
index c374978..9761950 100644
@@ -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) {
Signature · 1 line
1.7.7.4
Acked-by on v2 1/1
#4 lore raw

Hi

Quoted 3 lines · Hubert Feurstein

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.

Looks good to me, thank you!
Greg, please pull it into your tree

Quoted 1 line
Signature · 1 line
	Evgeniy Polyakov
#5 lore raw
Quoted 9 lines · Evgeniy Polyakov

Hi

Quoted 3 lines · Hubert Feurstein

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.

Looks good to me, thank you!
Greg, please pull it into your tree

Um, pull what? Can someone please send me the whole patch, as I can't seem to find it anywhere, sorry.

greg k-h

#6 lore raw
Quoted 2 lines · Greg KH

Um, pull what? Can someone please send me the whole patch, as I can't seem to find it anywhere, sorry.

Forwarded

Signature · 1 line
	Evgeniy Polyakov