public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dtor_core@ameritech.net>
To: sensors@Stimpy.netroedge.com
Cc: LKML <linux-kernel@vger.kernel.org>, Greg KH <gregkh@suse.de>,
	Evgeniy Polyakov <johnpol@2ka.mipt.ru>
Subject: [RFC/PATCH 14/22] W1: rename timeout to scan_interval
Date: Thu, 21 Apr 2005 02:21:16 -0500	[thread overview]
Message-ID: <200504210221.16881.dtor_core@ameritech.net> (raw)
In-Reply-To: <200504210207.02421.dtor_core@ameritech.net>

W1: more master attributes changes:
    - rename timeout parameter/attribute to scan_interval to better
      reflect its purpose;
    - make scan_timeout be a per-device attribute and allow changing
      it from userspace via sysfs;
    - allow changing max_slave_count it from userspace as well.

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
---

 w1.c |   60 +++++++++++++++++++++++++++++++++++++++++++++++++-----------
 w1.h |    1 +
 2 files changed, 50 insertions(+), 11 deletions(-)

Index: dtor/drivers/w1/w1.c
===================================================================
--- dtor.orig/drivers/w1/w1.c
+++ dtor/drivers/w1/w1.c
@@ -42,11 +42,11 @@ MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Evgeniy Polyakov <johnpol@2ka.mipt.ru>");
 MODULE_DESCRIPTION("Driver for 1-wire Dallas network protocol.");
 
-static int w1_timeout = 10;
+static int w1_scan_interval = 10;
 static int w1_max_slave_count = 10;
 static int w1_max_slave_ttl = 10;
 
-module_param_named(timeout, w1_timeout, int, 0);
+module_param_named(scan_interval, w1_scan_interval, int, 0);
 module_param_named(max_slave_count, w1_max_slave_count, int, 0);
 module_param_named(slave_ttl, w1_max_slave_ttl, int, 0);
 
@@ -357,7 +357,7 @@ static int w1_process(void *data)
 
 	while (!dev->need_exit) {
 		try_to_freeze(PF_FREEZE);
-		msleep_interruptible(w1_timeout * 1000);
+		msleep_interruptible(dev->scan_interval * 1000);
 
 		if (signal_pending(current))
 			flush_signals(current);
@@ -401,33 +401,71 @@ static ssize_t w1_master_attribute_show_
 	return sprintf(buf, "%s\n", master->name);
 }
 
-static ssize_t w1_master_attribute_show_timeout(struct device *dev, char *buf)
+static ssize_t
+w1_master_attribute_show_scan_interval(struct device *dev, char *buf)
 {
-	ssize_t count;
-	count = sprintf(buf, "%d\n", w1_timeout);
-	return count;
+	struct w1_master *master = to_w1_master(dev);
+
+	return sprintf(buf, "%d\n", master->scan_interval);
+}
+
+static ssize_t
+w1_master_attribute_set_scan_interval(struct device *dev, const char *buf,
+				      size_t n)
+{
+	struct w1_master *master = to_w1_master(dev);
+	int interval;
+
+	interval = simple_strtoul(buf, NULL, 10);
+	if (!interval)
+		return -EINVAL;
+
+	master->scan_interval = interval;
+	return 0;
 }
 
-static ssize_t w1_master_attribute_show_max_slave_count(struct device *dev, char *buf)
+static ssize_t
+w1_master_attribute_show_max_slave_count(struct device *dev, char *buf)
 {
 	struct w1_master *master = to_w1_master(dev);
 
 	return sprintf(buf, "%d\n", master->max_slave_count);
 }
 
