w1: add fast search for single slave bus
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
@@ -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
@@ -892,6 +892,17 @@ void w1_search(struct w1_master *dev, u8 search_type, w1_slave_found_callback cbbreak ; } +#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
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
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.
Signed-off-by Hubert Feurstein <[email protected]>---
drivers/w1/Kconfig| 8 ++++++++drivers/w1/w1.c| 11 +++++++++++2 files changed, 19 insertions(+), 0 deletions(-)drivers/w1/Kconfig +0
-0@@ -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
-03. 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
sourcedrivers/w1/slaves/Kconfigdrivers/w1/w1.c +1
-0@@ -892,6 +892,17 @@ void w1_search(struct w1_master *dev, u8 search_type, w1_slave_found_callback cbbreak ; } +#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/
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
@@ -892,6 +892,16 @@ void w1_search(struct w1_master *dev, u8 search_type, w1_slave_found_callback cbbreak ; } +/* 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
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
Signed-off-by Hubert Feurstein <[email protected]>
Signature · 1 line
Evgeniy Polyakov
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
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