diff options
author | David Fries <David@Fries.net> | 2014-01-15 23:29:15 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2014-02-07 18:40:17 -0500 |
commit | a16130569af7e92b0a68a8c96170d84756f91c47 (patch) | |
tree | 062e723bc478c110d86fde537a69d264d59b2476 /drivers/w1 | |
parent | af8c7237b082acefb996878a21a87017059b2c52 (diff) |
w1: increase w1_max_slave_count, allow write access
w1_max_slave_count is only used to abort the search early
or take a fast search (when 1), so there isn't any reason to not allow
it to be updated through sysfs. Memory is not allocated based on
the current value and 10 is a rather low base number, increasing to
64, and printing a message the first time the count is reached and
there were more devices to discover to let the user know why not
all the devices were found.
Signed-off-by: David Fries <David@Fries.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.c | 30 | ||||
-rw-r--r-- | drivers/w1/w1.h | 2 |
2 files changed, 30 insertions, 2 deletions
diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c index 92766a9f8b4d..34ffdc6da4fb 100644 --- a/drivers/w1/w1.c +++ b/drivers/w1/w1.c | |||
@@ -46,7 +46,7 @@ MODULE_AUTHOR("Evgeniy Polyakov <zbr@ioremap.net>"); | |||
46 | MODULE_DESCRIPTION("Driver for 1-wire Dallas network protocol."); | 46 | MODULE_DESCRIPTION("Driver for 1-wire Dallas network protocol."); |
47 | 47 | ||
48 | static int w1_timeout = 10; | 48 | static int w1_timeout = 10; |
49 | int w1_max_slave_count = 10; | 49 | int w1_max_slave_count = 64; |
50 | int w1_max_slave_ttl = 10; | 50 | int w1_max_slave_ttl = 10; |
51 | 51 | ||
52 | module_param_named(timeout, w1_timeout, int, 0); | 52 | module_param_named(timeout, w1_timeout, int, 0); |
@@ -316,6 +316,24 @@ static ssize_t w1_master_attribute_show_timeout(struct device *dev, struct devic | |||
316 | return count; | 316 | return count; |
317 | } | 317 | } |
318 | 318 | ||
319 | static ssize_t w1_master_attribute_store_max_slave_count(struct device *dev, | ||
320 | struct device_attribute *attr, const char *buf, size_t count) | ||
321 | { | ||
322 | long tmp; | ||
323 | struct w1_master *md = dev_to_w1_master(dev); | ||
324 | |||
325 | if (kstrtol(buf, 0, &tmp) == -EINVAL || tmp < 1) | ||
326 | return -EINVAL; | ||
327 | |||
328 | mutex_lock(&md->mutex); | ||
329 | md->max_slave_count = tmp; | ||
330 | /* allow each time the max_slave_count is updated */ | ||
331 | clear_bit(W1_WARN_MAX_COUNT, &md->flags); | ||
332 | mutex_unlock(&md->mutex); | ||
333 | |||
334 | return count; | ||
335 | } | ||
336 | |||
319 | static ssize_t w1_master_attribute_show_max_slave_count(struct device *dev, struct device_attribute *attr, char *buf) | 337 | static ssize_t w1_master_attribute_show_max_slave_count(struct device *dev, struct device_attribute *attr, char *buf) |
320 | { | 338 | { |
321 | struct w1_master *md = dev_to_w1_master(dev); | 339 | struct w1_master *md = dev_to_w1_master(dev); |
@@ -518,7 +536,7 @@ static ssize_t w1_master_attribute_store_remove(struct device *dev, | |||
518 | static W1_MASTER_ATTR_RO(name, S_IRUGO); | 536 | static W1_MASTER_ATTR_RO(name, S_IRUGO); |
519 | static W1_MASTER_ATTR_RO(slaves, S_IRUGO); | 537 | static W1_MASTER_ATTR_RO(slaves, S_IRUGO); |
520 | static W1_MASTER_ATTR_RO(slave_count, S_IRUGO); | 538 | static W1_MASTER_ATTR_RO(slave_count, S_IRUGO); |
521 | static W1_MASTER_ATTR_RO(max_slave_count, S_IRUGO); | 539 | static W1_MASTER_ATTR_RW(max_slave_count, S_IRUGO | S_IWUSR | S_IWGRP); |
522 | static W1_MASTER_ATTR_RO(attempts, S_IRUGO); | 540 | static W1_MASTER_ATTR_RO(attempts, S_IRUGO); |
523 | static W1_MASTER_ATTR_RO(timeout, S_IRUGO); | 541 | static W1_MASTER_ATTR_RO(timeout, S_IRUGO); |
524 | static W1_MASTER_ATTR_RO(pointer, S_IRUGO); | 542 | static W1_MASTER_ATTR_RO(pointer, S_IRUGO); |
@@ -976,6 +994,14 @@ void w1_search(struct w1_master *dev, u8 search_type, w1_slave_found_callback cb | |||
976 | desc_bit = last_zero; | 994 | desc_bit = last_zero; |
977 | cb(dev, rn); | 995 | cb(dev, rn); |
978 | } | 996 | } |
997 | |||
998 | if (!last_device && slave_count == dev->max_slave_count && | ||
999 | !test_bit(W1_WARN_MAX_COUNT, &dev->flags)) { | ||
1000 | dev_info(&dev->dev, "%s: max_slave_count %d reached, " | ||
1001 | "additional sensors ignored\n", __func__, | ||
1002 | dev->max_slave_count); | ||
1003 | set_bit(W1_WARN_MAX_COUNT, &dev->flags); | ||
1004 | } | ||
979 | } | 1005 | } |
980 | } | 1006 | } |
981 | 1007 | ||
diff --git a/drivers/w1/w1.h b/drivers/w1/w1.h index bc329d2bba28..bd10b3c2a406 100644 --- a/drivers/w1/w1.h +++ b/drivers/w1/w1.h | |||
@@ -158,9 +158,11 @@ struct w1_bus_master | |||
158 | /** | 158 | /** |
159 | * enum w1_master_flags - bitfields used in w1_master.flags | 159 | * enum w1_master_flags - bitfields used in w1_master.flags |
160 | * @W1_ABORT_SEARCH: abort searching early on shutdown | 160 | * @W1_ABORT_SEARCH: abort searching early on shutdown |
161 | * @W1_WARN_MAX_COUNT: limit warning when the maximum count is reached | ||
161 | */ | 162 | */ |
162 | enum w1_master_flags { | 163 | enum w1_master_flags { |
163 | W1_ABORT_SEARCH = 0, | 164 | W1_ABORT_SEARCH = 0, |
165 | W1_WARN_MAX_COUNT = 1, | ||
164 | }; | 166 | }; |
165 | 167 | ||
166 | struct w1_master | 168 | struct w1_master |