Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 2676
b: refs/heads/master
c: 2a9d0c1
h: refs/heads/master
v: v3
  • Loading branch information
Evgeniy Polyakov authored and Greg Kroah-Hartman committed Jun 22, 2005
1 parent 7ebaf79 commit 55aeabf
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 2 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 6b729861831177b270a2932a13e79cb41d673146
refs/heads/master: 2a9d0c178158da4a9bcf22311a414c26a8102d13
50 changes: 49 additions & 1 deletion trunk/drivers/w1/w1.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,39 @@ static ssize_t w1_master_attribute_show_name(struct device *dev, struct device_a
return count;
}

static ssize_t w1_master_attribute_store_search(struct device * dev,
struct device_attribute *attr,
const char * buf, size_t count)
{
struct w1_master *md = container_of(dev, struct w1_master, dev);

if (down_interruptible (&md->mutex))
return -EBUSY;

md->search_count = simple_strtol(buf, NULL, 0);

up(&md->mutex);

return count;
}

static ssize_t w1_master_attribute_show_search(struct device *dev,
struct device_attribute *attr,
char *buf)
{
struct w1_master *md = container_of(dev, struct w1_master, dev);
ssize_t count;

if (down_interruptible (&md->mutex))
return -EBUSY;

count = sprintf(buf, "%d\n", md->search_count);

up(&md->mutex);

return count;
}

static ssize_t w1_master_attribute_show_pointer(struct device *dev, struct device_attribute *attr, char *buf)
{
struct w1_master *md = container_of(dev, struct w1_master, dev);
Expand Down Expand Up @@ -242,13 +275,20 @@ static ssize_t w1_master_attribute_show_slaves(struct device *dev, struct device
__ATTR(w1_master_##_name, _mode, \
w1_master_attribute_show_##_name, NULL)

#define W1_MASTER_ATTR_RW(_name, _mode) \
struct device_attribute w1_master_attribute_##_name = \
__ATTR(w1_master_##_name, _mode, \
w1_master_attribute_show_##_name, \
w1_master_attribute_store_##_name)

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_RO(attempts, S_IRUGO);
static W1_MASTER_ATTR_RO(timeout, S_IRUGO);
static W1_MASTER_ATTR_RO(pointer, S_IRUGO);
static W1_MASTER_ATTR_RW(search, S_IRUGO | S_IWUGO);

static struct attribute *w1_master_default_attrs[] = {
&w1_master_attribute_name.attr,
Expand All @@ -258,6 +298,7 @@ static struct attribute *w1_master_default_attrs[] = {
&w1_master_attribute_attempts.attr,
&w1_master_attribute_timeout.attr,
&w1_master_attribute_pointer.attr,
&w1_master_attribute_search.attr,
NULL
};

Expand Down Expand Up @@ -643,11 +684,14 @@ int w1_process(void *data)
if (!dev->initialized)
continue;

if (dev->search_count == 0)
continue;

if (down_interruptible(&dev->mutex))
continue;

list_for_each_entry(sl, &dev->slist, w1_slave_entry)
clear_bit(W1_SLAVE_ACTIVE, (long *)&sl->flags);
clear_bit(W1_SLAVE_ACTIVE, (long *)&sl->flags);

w1_search_devices(dev, w1_slave_found);

Expand All @@ -662,6 +706,10 @@ int w1_process(void *data)
} else if (test_bit(W1_SLAVE_ACTIVE, (unsigned long *)&sl->flags))
sl->ttl = dev->slave_ttl;
}

if (dev->search_count > 0)
dev->search_count--;

up(&dev->mutex);
}

Expand Down
1 change: 1 addition & 0 deletions trunk/drivers/w1/w1.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ struct w1_master
int slave_ttl;
int initialized;
u32 id;
int search_count;

atomic_t refcnt;

Expand Down
1 change: 1 addition & 0 deletions trunk/drivers/w1/w1_int.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ static struct w1_master * w1_alloc_dev(u32 id, int slave_count, int slave_ttl,
dev->initialized = 0;
dev->id = id;
dev->slave_ttl = slave_ttl;
dev->search_count = -1; /* continual scan */

atomic_set(&dev->refcnt, 2);

Expand Down

0 comments on commit 55aeabf

Please sign in to comment.