aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEvgeniy Polyakov <johnpol@2ka.mipt.ru>2005-06-03 17:31:02 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2005-06-22 00:43:11 -0400
commit2a9d0c178158da4a9bcf22311a414c26a8102d13 (patch)
tree7039be0c9767193b1046d737686bb00c8dbf64d3
parent6b729861831177b270a2932a13e79cb41d673146 (diff)
[PATCH] w1: Adds a sysfs entry (w1_master_search) that allows you to disable/enable periodic searches.
Adds a sysfs entry (w1_master_search) that allows you to disable/enable periodic searches. Signed-off-by: Ben Gardner <bgardner@wabtec.com> Signed-off-by: Evgeniy Polyakov <johnpol@2ka.mipt.ru> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r--drivers/w1/w1.c50
-rw-r--r--drivers/w1/w1.h1
-rw-r--r--drivers/w1/w1_int.c1
3 files changed, 51 insertions, 1 deletions
diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c
index 4fa959f08554..48da17596d43 100644
--- a/drivers/w1/w1.c
+++ b/drivers/w1/w1.c
@@ -148,6 +148,39 @@ static ssize_t w1_master_attribute_show_name(struct device *dev, struct device_a
148 return count; 148 return count;
149} 149}
150 150
151static ssize_t w1_master_attribute_store_search(struct device * dev,
152 struct device_attribute *attr,
153 const char * buf, size_t count)
154{
155 struct w1_master *md = container_of(dev, struct w1_master, dev);
156
157 if (down_interruptible (&md->mutex))
158 return -EBUSY;
159
160 md->search_count = simple_strtol(buf, NULL, 0);
161
162 up(&md->mutex);
163
164 return count;
165}
166
167static ssize_t w1_master_attribute_show_search(struct device *dev,
168 struct device_attribute *attr,
169 char *buf)
170{
171 struct w1_master *md = container_of(dev, struct w1_master, dev);
172 ssize_t count;
173
174 if (down_interruptible (&md->mutex))
175 return -EBUSY;
176
177 count = sprintf(buf, "%d\n", md->search_count);
178
179 up(&md->mutex);
180
181 return count;
182}
183
151static ssize_t w1_master_attribute_show_pointer(struct device *dev, struct device_attribute *attr, char *buf) 184static ssize_t w1_master_attribute_show_pointer(struct device *dev, struct device_attribute *attr, char *buf)
152{ 185{
153 struct w1_master *md = container_of(dev, struct w1_master, dev); 186 struct w1_master *md = container_of(dev, struct w1_master, dev);
@@ -242,6 +275,12 @@ static ssize_t w1_master_attribute_show_slaves(struct device *dev, struct device
242 __ATTR(w1_master_##_name, _mode, \ 275 __ATTR(w1_master_##_name, _mode, \
243 w1_master_attribute_show_##_name, NULL) 276 w1_master_attribute_show_##_name, NULL)
244 277
278#define W1_MASTER_ATTR_RW(_name, _mode) \
279 struct device_attribute w1_master_attribute_##_name = \
280 __ATTR(w1_master_##_name, _mode, \
281 w1_master_attribute_show_##_name, \
282 w1_master_attribute_store_##_name)
283
245static W1_MASTER_ATTR_RO(name, S_IRUGO); 284static W1_MASTER_ATTR_RO(name, S_IRUGO);
246static W1_MASTER_ATTR_RO(slaves, S_IRUGO); 285static W1_MASTER_ATTR_RO(slaves, S_IRUGO);
247static W1_MASTER_ATTR_RO(slave_count, S_IRUGO); 286static W1_MASTER_ATTR_RO(slave_count, S_IRUGO);
@@ -249,6 +288,7 @@ static W1_MASTER_ATTR_RO(max_slave_count, S_IRUGO);
249static W1_MASTER_ATTR_RO(attempts, S_IRUGO); 288static W1_MASTER_ATTR_RO(attempts, S_IRUGO);
250static W1_MASTER_ATTR_RO(timeout, S_IRUGO); 289static W1_MASTER_ATTR_RO(timeout, S_IRUGO);
251static W1_MASTER_ATTR_RO(pointer, S_IRUGO); 290static W1_MASTER_ATTR_RO(pointer, S_IRUGO);
291static W1_MASTER_ATTR_RW(search, S_IRUGO | S_IWUGO);
252 292
253static struct attribute *w1_master_default_attrs[] = { 293static struct attribute *w1_master_default_attrs[] = {
254 &w1_master_attribute_name.attr, 294 &w1_master_attribute_name.attr,
@@ -258,6 +298,7 @@ static struct attribute *w1_master_default_attrs[] = {
258 &w1_master_attribute_attempts.attr, 298 &w1_master_attribute_attempts.attr,
259 &w1_master_attribute_timeout.attr, 299 &w1_master_attribute_timeout.attr,
260 &w1_master_attribute_pointer.attr, 300 &w1_master_attribute_pointer.attr,
301 &w1_master_attribute_search.attr,
261 NULL 302 NULL
262}; 303};
263 304
@@ -643,11 +684,14 @@ int w1_process(void *data)
643 if (!dev->initialized) 684 if (!dev->initialized)
644 continue; 685 continue;
645 686
687 if (dev->search_count == 0)
688 continue;
689
646 if (down_interruptible(&dev->mutex)) 690 if (down_interruptible(&dev->mutex))
647 continue; 691 continue;
648 692
649 list_for_each_entry(sl, &dev->slist, w1_slave_entry) 693 list_for_each_entry(sl, &dev->slist, w1_slave_entry)
650 clear_bit(W1_SLAVE_ACTIVE, (long *)&sl->flags); 694 clear_bit(W1_SLAVE_ACTIVE, (long *)&sl->flags);
651 695
652 w1_search_devices(dev, w1_slave_found); 696 w1_search_devices(dev, w1_slave_found);
653 697
@@ -662,6 +706,10 @@ int w1_process(void *data)
662 } else if (test_bit(W1_SLAVE_ACTIVE, (unsigned long *)&sl->flags)) 706 } else if (test_bit(W1_SLAVE_ACTIVE, (unsigned long *)&sl->flags))
663 sl->ttl = dev->slave_ttl; 707 sl->ttl = dev->slave_ttl;
664 } 708 }
709
710 if (dev->search_count > 0)
711 dev->search_count--;
712
665 up(&dev->mutex); 713 up(&dev->mutex);
666 } 714 }
667 715
diff --git a/drivers/w1/w1.h b/drivers/w1/w1.h
index 3cfdd08d32fc..6b5f7be50b8a 100644
--- a/drivers/w1/w1.h
+++ b/drivers/w1/w1.h
@@ -162,6 +162,7 @@ struct w1_master
162 int slave_ttl; 162 int slave_ttl;
163 int initialized; 163 int initialized;
164 u32 id; 164 u32 id;
165 int search_count;
165 166
166 atomic_t refcnt; 167 atomic_t refcnt;
167 168
diff --git a/drivers/w1/w1_int.c b/drivers/w1/w1_int.c
index 280f140ae698..cf18f1324f03 100644
--- a/drivers/w1/w1_int.c
+++ b/drivers/w1/w1_int.c
@@ -69,6 +69,7 @@ static struct w1_master * w1_alloc_dev(u32 id, int slave_count, int slave_ttl,
69 dev->initialized = 0; 69 dev->initialized = 0;
70 dev->id = id; 70 dev->id = id;
71 dev->slave_ttl = slave_ttl; 71 dev->slave_ttl = slave_ttl;
72 dev->search_count = -1; /* continual scan */
72 73
73 atomic_set(&dev->refcnt, 2); 74 atomic_set(&dev->refcnt, 2);
74 75