[PATCH 6/35] W1: w1_process, block when there's nothing to do

From: David Fries
Date: Fri Mar 28 2008 - 08:52:25 EST


w1.c 1.10
Instead of sleeping with a timeout, it will now sleep with a timeout
only when there is an active bus search. When the search is not
active it will block until something wakes it up. kthread_stop and
changing the search_count will wake up the thread. Now if the search
value is changed (to request a new search) it will wake up and do the
search immediately, rather than waiting for the end of the current
timeout.

Signed-off-by: David Fries <david@xxxxxxxxx>
---
drivers/w1/w1.c | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c
index 7dd34f2..5d8c2c7 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,
mutex_lock(&md->mutex);
md->search_count = simple_strtol(buf, NULL, 0);
mutex_unlock(&md->mutex);
+ wake_up_process(md->thread);

return count;
}
@@ -828,7 +829,11 @@ int w1_process(void *data)
if(kthread_should_stop())
break;

- schedule_timeout(jtime);
+ /* Only sleep when the search is active. */
+ if(dev->search_count)
+ schedule_timeout(jtime);
+ else
+ schedule();
}

atomic_dec(&dev->refcnt);
--
1.4.4.4

Attachment: pgp00000.pgp
Description: PGP signature