aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/w1
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/w1')
-rw-r--r--drivers/w1/w1.c20
-rw-r--r--drivers/w1/w1.h4
-rw-r--r--drivers/w1/w1_int.c2
3 files changed, 17 insertions, 9 deletions
diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c
index 730faa49d8dc..9b5c11701c37 100644
--- a/drivers/w1/w1.c
+++ b/drivers/w1/w1.c
@@ -251,6 +251,7 @@ static ssize_t w1_master_attribute_store_search(struct device * dev,
251 mutex_lock(&md->mutex); 251 mutex_lock(&md->mutex);
252 md->search_count = simple_strtol(buf, NULL, 0); 252 md->search_count = simple_strtol(buf, NULL, 0);
253 mutex_unlock(&md->mutex); 253 mutex_unlock(&md->mutex);
254 wake_up_process(md->thread);
254 255
255 return count; 256 return count;
256} 257}
@@ -773,7 +774,7 @@ void w1_search(struct w1_master *dev, u8 search_type, w1_slave_found_callback cb
773 tmp64 = (triplet_ret >> 2); 774 tmp64 = (triplet_ret >> 2);
774 rn |= (tmp64 << i); 775 rn |= (tmp64 << i);
775 776
776 if (test_bit(W1_MASTER_NEED_EXIT, &dev->flags)) { 777 if (kthread_should_stop()) {
777 printk(KERN_INFO "Abort w1_search (exiting)\n"); 778 printk(KERN_INFO "Abort w1_search (exiting)\n");
778 return; 779 return;
779 } 780 }
@@ -811,8 +812,12 @@ void w1_search_process(struct w1_master *dev, u8 search_type)
811int w1_process(void *data) 812int w1_process(void *data)
812{ 813{
813 struct w1_master *dev = (struct w1_master *) data; 814 struct w1_master *dev = (struct w1_master *) data;
815 /* As long as w1_timeout is only set by a module parameter the sleep
816 * time can be calculated in jiffies once.
817 */
818 const unsigned long jtime = msecs_to_jiffies(w1_timeout * 1000);
814 819
815 while (!kthread_should_stop() && !test_bit(W1_MASTER_NEED_EXIT, &dev->flags)) { 820 while (!kthread_should_stop()) {
816 if (dev->search_count) { 821 if (dev->search_count) {
817 mutex_lock(&dev->mutex); 822 mutex_lock(&dev->mutex);
818 w1_search_process(dev, W1_SEARCH); 823 w1_search_process(dev, W1_SEARCH);
@@ -820,7 +825,16 @@ int w1_process(void *data)
820 } 825 }
821 826
822 try_to_freeze(); 827 try_to_freeze();
823 msleep_interruptible(w1_timeout * 1000); 828 __set_current_state(TASK_INTERRUPTIBLE);
829
830 if (kthread_should_stop())
831 break;
832
833 /* Only sleep when the search is active. */
834 if (dev->search_count)
835 schedule_timeout(jtime);
836 else
837 schedule();
824 } 838 }
825 839
826 atomic_dec(&dev->refcnt); 840 atomic_dec(&dev->refcnt);
diff --git a/drivers/w1/w1.h b/drivers/w1/w1.h
index 13e0ea880bf8..34ee01e008ad 100644
--- a/drivers/w1/w1.h
+++ b/drivers/w1/w1.h
@@ -149,8 +149,6 @@ struct w1_bus_master
149 u8, w1_slave_found_callback); 149 u8, w1_slave_found_callback);
150}; 150};
151 151
152#define W1_MASTER_NEED_EXIT 0
153
154struct w1_master 152struct w1_master
155{ 153{
156 struct list_head w1_master_entry; 154 struct list_head w1_master_entry;
@@ -169,8 +167,6 @@ struct w1_master
169 void *priv; 167 void *priv;
170 int priv_size; 168 int priv_size;
171 169
172 long flags;
173
174 struct task_struct *thread; 170 struct task_struct *thread;
175 struct mutex mutex; 171 struct mutex mutex;
176 172
diff --git a/drivers/w1/w1_int.c b/drivers/w1/w1_int.c
index 36ff40250b61..bd877b24ce42 100644
--- a/drivers/w1/w1_int.c
+++ b/drivers/w1/w1_int.c
@@ -142,7 +142,6 @@ int w1_add_master_device(struct w1_bus_master *master)
142 142
143#if 0 /* Thread cleanup code, not required currently. */ 143#if 0 /* Thread cleanup code, not required currently. */
144err_out_kill_thread: 144err_out_kill_thread:
145 set_bit(W1_MASTER_NEED_EXIT, &dev->flags);
146 kthread_stop(dev->thread); 145 kthread_stop(dev->thread);
147#endif 146#endif
148err_out_rm_attr: 147err_out_rm_attr:
@@ -158,7 +157,6 @@ void __w1_remove_master_device(struct w1_master *dev)
158 struct w1_netlink_msg msg; 157 struct w1_netlink_msg msg;
159 struct w1_slave *sl, *sln; 158 struct w1_slave *sl, *sln;
160 159
161 set_bit(W1_MASTER_NEED_EXIT, &dev->flags);
162 kthread_stop(dev->thread); 160 kthread_stop(dev->thread);
163 161
164 mutex_lock(&w1_mlock); 162 mutex_lock(&w1_mlock);