aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/w1
diff options
context:
space:
mode:
authorDmitry Khromov <dk@icelogic.net>2015-05-12 15:29:44 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2015-05-24 15:08:59 -0400
commitc3098356927254be270e5dc186a2ca144b64463b (patch)
tree940a4cbc322141f72c57507bc9867cf1489466a9 /drivers/w1
parent99b7e93c95c78952724a9783de6c78def8fbfc3f (diff)
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>
Diffstat (limited to 'drivers/w1')
-rw-r--r--drivers/w1/w1.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c
index 181f41cb960b..c9a7ff67d395 100644
--- a/drivers/w1/w1.c
+++ b/drivers/w1/w1.c
@@ -46,11 +46,15 @@ MODULE_AUTHOR("Evgeniy Polyakov <zbr@ioremap.net>");
46MODULE_DESCRIPTION("Driver for 1-wire Dallas network protocol."); 46MODULE_DESCRIPTION("Driver for 1-wire Dallas network protocol.");
47 47
48static int w1_timeout = 10; 48static int w1_timeout = 10;
49static int w1_timeout_us = 0;
49int w1_max_slave_count = 64; 50int w1_max_slave_count = 64;
50int w1_max_slave_ttl = 10; 51int w1_max_slave_ttl = 10;
51 52
52module_param_named(timeout, w1_timeout, int, 0); 53module_param_named(timeout, w1_timeout, int, 0);
53MODULE_PARM_DESC(timeout, "time in seconds between automatic slave searches"); 54MODULE_PARM_DESC(timeout, "time in seconds between automatic slave searches");
55module_param_named(timeout_us, w1_timeout_us, int, 0);
56MODULE_PARM_DESC(timeout, "time in microseconds between automatic slave"
57 " searches");
54/* A search stops when w1_max_slave_count devices have been found in that 58/* A search stops when w1_max_slave_count devices have been found in that
55 * search. The next search will start over and detect the same set of devices 59 * search. The next search will start over and detect the same set of devices
56 * on a static 1-wire bus. Memory is not allocated based on this number, just 60 * on a static 1-wire bus. Memory is not allocated based on this number, just
@@ -317,6 +321,14 @@ static ssize_t w1_master_attribute_show_timeout(struct device *dev, struct devic
317 return count; 321 return count;
318} 322}
319 323
324static ssize_t w1_master_attribute_show_timeout_us(struct device *dev,
325 struct device_attribute *attr, char *buf)
326{
327 ssize_t count;
328 count = sprintf(buf, "%d\n", w1_timeout_us);
329 return count;
330}
331
320static ssize_t w1_master_attribute_store_max_slave_count(struct device *dev, 332static ssize_t w1_master_attribute_store_max_slave_count(struct device *dev,
321 struct device_attribute *attr, const char *buf, size_t count) 333 struct device_attribute *attr, const char *buf, size_t count)
322{ 334{
@@ -543,6 +555,7 @@ static W1_MASTER_ATTR_RO(slave_count, S_IRUGO);
543static W1_MASTER_ATTR_RW(max_slave_count, S_IRUGO | S_IWUSR | S_IWGRP); 555static W1_MASTER_ATTR_RW(max_slave_count, S_IRUGO | S_IWUSR | S_IWGRP);
544static W1_MASTER_ATTR_RO(attempts, S_IRUGO); 556static W1_MASTER_ATTR_RO(attempts, S_IRUGO);
545static W1_MASTER_ATTR_RO(timeout, S_IRUGO); 557static W1_MASTER_ATTR_RO(timeout, S_IRUGO);
558static W1_MASTER_ATTR_RO(timeout_us, S_IRUGO);
546static W1_MASTER_ATTR_RO(pointer, S_IRUGO); 559static W1_MASTER_ATTR_RO(pointer, S_IRUGO);
547static W1_MASTER_ATTR_RW(search, S_IRUGO | S_IWUSR | S_IWGRP); 560static W1_MASTER_ATTR_RW(search, S_IRUGO | S_IWUSR | S_IWGRP);
548static W1_MASTER_ATTR_RW(pullup, S_IRUGO | S_IWUSR | S_IWGRP); 561static W1_MASTER_ATTR_RW(pullup, S_IRUGO | S_IWUSR | S_IWGRP);
@@ -556,6 +569,7 @@ static struct attribute *w1_master_default_attrs[] = {
556 &w1_master_attribute_max_slave_count.attr, 569 &w1_master_attribute_max_slave_count.attr,
557 &w1_master_attribute_attempts.attr, 570 &w1_master_attribute_attempts.attr,
558 &w1_master_attribute_timeout.attr, 571 &w1_master_attribute_timeout.attr,
572 &w1_master_attribute_timeout_us.attr,
559 &w1_master_attribute_pointer.attr, 573 &w1_master_attribute_pointer.attr,
560 &w1_master_attribute_search.attr, 574 &w1_master_attribute_search.attr,
561 &w1_master_attribute_pullup.attr, 575 &w1_master_attribute_pullup.attr,
@@ -1108,7 +1122,8 @@ int w1_process(void *data)
1108 /* As long as w1_timeout is only set by a module parameter the sleep 1122 /* As long as w1_timeout is only set by a module parameter the sleep
1109 * time can be calculated in jiffies once. 1123 * time can be calculated in jiffies once.
1110 */ 1124 */
1111 const unsigned long jtime = msecs_to_jiffies(w1_timeout * 1000); 1125 const unsigned long jtime =
1126 usecs_to_jiffies(w1_timeout * 1000000 + w1_timeout_us);
1112 /* remainder if it woke up early */ 1127 /* remainder if it woke up early */
1113 unsigned long jremain = 0; 1128 unsigned long jremain = 0;
1114 1129