* [PATCH] Introduce an ability to specify microseconds bus scanning intervals in w1 core
[not found] ` <1040571428797306@web8j.yandex.ru>
@ 2015-04-14 7:40 ` Dmitry Khromov
2015-04-14 17:15 ` Randy Dunlap
0 siblings, 1 reply; 10+ messages in thread
From: Dmitry Khromov @ 2015-04-14 7:40 UTC (permalink / raw)
To: linux-kernel; +Cc: gregkh, Evgeniy Polyakov
DS1990* "iButtons" and compatible RFID card readers commonly found at
physical access control systems are usually attached/generate presence
for as short as 100 ms - hence the tens-to-hundreds milliseconds scan
intervals are required.
Tested on Raspberry Pi model B+ with DS2482-100 bus master,
tens-of-milliseconds intervals are easily achieved without significant
CPU load (and with unknown accuracy), and though I doubt
microseconds-scale intervals are really feasible in terms of practical
use and underlying buses timings, I believe it makes sense to give the
ability of using them to those willing to try.
Signed-off-by: Dmitry Khromov <dk@icelogic.net>
Acked-by: Evgeniy Polyakov <zbr@ioremap.net>
drivers/w1/w1.c | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
---
diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c
index 181f41c..73b4e2d 100644
--- a/drivers/w1/w1.c
+++ b/drivers/w1/w1.c
@@ -46,11 +46,15 @@ MODULE_AUTHOR("Evgeniy Polyakov <zbr@ioremap.net>");
MODULE_DESCRIPTION("Driver for 1-wire Dallas network protocol.");
static int w1_timeout = 10;
+static int w1_timeout_us = 0;
int w1_max_slave_count = 64;
int w1_max_slave_ttl = 10;
module_param_named(timeout, w1_timeout, int, 0);
MODULE_PARM_DESC(timeout, "time in seconds between automatic slave searches");
+module_param_named(timeout_us, w1_timeout_us, int, 0);
+MODULE_PARM_DESC(timeout, "time in microseconds between automatic slave"
+ "searches");
/* A search stops when w1_max_slave_count devices have been found in that
* search. The next search will start over and detect the same set of devices
* 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
return count;
}
+static ssize_t w1_master_attribute_show_timeout_us(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ ssize_t count;
+ count = sprintf(buf, "%d\n", w1_timeout_us);
+ 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)
{
@@ -543,6 +555,7 @@ static W1_MASTER_ATTR_RO(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(timeout_us, S_IRUGO);
static W1_MASTER_ATTR_RO(pointer, S_IRUGO);
static W1_MASTER_ATTR_RW(search, S_IRUGO | S_IWUSR | S_IWGRP);
static W1_MASTER_ATTR_RW(pullup, S_IRUGO | S_IWUSR | S_IWGRP);
@@ -556,6 +569,7 @@ static struct attribute *w1_master_default_attrs[] = {
&w1_master_attribute_max_slave_count.attr,
&w1_master_attribute_attempts.attr,
&w1_master_attribute_timeout.attr,
+ &w1_master_attribute_timeout_us.attr,
&w1_master_attribute_pointer.attr,
&w1_master_attribute_search.attr,
&w1_master_attribute_pullup.attr,
@@ -1108,7 +1122,8 @@ int w1_process(void *data)
/* As long as w1_timeout is only set by a module parameter the sleep
* time can be calculated in jiffies once.
*/
- const unsigned long jtime = msecs_to_jiffies(w1_timeout * 1000);
+ const unsigned long jtime =
+ usecs_to_jiffies(w1_timeout * 1000000 + w1_timeout_us);
/* remainder if it woke up early */
unsigned long jremain = 0;
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH] Introduce an ability to specify microseconds bus scanning intervals in w1 core
2015-04-14 7:40 ` [PATCH] Introduce an ability to specify microseconds bus scanning intervals in w1 core Dmitry Khromov
@ 2015-04-14 17:15 ` Randy Dunlap
2015-04-22 21:55 ` [PATCH v2] w1: introduce an ability to specify microseconds bus scanning intervals Dmitry Khromov
0 siblings, 1 reply; 10+ messages in thread
From: Randy Dunlap @ 2015-04-14 17:15 UTC (permalink / raw)
To: Dmitry Khromov, linux-kernel; +Cc: gregkh, Evgeniy Polyakov
On 04/14/15 00:40, Dmitry Khromov wrote:
> DS1990* "iButtons" and compatible RFID card readers commonly found at
> physical access control systems are usually attached/generate presence
> for as short as 100 ms - hence the tens-to-hundreds milliseconds scan
> intervals are required.
>
> Tested on Raspberry Pi model B+ with DS2482-100 bus master,
> tens-of-milliseconds intervals are easily achieved without significant
> CPU load (and with unknown accuracy), and though I doubt
> microseconds-scale intervals are really feasible in terms of practical
> use and underlying buses timings, I believe it makes sense to give the
> ability of using them to those willing to try.
>
> Signed-off-by: Dmitry Khromov <dk@icelogic.net>
> Acked-by: Evgeniy Polyakov <zbr@ioremap.net>
>
> drivers/w1/w1.c | 17 ++++++++++++++++-
> 1 file changed, 16 insertions(+), 1 deletion(-)
> ---
> diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c
> index 181f41c..73b4e2d 100644
> --- a/drivers/w1/w1.c
> +++ b/drivers/w1/w1.c
> @@ -46,11 +46,15 @@ MODULE_AUTHOR("Evgeniy Polyakov <zbr@ioremap.net>");
> MODULE_DESCRIPTION("Driver for 1-wire Dallas network protocol.");
>
> static int w1_timeout = 10;
> +static int w1_timeout_us = 0;
> int w1_max_slave_count = 64;
> int w1_max_slave_ttl = 10;
>
> module_param_named(timeout, w1_timeout, int, 0);
> MODULE_PARM_DESC(timeout, "time in seconds between automatic slave searches");
> +module_param_named(timeout_us, w1_timeout_us, int, 0);
> +MODULE_PARM_DESC(timeout, "time in microseconds between automatic slave"
> + "searches");
The description string needs a space between "slave" and "searches".
> /* A search stops when w1_max_slave_count devices have been found in that
> * search. The next search will start over and detect the same set of devices
> * on a static 1-wire bus. Memory is not allocated based on this number, just
--
~Randy
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v2] w1: introduce an ability to specify microseconds bus scanning intervals
2015-04-14 17:15 ` Randy Dunlap
@ 2015-04-22 21:55 ` Dmitry Khromov
2015-04-22 23:22 ` Evgeniy Polyakov
2015-04-23 9:20 ` Greg KH
0 siblings, 2 replies; 10+ messages in thread
From: Dmitry Khromov @ 2015-04-22 21:55 UTC (permalink / raw)
To: linux-kernel; +Cc: gregkh, zbr, rdunlap, Dmitry Khromov
Signed-off-by: Dmitry Khromov <dk@icelogic.net>
---
drivers/w1/w1.c | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c
index 181f41c..c9a7ff6 100644
--- a/drivers/w1/w1.c
+++ b/drivers/w1/w1.c
@@ -46,11 +46,15 @@ MODULE_AUTHOR("Evgeniy Polyakov <zbr@ioremap.net>");
MODULE_DESCRIPTION("Driver for 1-wire Dallas network protocol.");
static int w1_timeout = 10;
+static int w1_timeout_us = 0;
int w1_max_slave_count = 64;
int w1_max_slave_ttl = 10;
module_param_named(timeout, w1_timeout, int, 0);
MODULE_PARM_DESC(timeout, "time in seconds between automatic slave searches");
+module_param_named(timeout_us, w1_timeout_us, int, 0);
+MODULE_PARM_DESC(timeout, "time in microseconds between automatic slave"
+ " searches");
/* A search stops when w1_max_slave_count devices have been found in that
* search. The next search will start over and detect the same set of devices
* 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
return count;
}
+static ssize_t w1_master_attribute_show_timeout_us(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ ssize_t count;
+ count = sprintf(buf, "%d\n", w1_timeout_us);
+ 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)
{
@@ -543,6 +555,7 @@ static W1_MASTER_ATTR_RO(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(timeout_us, S_IRUGO);
static W1_MASTER_ATTR_RO(pointer, S_IRUGO);
static W1_MASTER_ATTR_RW(search, S_IRUGO | S_IWUSR | S_IWGRP);
static W1_MASTER_ATTR_RW(pullup, S_IRUGO | S_IWUSR | S_IWGRP);
@@ -556,6 +569,7 @@ static struct attribute *w1_master_default_attrs[] = {
&w1_master_attribute_max_slave_count.attr,
&w1_master_attribute_attempts.attr,
&w1_master_attribute_timeout.attr,
+ &w1_master_attribute_timeout_us.attr,
&w1_master_attribute_pointer.attr,
&w1_master_attribute_search.attr,
&w1_master_attribute_pullup.attr,
@@ -1108,7 +1122,8 @@ int w1_process(void *data)
/* As long as w1_timeout is only set by a module parameter the sleep
* time can be calculated in jiffies once.
*/
- const unsigned long jtime = msecs_to_jiffies(w1_timeout * 1000);
+ const unsigned long jtime =
+ usecs_to_jiffies(w1_timeout * 1000000 + w1_timeout_us);
/* remainder if it woke up early */
unsigned long jremain = 0;
--
2.3.5
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH v2] w1: introduce an ability to specify microseconds bus scanning intervals
2015-04-22 21:55 ` [PATCH v2] w1: introduce an ability to specify microseconds bus scanning intervals Dmitry Khromov
@ 2015-04-22 23:22 ` Evgeniy Polyakov
2015-04-23 9:20 ` Greg KH
1 sibling, 0 replies; 10+ messages in thread
From: Evgeniy Polyakov @ 2015-04-22 23:22 UTC (permalink / raw)
To: Dmitry Khromov, linux-kernel; +Cc: gregkh, rdunlap
Hi
Looks good to me. Greg, please pull it into your tree.
Acked-by: Evgeniy Polyakov <zbr@ioremap.net>
23.04.2015, 00:56, "Dmitry Khromov" <dk@icelogic.net>:
> Signed-off-by: Dmitry Khromov <dk@icelogic.net>
> ---
> drivers/w1/w1.c | 17 ++++++++++++++++-
> 1 file changed, 16 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c
> index 181f41c..c9a7ff6 100644
> --- a/drivers/w1/w1.c
> +++ b/drivers/w1/w1.c
> @@ -46,11 +46,15 @@ MODULE_AUTHOR("Evgeniy Polyakov <zbr@ioremap.net>");
> MODULE_DESCRIPTION("Driver for 1-wire Dallas network protocol.");
>
> static int w1_timeout = 10;
> +static int w1_timeout_us = 0;
> int w1_max_slave_count = 64;
> int w1_max_slave_ttl = 10;
>
> module_param_named(timeout, w1_timeout, int, 0);
> MODULE_PARM_DESC(timeout, "time in seconds between automatic slave searches");
> +module_param_named(timeout_us, w1_timeout_us, int, 0);
> +MODULE_PARM_DESC(timeout, "time in microseconds between automatic slave"
> + " searches");
> /* A search stops when w1_max_slave_count devices have been found in that
> * search. The next search will start over and detect the same set of devices
> * 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
> return count;
> }
>
> +static ssize_t w1_master_attribute_show_timeout_us(struct device *dev,
> + struct device_attribute *attr, char *buf)
> +{
> + ssize_t count;
> + count = sprintf(buf, "%d\n", w1_timeout_us);
> + 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)
> {
> @@ -543,6 +555,7 @@ static W1_MASTER_ATTR_RO(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(timeout_us, S_IRUGO);
> static W1_MASTER_ATTR_RO(pointer, S_IRUGO);
> static W1_MASTER_ATTR_RW(search, S_IRUGO | S_IWUSR | S_IWGRP);
> static W1_MASTER_ATTR_RW(pullup, S_IRUGO | S_IWUSR | S_IWGRP);
> @@ -556,6 +569,7 @@ static struct attribute *w1_master_default_attrs[] = {
> &w1_master_attribute_max_slave_count.attr,
> &w1_master_attribute_attempts.attr,
> &w1_master_attribute_timeout.attr,
> + &w1_master_attribute_timeout_us.attr,
> &w1_master_attribute_pointer.attr,
> &w1_master_attribute_search.attr,
> &w1_master_attribute_pullup.attr,
> @@ -1108,7 +1122,8 @@ int w1_process(void *data)
> /* As long as w1_timeout is only set by a module parameter the sleep
> * time can be calculated in jiffies once.
> */
> - const unsigned long jtime = msecs_to_jiffies(w1_timeout * 1000);
> + const unsigned long jtime =
> + usecs_to_jiffies(w1_timeout * 1000000 + w1_timeout_us);
> /* remainder if it woke up early */
> unsigned long jremain = 0;
>
> --
> 2.3.5
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2] w1: introduce an ability to specify microseconds bus scanning intervals
2015-04-22 21:55 ` [PATCH v2] w1: introduce an ability to specify microseconds bus scanning intervals Dmitry Khromov
2015-04-22 23:22 ` Evgeniy Polyakov
@ 2015-04-23 9:20 ` Greg KH
2015-04-23 11:30 ` Dmitry Khromov
2015-05-12 19:29 ` Dmitry Khromov
1 sibling, 2 replies; 10+ messages in thread
From: Greg KH @ 2015-04-23 9:20 UTC (permalink / raw)
To: Dmitry Khromov; +Cc: linux-kernel, zbr, rdunlap
On Thu, Apr 23, 2015 at 12:55:35AM +0300, Dmitry Khromov wrote:
> Signed-off-by: Dmitry Khromov <dk@icelogic.net>
> ---
> drivers/w1/w1.c | 17 ++++++++++++++++-
> 1 file changed, 16 insertions(+), 1 deletion(-)
You added a new sysfs file, without any documentation about it added to
Documentation/ABI, nor any reason why this needs to be done in the
changelog entry for the patch.
I need _some_ kind of information here, sorry, I can't take this as-is.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2] w1: introduce an ability to specify microseconds bus scanning intervals
2015-04-23 9:20 ` Greg KH
@ 2015-04-23 11:30 ` Dmitry Khromov
2015-04-23 11:33 ` [PATCH v3] " Dmitry Khromov
2015-05-12 19:29 ` Dmitry Khromov
1 sibling, 1 reply; 10+ messages in thread
From: Dmitry Khromov @ 2015-04-23 11:30 UTC (permalink / raw)
To: Greg KH, Evgeniy Polyakov; +Cc: linux-kernel, rdunlap
On 23.04.2015 12:20, Greg KH wrote:
> On Thu, Apr 23, 2015 at 12:55:35AM +0300, Dmitry Khromov wrote:
>> Signed-off-by: Dmitry Khromov <dk@icelogic.net>
>> ---
>> drivers/w1/w1.c | 17 ++++++++++++++++-
>> 1 file changed, 16 insertions(+), 1 deletion(-)
>
> You added a new sysfs file, without any documentation about it added to
> Documentation/ABI, nor any reason why this needs to be done in the
> changelog entry for the patch.
Sorry for that, the complete reason was given in the original version of
the patch, I've added a short summary in the changelog for v3. Thanks
for reminding about the documentation. I've added a short description
and minor cosmetics to Documentation/w1/w1.generic to give a slightly
more detailed idea on what's going on during the bus scan.
Please review.
--
Regards,
- Dmitry
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v3] w1: introduce an ability to specify microseconds bus scanning intervals
2015-04-23 11:30 ` Dmitry Khromov
@ 2015-04-23 11:33 ` Dmitry Khromov
0 siblings, 0 replies; 10+ messages in thread
From: Dmitry Khromov @ 2015-04-23 11:33 UTC (permalink / raw)
To: gregkh, zbr; +Cc: linux-kernel, rdunlap, Dmitry Khromov
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>
---
Documentation/ABI/stable/sysfs-bus-w1 | 11 +++++++++++
Documentation/w1/w1.generic | 30 +++++++++++++++++++-----------
drivers/w1/w1.c | 17 ++++++++++++++++-
3 files changed, 46 insertions(+), 12 deletions(-)
create mode 100644 Documentation/ABI/stable/sysfs-bus-w1
diff --git a/Documentation/ABI/stable/sysfs-bus-w1 b/Documentation/ABI/stable/sysfs-bus-w1
new file mode 100644
index 0000000..140d85b
--- /dev/null
+++ b/Documentation/ABI/stable/sysfs-bus-w1
@@ -0,0 +1,11 @@
+What: /sys/bus/w1/devices/.../w1_master_timeout_us
+Date: April 2015
+Contact: Dmitry Khromov <dk@icelogic.net>
+Description: Bus scanning interval, microseconds component.
+ 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.
+ see Documentation/w1/w1.generic for detailed information.
+Users: any user space application which wants to know bus scanning
+ interval
diff --git a/Documentation/w1/w1.generic b/Documentation/w1/w1.generic
index b2033c6..b3ffaf8 100644
--- a/Documentation/w1/w1.generic
+++ b/Documentation/w1/w1.generic
@@ -76,21 +76,24 @@ See struct w1_bus_master definition in w1.h for details.
w1 master sysfs interface
------------------------------------------------------------------
-<xx-xxxxxxxxxxxxx> - a directory for a found device. The format is family-serial
+<xx-xxxxxxxxxxxxx> - A directory for a found device. The format is family-serial
bus - (standard) symlink to the w1 bus
driver - (standard) symlink to the w1 driver
-w1_master_add - Manually register a slave device
-w1_master_attempts - the number of times a search was attempted
+w1_master_add - (rw) manually register a slave device
+w1_master_attempts - (ro) the number of times a search was attempted
w1_master_max_slave_count
- - maximum number of slaves to search for at a time
-w1_master_name - the name of the device (w1_bus_masterX)
-w1_master_pullup - 5V strong pullup 0 enabled, 1 disabled
-w1_master_remove - Manually remove a slave device
-w1_master_search - the number of searches left to do, -1=continual (default)
+ - (rw) maximum number of slaves to search for at a time
+w1_master_name - (ro) the name of the device (w1_bus_masterX)
+w1_master_pullup - (rw) 5V strong pullup 0 enabled, 1 disabled
+w1_master_remove - (rw) manually remove a slave device
+w1_master_search - (rw) the number of searches left to do,
+ -1=continual (default)
w1_master_slave_count
- - the number of slaves found
-w1_master_slaves - the names of the slaves, one per line
-w1_master_timeout - the delay in seconds between searches
+ - (ro) the number of slaves found
+w1_master_slaves - (ro) the names of the slaves, one per line
+w1_master_timeout - (ro) the delay in seconds between searches
+w1_master_timeout_us
+ - (ro) the delay in microseconds beetwen searches
If you have a w1 bus that never changes (you don't add or remove devices),
you can set the module parameter search_count to a small positive number
@@ -101,6 +104,11 @@ generally only make sense when searching is disabled, as a search will
redetect manually removed devices that are present and timeout manually
added devices that aren't on the bus.
+Bus searches occur at an interval, specified as a summ of timeout and
+timeout_us module parameters (either of which may be 0) for as long as
+w1_master_search remains greater than 0 or is -1. Each search attempt
+decrements w1_master_search by 1 (down to 0) and increments
+w1_master_attempts by 1.
w1 slave sysfs interface
------------------------------------------------------------------
diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c
index 181f41c..c9a7ff6 100644
--- a/drivers/w1/w1.c
+++ b/drivers/w1/w1.c
@@ -46,11 +46,15 @@ MODULE_AUTHOR("Evgeniy Polyakov <zbr@ioremap.net>");
MODULE_DESCRIPTION("Driver for 1-wire Dallas network protocol.");
static int w1_timeout = 10;
+static int w1_timeout_us = 0;
int w1_max_slave_count = 64;
int w1_max_slave_ttl = 10;
module_param_named(timeout, w1_timeout, int, 0);
MODULE_PARM_DESC(timeout, "time in seconds between automatic slave searches");
+module_param_named(timeout_us, w1_timeout_us, int, 0);
+MODULE_PARM_DESC(timeout, "time in microseconds between automatic slave"
+ " searches");
/* A search stops when w1_max_slave_count devices have been found in that
* search. The next search will start over and detect the same set of devices
* 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
return count;
}
+static ssize_t w1_master_attribute_show_timeout_us(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ ssize_t count;
+ count = sprintf(buf, "%d\n", w1_timeout_us);
+ 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)
{
@@ -543,6 +555,7 @@ static W1_MASTER_ATTR_RO(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(timeout_us, S_IRUGO);
static W1_MASTER_ATTR_RO(pointer, S_IRUGO);
static W1_MASTER_ATTR_RW(search, S_IRUGO | S_IWUSR | S_IWGRP);
static W1_MASTER_ATTR_RW(pullup, S_IRUGO | S_IWUSR | S_IWGRP);
@@ -556,6 +569,7 @@ static struct attribute *w1_master_default_attrs[] = {
&w1_master_attribute_max_slave_count.attr,
&w1_master_attribute_attempts.attr,
&w1_master_attribute_timeout.attr,
+ &w1_master_attribute_timeout_us.attr,
&w1_master_attribute_pointer.attr,
&w1_master_attribute_search.attr,
&w1_master_attribute_pullup.attr,
@@ -1108,7 +1122,8 @@ int w1_process(void *data)
/* As long as w1_timeout is only set by a module parameter the sleep
* time can be calculated in jiffies once.
*/
- const unsigned long jtime = msecs_to_jiffies(w1_timeout * 1000);
+ const unsigned long jtime =
+ usecs_to_jiffies(w1_timeout * 1000000 + w1_timeout_us);
/* remainder if it woke up early */
unsigned long jremain = 0;
--
2.3.5
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v3] w1: introduce an ability to specify microseconds bus scanning intervals
2015-04-23 9:20 ` Greg KH
2015-04-23 11:30 ` Dmitry Khromov
@ 2015-05-12 19:29 ` Dmitry Khromov
2015-05-13 15:00 ` Evgeniy Polyakov
1 sibling, 1 reply; 10+ messages in thread
From: Dmitry Khromov @ 2015-05-12 19:29 UTC (permalink / raw)
To: gregkh, zbr; +Cc: linux-kernel, Dmitry Khromov
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>
---
Documentation/ABI/stable/sysfs-bus-w1 | 11 +++++++++++
Documentation/w1/w1.generic | 30 +++++++++++++++++++-----------
drivers/w1/w1.c | 17 ++++++++++++++++-
3 files changed, 46 insertions(+), 12 deletions(-)
create mode 100644 Documentation/ABI/stable/sysfs-bus-w1
diff --git a/Documentation/ABI/stable/sysfs-bus-w1 b/Documentation/ABI/stable/sysfs-bus-w1
new file mode 100644
index 0000000..140d85b
--- /dev/null
+++ b/Documentation/ABI/stable/sysfs-bus-w1
@@ -0,0 +1,11 @@
+What: /sys/bus/w1/devices/.../w1_master_timeout_us
+Date: April 2015
+Contact: Dmitry Khromov <dk@icelogic.net>
+Description: Bus scanning interval, microseconds component.
+ 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.
+ see Documentation/w1/w1.generic for detailed information.
+Users: any user space application which wants to know bus scanning
+ interval
diff --git a/Documentation/w1/w1.generic b/Documentation/w1/w1.generic
index b2033c6..b3ffaf8 100644
--- a/Documentation/w1/w1.generic
+++ b/Documentation/w1/w1.generic
@@ -76,21 +76,24 @@ See struct w1_bus_master definition in w1.h for details.
w1 master sysfs interface
------------------------------------------------------------------
-<xx-xxxxxxxxxxxxx> - a directory for a found device. The format is family-serial
+<xx-xxxxxxxxxxxxx> - A directory for a found device. The format is family-serial
bus - (standard) symlink to the w1 bus
driver - (standard) symlink to the w1 driver
-w1_master_add - Manually register a slave device
-w1_master_attempts - the number of times a search was attempted
+w1_master_add - (rw) manually register a slave device
+w1_master_attempts - (ro) the number of times a search was attempted
w1_master_max_slave_count
- - maximum number of slaves to search for at a time
-w1_master_name - the name of the device (w1_bus_masterX)
-w1_master_pullup - 5V strong pullup 0 enabled, 1 disabled
-w1_master_remove - Manually remove a slave device
-w1_master_search - the number of searches left to do, -1=continual (default)
+ - (rw) maximum number of slaves to search for at a time
+w1_master_name - (ro) the name of the device (w1_bus_masterX)
+w1_master_pullup - (rw) 5V strong pullup 0 enabled, 1 disabled
+w1_master_remove - (rw) manually remove a slave device
+w1_master_search - (rw) the number of searches left to do,
+ -1=continual (default)
w1_master_slave_count
- - the number of slaves found
-w1_master_slaves - the names of the slaves, one per line
-w1_master_timeout - the delay in seconds between searches
+ - (ro) the number of slaves found
+w1_master_slaves - (ro) the names of the slaves, one per line
+w1_master_timeout - (ro) the delay in seconds between searches
+w1_master_timeout_us
+ - (ro) the delay in microseconds beetwen searches
If you have a w1 bus that never changes (you don't add or remove devices),
you can set the module parameter search_count to a small positive number
@@ -101,6 +104,11 @@ generally only make sense when searching is disabled, as a search will
redetect manually removed devices that are present and timeout manually
added devices that aren't on the bus.
+Bus searches occur at an interval, specified as a summ of timeout and
+timeout_us module parameters (either of which may be 0) for as long as
+w1_master_search remains greater than 0 or is -1. Each search attempt
+decrements w1_master_search by 1 (down to 0) and increments
+w1_master_attempts by 1.
w1 slave sysfs interface
------------------------------------------------------------------
diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c
index 181f41c..c9a7ff6 100644
--- a/drivers/w1/w1.c
+++ b/drivers/w1/w1.c
@@ -46,11 +46,15 @@ MODULE_AUTHOR("Evgeniy Polyakov <zbr@ioremap.net>");
MODULE_DESCRIPTION("Driver for 1-wire Dallas network protocol.");
static int w1_timeout = 10;
+static int w1_timeout_us = 0;
int w1_max_slave_count = 64;
int w1_max_slave_ttl = 10;
module_param_named(timeout, w1_timeout, int, 0);
MODULE_PARM_DESC(timeout, "time in seconds between automatic slave searches");
+module_param_named(timeout_us, w1_timeout_us, int, 0);
+MODULE_PARM_DESC(timeout, "time in microseconds between automatic slave"
+ " searches");
/* A search stops when w1_max_slave_count devices have been found in that
* search. The next search will start over and detect the same set of devices
* 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
return count;
}
+static ssize_t w1_master_attribute_show_timeout_us(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ ssize_t count;
+ count = sprintf(buf, "%d\n", w1_timeout_us);
+ 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)
{
@@ -543,6 +555,7 @@ static W1_MASTER_ATTR_RO(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(timeout_us, S_IRUGO);
static W1_MASTER_ATTR_RO(pointer, S_IRUGO);
static W1_MASTER_ATTR_RW(search, S_IRUGO | S_IWUSR | S_IWGRP);
static W1_MASTER_ATTR_RW(pullup, S_IRUGO | S_IWUSR | S_IWGRP);
@@ -556,6 +569,7 @@ static struct attribute *w1_master_default_attrs[] = {
&w1_master_attribute_max_slave_count.attr,
&w1_master_attribute_attempts.attr,
&w1_master_attribute_timeout.attr,
+ &w1_master_attribute_timeout_us.attr,
&w1_master_attribute_pointer.attr,
&w1_master_attribute_search.attr,
&w1_master_attribute_pullup.attr,
@@ -1108,7 +1122,8 @@ int w1_process(void *data)
/* As long as w1_timeout is only set by a module parameter the sleep
* time can be calculated in jiffies once.
*/
- const unsigned long jtime = msecs_to_jiffies(w1_timeout * 1000);
+ const unsigned long jtime =
+ usecs_to_jiffies(w1_timeout * 1000000 + w1_timeout_us);
/* remainder if it woke up early */
unsigned long jremain = 0;
--
2.3.5
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH v3] w1: introduce an ability to specify microseconds bus scanning intervals
2015-05-12 19:29 ` Dmitry Khromov
@ 2015-05-13 15:00 ` Evgeniy Polyakov
2015-05-13 15:31 ` gregkh
0 siblings, 1 reply; 10+ messages in thread
From: Evgeniy Polyakov @ 2015-05-13 15:00 UTC (permalink / raw)
To: Dmitry Khromov, gregkh; +Cc: linux-kernel
Hi
12.05.2015, 22:30, "Dmitry Khromov" <dk@icelogic.net>:
> 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>
Greg, please pull it upstream
Acked-by: Evgeniy Polyakov <zbr@ioremap.net>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v3] w1: introduce an ability to specify microseconds bus scanning intervals
2015-05-13 15:00 ` Evgeniy Polyakov
@ 2015-05-13 15:31 ` gregkh
0 siblings, 0 replies; 10+ messages in thread
From: gregkh @ 2015-05-13 15:31 UTC (permalink / raw)
To: Evgeniy Polyakov; +Cc: Dmitry Khromov, linux-kernel
On Wed, May 13, 2015 at 06:00:55PM +0300, Evgeniy Polyakov wrote:
> Hi
>
> 12.05.2015, 22:30, "Dmitry Khromov" <dk@icelogic.net>:
> > 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>
>
> Greg, please pull it upstream
> Acked-by: Evgeniy Polyakov <zbr@ioremap.net>
Ok, will do.
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2015-05-13 15:31 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <55292A69.5020106@icelogic.net>
[not found] ` <1040571428797306@web8j.yandex.ru>
2015-04-14 7:40 ` [PATCH] Introduce an ability to specify microseconds bus scanning intervals in w1 core Dmitry Khromov
2015-04-14 17:15 ` Randy Dunlap
2015-04-22 21:55 ` [PATCH v2] w1: introduce an ability to specify microseconds bus scanning intervals Dmitry Khromov
2015-04-22 23:22 ` Evgeniy Polyakov
2015-04-23 9:20 ` Greg KH
2015-04-23 11:30 ` Dmitry Khromov
2015-04-23 11:33 ` [PATCH v3] " Dmitry Khromov
2015-05-12 19:29 ` Dmitry Khromov
2015-05-13 15:00 ` Evgeniy Polyakov
2015-05-13 15:31 ` gregkh
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.