aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/w1/w1.c19
-rw-r--r--drivers/w1/w1_int.c26
2 files changed, 23 insertions, 22 deletions
diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c
index aac03f151fe0..730faa49d8dc 100644
--- a/drivers/w1/w1.c
+++ b/drivers/w1/w1.c
@@ -813,21 +813,14 @@ int w1_process(void *data)
813 struct w1_master *dev = (struct w1_master *) data; 813 struct w1_master *dev = (struct w1_master *) data;
814 814
815 while (!kthread_should_stop() && !test_bit(W1_MASTER_NEED_EXIT, &dev->flags)) { 815 while (!kthread_should_stop() && !test_bit(W1_MASTER_NEED_EXIT, &dev->flags)) {
816 if (dev->search_count) {
817 mutex_lock(&dev->mutex);
818 w1_search_process(dev, W1_SEARCH);
819 mutex_unlock(&dev->mutex);
820 }
821
816 try_to_freeze(); 822 try_to_freeze();
817 msleep_interruptible(w1_timeout * 1000); 823 msleep_interruptible(w1_timeout * 1000);
818
819 if (kthread_should_stop() || test_bit(W1_MASTER_NEED_EXIT, &dev->flags))
820 break;
821
822 if (!dev->initialized)
823 continue;
824
825 if (dev->search_count == 0)
826 continue;
827
828 mutex_lock(&dev->mutex);
829 w1_search_process(dev, W1_SEARCH);
830 mutex_unlock(&dev->mutex);
831 } 824 }
832 825
833 atomic_dec(&dev->refcnt); 826 atomic_dec(&dev->refcnt);
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,
61 dev->slave_ttl = slave_ttl; 61 dev->slave_ttl = slave_ttl;
62 dev->search_count = -1; /* continual scan */ 62 dev->search_count = -1; /* continual scan */
63 63
64 /* 1 for w1_process to decrement
65 * 1 for __w1_remove_master_device to decrement
66 */
64 atomic_set(&dev->refcnt, 2); 67 atomic_set(&dev->refcnt, 2);
65 68
66 INIT_LIST_HEAD(&dev->slist); 69 INIT_LIST_HEAD(&dev->slist);
@@ -109,23 +112,23 @@ int w1_add_master_device(struct w1_bus_master *master)
109 if (!dev) 112 if (!dev)
110 return -ENOMEM; 113 return -ENOMEM;
111 114
115 retval = w1_create_master_attributes(dev);
116 if (retval)
117 goto err_out_free_dev;
118
119 memcpy(dev->bus_master, master, sizeof(struct w1_bus_master));
120
121 dev->initialized = 1;
122
112 dev->thread = kthread_run(&w1_process, dev, "%s", dev->name); 123 dev->thread = kthread_run(&w1_process, dev, "%s", dev->name);
113 if (IS_ERR(dev->thread)) { 124 if (IS_ERR(dev->thread)) {
114 retval = PTR_ERR(dev->thread); 125 retval = PTR_ERR(dev->thread);
115 dev_err(&dev->dev, 126 dev_err(&dev->dev,
116 "Failed to create new kernel thread. err=%d\n", 127 "Failed to create new kernel thread. err=%d\n",
117 retval); 128 retval);
118 goto err_out_free_dev; 129 goto err_out_rm_attr;
119 } 130 }
120 131
121 retval = w1_create_master_attributes(dev);
122 if (retval)
123 goto err_out_kill_thread;
124
125 memcpy(dev->bus_master, master, sizeof(struct w1_bus_master));
126
127 dev->initialized = 1;
128
129 mutex_lock(&w1_mlock); 132 mutex_lock(&w1_mlock);
130 list_add(&dev->w1_master_entry, &w1_masters); 133 list_add(&dev->w1_master_entry, &w1_masters);
131 mutex_unlock(&w1_mlock); 134 mutex_unlock(&w1_mlock);
@@ -137,8 +140,13 @@ int w1_add_master_device(struct w1_bus_master *master)
137 140
138 return 0; 141 return 0;
139 142
143#if 0 /* Thread cleanup code, not required currently. */
140err_out_kill_thread: 144err_out_kill_thread:
145 set_bit(W1_MASTER_NEED_EXIT, &dev->flags);
141 kthread_stop(dev->thread); 146 kthread_stop(dev->thread);
147#endif
148err_out_rm_attr:
149 w1_destroy_master_attributes(dev);
142err_out_free_dev: 150err_out_free_dev:
143 w1_free_dev(dev); 151 w1_free_dev(dev);
144 152