[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20080328122449.GF3613@spacedout.fries.net>
Date: Fri, 28 Mar 2008 07:24:49 -0500
From: David Fries <david@...es.net>
To: linux-kernel@...r.kernel.org
Cc: Evgeniy Polyakov <johnpol@....mipt.ru>
Subject: [PATCH 5/35] W1: w1_process, remove W1_MASTER_NEED_EXIT, it is redundant
w1.c 1.9
w1.h 1.7
w1_int.c 1.5
Removed W1_MASTER_NEED_EXIT along with the flags variable it used as
they were redundant. The kthread_stop() and kthread_should_stop() do
the same thing and were already being used and checked. I also think
there was a race condition in the current implemention. If
W1_MASTER_NEED_EXIT was set, the w1_process woke up, then exited
because that flag was set before the remove master thread called
kthread_stop, kthread_stop would never return.
Signed-off-by: David Fries <david@...es.net>
---
drivers/w1/w1.c | 6 +++---
drivers/w1/w1.h | 4 ----
drivers/w1/w1_int.c | 2 --
3 files changed, 3 insertions(+), 9 deletions(-)
diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c
index ad89d85..7dd34f2 100644
--- a/drivers/w1/w1.c
+++ b/drivers/w1/w1.c
@@ -772,7 +772,7 @@ void w1_search(struct w1_master *dev, u8 search_type, w1_slave_found_callback cb
tmp64 = (triplet_ret >> 2);
rn |= (tmp64 << i);
- if(test_bit(W1_MASTER_NEED_EXIT, &dev->flags)) {
+ if(kthread_should_stop()) {
printk(KERN_INFO "Abort w1_search (exiting)\n");
return;
}
@@ -815,7 +815,7 @@ int w1_process(void *data)
*/
const unsigned long jtime=msecs_to_jiffies(w1_timeout * 1000);
- while (!kthread_should_stop() && !test_bit(W1_MASTER_NEED_EXIT, &dev->flags)) {
+ while (!kthread_should_stop()) {
if(dev->search_count) {
mutex_lock(&dev->mutex);
w1_search_process(dev, W1_SEARCH);
@@ -825,7 +825,7 @@ int w1_process(void *data)
try_to_freeze();
__set_current_state(TASK_INTERRUPTIBLE);
- if(kthread_should_stop() || test_bit(W1_MASTER_NEED_EXIT, &dev->flags))
+ if(kthread_should_stop())
break;
schedule_timeout(jtime);
diff --git a/drivers/w1/w1.h b/drivers/w1/w1.h
index 1533cb3..c47ca1e 100644
--- a/drivers/w1/w1.h
+++ b/drivers/w1/w1.h
@@ -149,8 +149,6 @@ struct w1_bus_master
u8, w1_slave_found_callback);
};
-#define W1_MASTER_NEED_EXIT 0
-
struct w1_master
{
struct list_head w1_master_entry;
@@ -169,8 +167,6 @@ struct w1_master
void *priv;
int priv_size;
- long flags;
-
struct task_struct *thread;
struct mutex mutex;
diff --git a/drivers/w1/w1_int.c b/drivers/w1/w1_int.c
index bb6cbbe..3388d8f 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)
#if 0 /* Thread cleanup code, not required currently. */
err_out_kill_thread:
- set_bit(W1_MASTER_NEED_EXIT, &dev->flags);
kthread_stop(dev->thread);
#endif
err_out_rm_attr:
@@ -158,7 +157,6 @@ void __w1_remove_master_device(struct w1_master *dev)
struct w1_netlink_msg msg;
struct w1_slave *sl, *sln;
- set_bit(W1_MASTER_NEED_EXIT, &dev->flags);
kthread_stop(dev->thread);
mutex_lock(&w1_mlock);
--
1.4.4.4
Content of type "application/pgp-signature" skipped
Powered by blists - more mailing lists