lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:	Tue, 14 Apr 2015 10:40:55 +0300
From:	Dmitry Khromov <dk@...logic.net>
To:	linux-kernel@...r.kernel.org
CC:	gregkh@...uxfoundation.org, Evgeniy Polyakov <zbr@...emap.net>
Subject: [PATCH] Introduce an ability to specify microseconds bus
 scanning intervals in w1 core

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@...logic.net>
Acked-by: Evgeniy Polyakov <zbr@...emap.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@...emap.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;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