aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/w1/w1.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/w1/w1.c')
-rw-r--r--drivers/w1/w1.c20
1 files changed, 17 insertions, 3 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);