From: David Fries <David@Fries.net>
To: linux-kernel@vger.kernel.org
Cc: Evgeniy Polyakov <zbr@ioremap.net>, GregKH <greg@kroah.com>
Subject: [PATCH 04/15] w1: increase w1_max_slave_count, allow write access
Date: Wed, 15 Jan 2014 22:29:15 -0600 [thread overview]
Message-ID: <1389846566-28862-5-git-send-email-David@Fries.net> (raw)
In-Reply-To: <1389846566-28862-1-git-send-email-David@Fries.net>
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>
---
drivers/w1/w1.c | 30 ++++++++++++++++++++++++++++--
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 92766a9..34ffdc6 100644
--- a/drivers/w1/w1.c
+++ b/drivers/w1/w1.c
@@ -46,7 +46,7 @@ MODULE_AUTHOR("Evgeniy Polyakov <zbr@ioremap.net>");
MODULE_DESCRIPTION("Driver for 1-wire Dallas network protocol.");
static int w1_timeout = 10;
-int w1_max_slave_count = 10;
+int w1_max_slave_count = 64;
int w1_max_slave_ttl = 10;
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
return count;
}
+static ssize_t w1_master_attribute_store_max_slave_count(struct device *dev,
+ struct device_attribute *attr, const char *buf, size_t count)
+{
+ long tmp;
+ struct w1_master *md = dev_to_w1_master(dev);
+
+ if (kstrtol(buf, 0, &tmp) == -EINVAL || tmp < 1)
+ return -EINVAL;
+
+ mutex_lock(&md->mutex);
+ md->max_slave_count = tmp;
+ /* allow each time the max_slave_count is updated */
+ clear_bit(W1_WARN_MAX_COUNT, &md->flags);
+ mutex_unlock(&md->mutex);
+
+ return count;
+}
+
static ssize_t w1_master_attribute_show_max_slave_count(struct device *dev, struct device_attribute *attr, char *buf)
{
struct w1_master *md = dev_to_w1_master(dev);
@@ -518,7 +536,7 @@ static ssize_t w1_master_attribute_store_remove(struct device *dev,
static W1_MASTER_ATTR_RO(name, S_IRUGO);
static W1_MASTER_ATTR_RO(slaves, S_IRUGO);
static W1_MASTER_ATTR_RO(slave_count, S_IRUGO);
-static W1_MASTER_ATTR_RO(max_slave_count, S_IRUGO);
+static W1_MASTER_ATTR_RW(max_slave_count, S_IRUGO | S_IWUSR | S_IWGRP);
static W1_MASTER_ATTR_RO(attempts, S_IRUGO);
static W1_MASTER_ATTR_RO(timeout, S_IRUGO);
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
desc_bit = last_zero;
cb(dev, rn);
}
+
+ if (!last_device && slave_count == dev->max_slave_count &&
+ !test_bit(W1_WARN_MAX_COUNT, &dev->flags)) {
+ dev_info(&dev->dev, "%s: max_slave_count %d reached, "
+ "additional sensors ignored\n", __func__,
+ dev->max_slave_count);
+ set_bit(W1_WARN_MAX_COUNT, &dev->flags);
+ }
}
}
diff --git a/drivers/w1/w1.h b/drivers/w1/w1.h
index bc329d2..bd10b3c 100644
--- a/drivers/w1/w1.h
+++ b/drivers/w1/w1.h
@@ -158,9 +158,11 @@ struct w1_bus_master
/**
* enum w1_master_flags - bitfields used in w1_master.flags
* @W1_ABORT_SEARCH: abort searching early on shutdown
+ * @W1_WARN_MAX_COUNT: limit warning when the maximum count is reached
*/
enum w1_master_flags {
W1_ABORT_SEARCH = 0,
+ W1_WARN_MAX_COUNT = 1,
};
struct w1_master
--
1.7.10.4
next prev parent reply other threads:[~2014-01-16 4:31 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-16 4:29 [PATCH 00/14] w1: async netlink, search, fixes, and improvements David Fries
2014-01-16 4:29 ` [PATCH 01/15] w1: fix w1_send_slave dropping a slave id David Fries
2014-01-16 4:29 ` [PATCH 02/15] w1: fixup search to support abort from netlink David Fries
2014-01-16 4:29 ` [PATCH 03/15] w1: Only wake up the search process if it is going to be searching David Fries
2014-01-16 4:29 ` David Fries [this message]
2014-01-16 4:29 ` [PATCH 05/15] w1: continue slave search where previous left off David Fries
2014-01-16 4:29 ` [PATCH 06/15] w1: new netlink commands, add/remove/list slaves David Fries
2014-01-16 4:29 ` [PATCH 07/15] w1: process w1 netlink commands in w1_process thread David Fries
2014-01-16 4:29 ` [PATCH 08/15] connector: add portid to unicast in addition to broadcasting David Fries
2014-01-16 4:29 ` [PATCH 09/15] w1: reply only to the requester portid David Fries
2014-01-16 4:29 ` [PATCH 10/15] w1: ds2490 reduce magic numbers David Fries
2014-01-16 4:29 ` [PATCH 11/15] w1: ds2490 USB setup fixes David Fries
2014-01-16 4:29 ` [PATCH 12/15] w1: ds2490 fix and enable hardware search David Fries
2014-01-16 4:29 ` [PATCH 13/15] w1: use family_data instead of rom in w1_slave David Fries
2014-01-16 4:29 ` [PATCH 14/15] w1: format for DocBook and fixes David Fries
2014-01-16 4:29 ` [PATCH 15/15] w1: hold bus_mutex in netlink and search David Fries
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1389846566-28862-5-git-send-email-David@Fries.net \
--to=david@fries.net \
--cc=greg@kroah.com \
--cc=linux-kernel@vger.kernel.org \
--cc=zbr@ioremap.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox