diff options
author | David Fries <david@fries.net> | 2008-10-16 01:04:41 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-10-16 14:21:49 -0400 |
commit | 3c52e4e627896b42152cc6ff98216c302932227e (patch) | |
tree | 811992a651418cfcd8a606317e2abae26447b9f9 /drivers/w1/w1.c | |
parent | 01e14d6db9654be005a0a5384090aea2cde39976 (diff) |
W1: w1_process, block or sleep
The w1_process thread's sleeping and termination has been modified.
msleep_interruptible was replaced by schedule_timeout and schedule to
allow for kthread_stop and wake_up_process to interrupt the sleep and the
unbounded sleeping when a bus search is disabled. The W1_MASTER_NEED_EXIT
and flags variable were removed as they were redundant with
kthread_should_stop and kthread_stop. If w1_process is sleeping,
requesting a search will immediately wake it up rather than waiting for
the end of msleep_interruptible previously.
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.c')
-rw-r--r-- | drivers/w1/w1.c | 20 |
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) | |||
811 | int w1_process(void *data) | 812 | int 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); |