mutex_lock(&md->mutex);
md->search_count = simple_strtol(buf, NULL, 0);
mutex_unlock(&md->mutex);
+ wake_up_process(md->thread);
return count;
}
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;
}
int w1_process(void *data)
{
struct w1_master *dev = (struct w1_master *) data;
+ /* As long as w1_timeout is only set by a module parameter the sleep
+ * time can be calculated in jiffies once.
+ */
+ 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);
}
try_to_freeze();
- msleep_interruptible(w1_timeout * 1000);
+ __set_current_state(TASK_INTERRUPTIBLE);
+
+ if (kthread_should_stop())
+ break;
+
+ /* Only sleep when the search is active. */
+ if (dev->search_count)
+ schedule_timeout(jtime);
+ else
+ schedule();
}
atomic_dec(&dev->refcnt);
u8, w1_slave_found_callback);
};
-#define W1_MASTER_NEED_EXIT 0
-
struct w1_master
{
struct list_head w1_master_entry;
void *priv;
int priv_size;
- long flags;
-
struct task_struct *thread;
struct mutex mutex;
#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:
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);