Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 114916
b: refs/heads/master
c: 01e14d6
h: refs/heads/master
v: v3
  • Loading branch information
David Fries authored and Linus Torvalds committed Oct 16, 2008
1 parent fa05085 commit 0105f33
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 23 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: 0d671b272af9eb06260ab3fd210d454e98dd4216
refs/heads/master: 01e14d6db9654be005a0a5384090aea2cde39976
19 changes: 6 additions & 13 deletions trunk/drivers/w1/w1.c
Original file line number Diff line number Diff line change
Expand Up @@ -813,21 +813,14 @@ int w1_process(void *data)
struct w1_master *dev = (struct w1_master *) data;

while (!kthread_should_stop() && !test_bit(W1_MASTER_NEED_EXIT, &dev->flags)) {
if (dev->search_count) {
mutex_lock(&dev->mutex);
w1_search_process(dev, W1_SEARCH);
mutex_unlock(&dev->mutex);
}

try_to_freeze();
msleep_interruptible(w1_timeout * 1000);

if (kthread_should_stop() || test_bit(W1_MASTER_NEED_EXIT, &dev->flags))
break;

if (!dev->initialized)
continue;

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

mutex_lock(&dev->mutex);
w1_search_process(dev, W1_SEARCH);
mutex_unlock(&dev->mutex);
}

atomic_dec(&dev->refcnt);
Expand Down
26 changes: 17 additions & 9 deletions trunk/drivers/w1/w1_int.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ static struct w1_master * w1_alloc_dev(u32 id, int slave_count, int slave_ttl,
dev->slave_ttl = slave_ttl;
dev->search_count = -1; /* continual scan */

/* 1 for w1_process to decrement
* 1 for __w1_remove_master_device to decrement
*/
atomic_set(&dev->refcnt, 2);

INIT_LIST_HEAD(&dev->slist);
Expand Down Expand Up @@ -109,23 +112,23 @@ int w1_add_master_device(struct w1_bus_master *master)
if (!dev)
return -ENOMEM;

retval = w1_create_master_attributes(dev);
if (retval)
goto err_out_free_dev;

memcpy(dev->bus_master, master, sizeof(struct w1_bus_master));

dev->initialized = 1;

dev->thread = kthread_run(&w1_process, dev, "%s", dev->name);
if (IS_ERR(dev->thread)) {
retval = PTR_ERR(dev->thread);
dev_err(&dev->dev,
"Failed to create new kernel thread. err=%d\n",
retval);
goto err_out_free_dev;
goto err_out_rm_attr;
}

retval = w1_create_master_attributes(dev);
if (retval)
goto err_out_kill_thread;

memcpy(dev->bus_master, master, sizeof(struct w1_bus_master));

dev->initialized = 1;

mutex_lock(&w1_mlock);
list_add(&dev->w1_master_entry, &w1_masters);
mutex_unlock(&w1_mlock);
Expand All @@ -137,8 +140,13 @@ int w1_add_master_device(struct w1_bus_master *master)

return 0;

#if 0 /* Thread cleanup code, not required currently. */
err_out_kill_thread:
set_bit(W1_MASTER_NEED_EXIT, &dev->flags);
kthread_stop(dev->thread);
#endif
err_out_rm_attr:
w1_destroy_master_attributes(dev);
err_out_free_dev:
w1_free_dev(dev);

Expand Down

0 comments on commit 0105f33

Please sign in to comment.