Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

w1: introduce an ability to specify microseconds bus scanning intervals

Some of 1-Wire devices commonly associated with physical access control
systems are attached/generate presence for as short as 100 ms - hence
the tens-to-hundreds milliseconds scan intervals are required.

Signed-off-by: Dmitry Khromov <dk@icelogic.net>
Acked-by: Evgeniy Polyakov <zbr@ioremap.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Dmitry Khromov and committed by
Greg Kroah-Hartman
c3098356 99b7e93c

+46 -12
+11
Documentation/ABI/stable/sysfs-bus-w1
··· 1 + What: /sys/bus/w1/devices/.../w1_master_timeout_us 2 + Date: April 2015 3 + Contact: Dmitry Khromov <dk@icelogic.net> 4 + Description: Bus scanning interval, microseconds component. 5 + Some of 1-Wire devices commonly associated with physical access 6 + control systems are attached/generate presence for as short as 7 + 100 ms - hence the tens-to-hundreds milliseconds scan intervals 8 + are required. 9 + see Documentation/w1/w1.generic for detailed information. 10 + Users: any user space application which wants to know bus scanning 11 + interval
+19 -11
Documentation/w1/w1.generic
··· 76 76 77 77 w1 master sysfs interface 78 78 ------------------------------------------------------------------ 79 - <xx-xxxxxxxxxxxxx> - a directory for a found device. The format is family-serial 79 + <xx-xxxxxxxxxxxxx> - A directory for a found device. The format is family-serial 80 80 bus - (standard) symlink to the w1 bus 81 81 driver - (standard) symlink to the w1 driver 82 - w1_master_add - Manually register a slave device 83 - w1_master_attempts - the number of times a search was attempted 82 + w1_master_add - (rw) manually register a slave device 83 + w1_master_attempts - (ro) the number of times a search was attempted 84 84 w1_master_max_slave_count 85 - - maximum number of slaves to search for at a time 86 - w1_master_name - the name of the device (w1_bus_masterX) 87 - w1_master_pullup - 5V strong pullup 0 enabled, 1 disabled 88 - w1_master_remove - Manually remove a slave device 89 - w1_master_search - the number of searches left to do, -1=continual (default) 85 + - (rw) maximum number of slaves to search for at a time 86 + w1_master_name - (ro) the name of the device (w1_bus_masterX) 87 + w1_master_pullup - (rw) 5V strong pullup 0 enabled, 1 disabled 88 + w1_master_remove - (rw) manually remove a slave device 89 + w1_master_search - (rw) the number of searches left to do, 90 + -1=continual (default) 90 91 w1_master_slave_count 91 - - the number of slaves found 92 - w1_master_slaves - the names of the slaves, one per line 93 - w1_master_timeout - the delay in seconds between searches 92 + - (ro) the number of slaves found 93 + w1_master_slaves - (ro) the names of the slaves, one per line 94 + w1_master_timeout - (ro) the delay in seconds between searches 95 + w1_master_timeout_us 96 + - (ro) the delay in microseconds beetwen searches 94 97 95 98 If you have a w1 bus that never changes (you don't add or remove devices), 96 99 you can set the module parameter search_count to a small positive number ··· 104 101 redetect manually removed devices that are present and timeout manually 105 102 added devices that aren't on the bus. 106 103 104 + Bus searches occur at an interval, specified as a summ of timeout and 105 + timeout_us module parameters (either of which may be 0) for as long as 106 + w1_master_search remains greater than 0 or is -1. Each search attempt 107 + decrements w1_master_search by 1 (down to 0) and increments 108 + w1_master_attempts by 1. 107 109 108 110 w1 slave sysfs interface 109 111 ------------------------------------------------------------------
+16 -1
drivers/w1/w1.c
··· 46 46 MODULE_DESCRIPTION("Driver for 1-wire Dallas network protocol."); 47 47 48 48 static int w1_timeout = 10; 49 + static int w1_timeout_us = 0; 49 50 int w1_max_slave_count = 64; 50 51 int w1_max_slave_ttl = 10; 51 52 52 53 module_param_named(timeout, w1_timeout, int, 0); 53 54 MODULE_PARM_DESC(timeout, "time in seconds between automatic slave searches"); 55 + module_param_named(timeout_us, w1_timeout_us, int, 0); 56 + MODULE_PARM_DESC(timeout, "time in microseconds between automatic slave" 57 + " searches"); 54 58 /* A search stops when w1_max_slave_count devices have been found in that 55 59 * search. The next search will start over and detect the same set of devices 56 60 * on a static 1-wire bus. Memory is not allocated based on this number, just ··· 321 317 return count; 322 318 } 323 319 320 + static ssize_t w1_master_attribute_show_timeout_us(struct device *dev, 321 + struct device_attribute *attr, char *buf) 322 + { 323 + ssize_t count; 324 + count = sprintf(buf, "%d\n", w1_timeout_us); 325 + return count; 326 + } 327 + 324 328 static ssize_t w1_master_attribute_store_max_slave_count(struct device *dev, 325 329 struct device_attribute *attr, const char *buf, size_t count) 326 330 { ··· 555 543 static W1_MASTER_ATTR_RW(max_slave_count, S_IRUGO | S_IWUSR | S_IWGRP); 556 544 static W1_MASTER_ATTR_RO(attempts, S_IRUGO); 557 545 static W1_MASTER_ATTR_RO(timeout, S_IRUGO); 546 + static W1_MASTER_ATTR_RO(timeout_us, S_IRUGO); 558 547 static W1_MASTER_ATTR_RO(pointer, S_IRUGO); 559 548 static W1_MASTER_ATTR_RW(search, S_IRUGO | S_IWUSR | S_IWGRP); 560 549 static W1_MASTER_ATTR_RW(pullup, S_IRUGO | S_IWUSR | S_IWGRP); ··· 569 556 &w1_master_attribute_max_slave_count.attr, 570 557 &w1_master_attribute_attempts.attr, 571 558 &w1_master_attribute_timeout.attr, 559 + &w1_master_attribute_timeout_us.attr, 572 560 &w1_master_attribute_pointer.attr, 573 561 &w1_master_attribute_search.attr, 574 562 &w1_master_attribute_pullup.attr, ··· 1122 1108 /* As long as w1_timeout is only set by a module parameter the sleep 1123 1109 * time can be calculated in jiffies once. 1124 1110 */ 1125 - const unsigned long jtime = msecs_to_jiffies(w1_timeout * 1000); 1111 + const unsigned long jtime = 1112 + usecs_to_jiffies(w1_timeout * 1000000 + w1_timeout_us); 1126 1113 /* remainder if it woke up early */ 1127 1114 unsigned long jremain = 0; 1128 1115