diff options
author | David Fries <david@fries.net> | 2008-10-15 22:04:40 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-10-16 11:21:49 -0700 |
commit | 01e14d6db9654be005a0a5384090aea2cde39976 (patch) | |
tree | 9db896b843f763a17d97105fbcef597367d50395 /drivers/w1/w1_int.c | |
parent | 0d671b272af9eb06260ab3fd210d454e98dd4216 (diff) | |
download | linux-01e14d6db9654be005a0a5384090aea2cde39976.tar.bz2 |
W1: don't delay search start
Move the creation of the w1_process thread to after the device has been
initialized. This way w1_process doesn't have to check to see if it has
been initialized and the bus search can proceed without sleeping. That
also eliminates two checks in the w1_process loop. The sleep now happens
at the end of the loop not the beginning.
Also added a comment for why the atomic_set was 2.
Signed-off-by: David Fries <david@fries.net>
Signed-off-by: Evgeniy Polyakov <johnpol@2ka.mipt.ru>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/w1/w1_int.c')
-rw-r--r-- | drivers/w1/w1_int.c | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/drivers/w1/w1_int.c b/drivers/w1/w1_int.c index ed3228017dad..36ff40250b61 100644 --- a/drivers/w1/w1_int.c +++ b/drivers/w1/w1_int.c @@ -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); @@ -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); @@ -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); |