+static ssize_t
+w1_master_attribute_set_max_slave_count(struct device *dev, const char *buf,
+					size_t n)
+{
+	struct w1_master *master = to_w1_master(dev);
+	int max_count;
+
+	max_count = simple_strtoul(buf, NULL, 10);
+	if (!max_count)
+		return -EINVAL;
+
+	master->max_slave_count = max_count;
+	return 0;
+}
+
 #define W1_MASTER_ATTR_RO(_name, _mode)				\
 	struct device_attribute w1_master_attribute_##_name =	\
 		__ATTR(_name, _mode,				\
 		       w1_master_attribute_show_##_name, NULL)
 
+#define W1_MASTER_ATTR_RW(_name, _mode)				\
+	struct device_attribute w1_master_attribute_##_name =	\
+		__ATTR(_name, _mode,				\
+		       w1_master_attribute_show_##_name,	\
+		       w1_master_attribute_set_##_name)
+
 static W1_MASTER_ATTR_RO(name, S_IRUGO);
-static W1_MASTER_ATTR_RO(max_slave_count, S_IRUGO);
-static W1_MASTER_ATTR_RO(timeout, S_IRUGO);
+static W1_MASTER_ATTR_RW(max_slave_count, S_IWUSR | S_IRUGO);
+static W1_MASTER_ATTR_RW(scan_interval, S_IWUSR | S_IRUGO);
 
 static struct attribute *w1_master_default_attrs[] = {
 	&w1_master_attribute_name.attr,
 	&w1_master_attribute_max_slave_count.attr,
-	&w1_master_attribute_timeout.attr,
+	&w1_master_attribute_scan_interval.attr,
 	NULL
 };
 
Index: dtor/drivers/w1/w1.h
===================================================================
--- dtor.orig/drivers/w1/w1.h
+++ dtor/drivers/w1/w1.h
@@ -107,6 +107,7 @@ struct w1_master
 	struct list_head	slist;
 	int			max_slave_count;
 	int			slave_ttl;
+	int			scan_interval;
 	int			initialized;
 	u32			id;
 

  parent reply	other threads:[~2005-04-21  8:21 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-04-21  7:07 [RFC/PATCH 0/22] W1: sysfs, lifetime and other fixes Dmitry Torokhov
2005-04-21  7:08 ` [RFC/PATCH 1/22] W1: whitespace fixes Dmitry Torokhov
2005-04-21  7:08 ` [RFC/PATCH 2/22] W1: formatting fixes Dmitry Torokhov
2005-04-21  7:09 ` [RFC/PATCH 3/22] W1: use attribute group for master's attributes Dmitry Torokhov
2005-04-21  7:10 ` [RFC/PATCH 4/22] W1: use attribute group for slave's attributes Dmitry Torokhov
2005-04-21  7:11 ` [RFC/PATCH 5/22] W1: list handling cleanup Dmitry Torokhov
2005-04-21  7:13 ` [RFC/PATCH 6/22] W1: drop owner field from master and slave structures Dmitry Torokhov
2005-04-21  7:13 ` [RFC/PATCH 7/22] W1: bus operations cleanup Dmitry Torokhov
2005-04-21  7:15 ` [RFC/PATCH 8/22] W1: merge master code into one file Dmitry Torokhov
2005-04-21  7:16 ` [RFC/PATCH 9/22] W1: drop custom hotplug over netlink notification Dmitry Torokhov
2005-04-21  7:17 ` [RFC/PATCH 10/22] W1: drop main control thread Dmitry Torokhov
2005-04-21  7:18 ` [RFC/PATCH 11/22] W1: move w1_search to the rest of IO code Dmitry Torokhov
2005-04-21  7:19 ` [RFC/PATCH 12/22] W1: drop unneeded master attributes Dmitry Torokhov
2005-04-21  7:20 ` [RFC/PATCH 13/22] W1: cleanup master attributes handling Dmitry Torokhov
2005-04-21  7:21 ` Dmitry Torokhov [this message]
2005-04-21  7:22 ` [RFC/PATCH 15/22] W1: add slave_ttl master attribute Dmitry Torokhov
2005-04-21  7:23 ` [RFC/PATCH 16/22] W1: cleanup masters refcounting & more Dmitry Torokhov
2005-04-21  7:23 ` [RFC/PATCH 17/22] W1: cleanup slave " Dmitry Torokhov
2005-04-21  7:25 ` [RFC/PATCH 18/22] W1: cleanup family implementation Dmitry Torokhov
2005-04-21  7:26 ` [RFC/PATCH 19/22] W1: convert families to be proper sysfs rivers Dmitry Torokhov
2005-04-21  7:27 ` [RFC/PATCH 20/22] W1: add w1_device_id/MODULE_DEVICE_TABLE for automatic driver loading Dmitry Torokhov
2005-04-21  7:36 ` [RFC/PATCH 21/22] W1: implement standard hotplug handler Dmitry Torokhov
2005-04-21  7:38 ` [RFC/PATCH 22/22] W1: expose module parameters in sysfs Dmitry Torokhov
2005-04-21 13:18 ` [RFC/PATCH 0/22] W1: sysfs, lifetime and other fixes Evgeniy Polyakov
2005-04-21 14:31   ` Dmitry Torokhov
2005-04-25  9:08     ` Evgeniy Polyakov
2005-04-25 16:32       ` Dmitry Torokhov
2005-04-25 19:26         ` Evgeniy Polyakov
2005-04-25 21:32           ` Dmitry Torokhov
2005-04-26  7:19             ` Evgeniy Polyakov
2005-04-25 20:15         ` Evgeniy Polyakov
2005-04-25 20:22           ` Dmitry Torokhov
2005-04-26  6:43             ` Evgeniy Polyakov
2005-04-26  6:50               ` Dmitry Torokhov
2005-04-26  7:06                 ` Evgeniy Polyakov
2005-04-26  7:16                   ` Dmitry Torokhov
2005-04-26  7:35                     ` Evgeniy Polyakov
2005-04-26  7:00               ` Greg KH
2005-04-26  7:17                 ` Evgeniy Polyakov
2005-04-26  6:58         ` Greg KH
2005-04-21 16:09   ` Dmitry Torokhov
2005-04-25  9:11     ` Evgeniy Polyakov
2005-04-25 16:36       ` Dmitry Torokhov
2005-04-25 19:32         ` Evgeniy Polyakov

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=200504210221.16881.dtor_core@ameritech.net \
    --to=dtor_core@ameritech.net \
    --cc=gregkh@suse.de \
    --cc=johnpol@2ka.mipt.ru \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sensors@Stimpy.netroedge.com \
    /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