Merge branch 'for-linus' of git://one.firstfloor.org/home/andi/git/linux-2.6
[pandora-kernel.git] / kernel / kthread.c
index 24be714..87c50cc 100644 (file)
@@ -31,6 +31,8 @@ struct kthread_create_info
        /* Result passed back to kthread_create() from keventd. */
        struct task_struct *result;
        struct completion done;
+
+       struct work_struct work;
 };
 
 struct kthread_stop_info
@@ -48,7 +50,7 @@ static struct kthread_stop_info kthread_stop_info;
 /**
  * kthread_should_stop - should this kthread return now?
  *
- * When someone calls kthread_stop on your kthread, it will be woken
+ * When someone calls kthread_stop() on your kthread, it will be woken
  * and this will return true.  You should then return, and your return
  * value will be passed through to kthread_stop().
  */
@@ -111,9 +113,10 @@ static int kthread(void *_create)
 }
 
 /* We are keventd: create a thread. */
-static void keventd_create_kthread(void *_create)
+static void keventd_create_kthread(struct work_struct *work)
 {
-       struct kthread_create_info *create = _create;
+       struct kthread_create_info *create =
+               container_of(work, struct kthread_create_info, work);
        int pid;
 
        /* We want our own signal handler (we take no signals by default). */
@@ -140,7 +143,7 @@ static void keventd_create_kthread(void *_create)
  * it.  See also kthread_run(), kthread_create_on_cpu().
  *
  * When woken, the thread will run @threadfn() with @data as its
- * argument. @threadfn can either call do_exit() directly if it is a
+ * argument. @threadfn() can either call do_exit() directly if it is a
  * standalone thread for which noone will call kthread_stop(), or
  * return when 'kthread_should_stop()' is true (which means
  * kthread_stop() has been called).  The return value should be zero
@@ -154,20 +157,20 @@ struct task_struct *kthread_create(int (*threadfn)(void *data),
                                   ...)
 {
        struct kthread_create_info create;
-       DECLARE_WORK(work, keventd_create_kthread, &create);
 
        create.threadfn = threadfn;
        create.data = data;
        init_completion(&create.started);
        init_completion(&create.done);
+       INIT_WORK(&create.work, keventd_create_kthread);
 
        /*
         * The workqueue needs to start up first:
         */
        if (!helper_wq)
-               work.func(work.data);
+               create.work.func(&create.work);
        else {
-               queue_work(helper_wq, &work);
+               queue_work(helper_wq, &create.work);
                wait_for_completion(&create.done);
        }
        if (!IS_ERR(create.result)) {
@@ -189,7 +192,7 @@ EXPORT_SYMBOL(kthread_create);
  *
  * Description: This function is equivalent to set_cpus_allowed(),
  * except that @cpu doesn't need to be online, and the thread must be
- * stopped (i.e., just returned from kthread_create().
+ * stopped (i.e., just returned from kthread_create()).
  */
 void kthread_bind(struct task_struct *k, unsigned int cpu)
 {
@@ -215,23 +218,6 @@ EXPORT_SYMBOL(kthread_bind);
  * was never called.
  */
 int kthread_stop(struct task_struct *k)
-{
-       return kthread_stop_sem(k, NULL);
-}
-EXPORT_SYMBOL(kthread_stop);
-
-/**
- * kthread_stop_sem - stop a thread created by kthread_create().
- * @k: thread created by kthread_create().
- * @s: semaphore that @k waits on while idle.
- *
- * Does essentially the same thing as kthread_stop() above, but wakes
- * @k by calling up(@s).
- *
- * Returns the result of threadfn(), or %-EINTR if wake_up_process()
- * was never called.
- */
-int kthread_stop_sem(struct task_struct *k, struct semaphore *s)
 {
        int ret;
 
@@ -246,10 +232,7 @@ int kthread_stop_sem(struct task_struct *k, struct semaphore *s)
 
        /* Now set kthread_should_stop() to true, and wake it up. */
        kthread_stop_info.k = k;
-       if (s)
-               up(s);
-       else
-               wake_up_process(k);
+       wake_up_process(k);
        put_task_struct(k);
 
        /* Once it dies, reset stop ptr, gather result and we're done. */
@@ -260,7 +243,7 @@ int kthread_stop_sem(struct task_struct *k, struct semaphore *s)
 
        return ret;
 }
-EXPORT_SYMBOL(kthread_stop_sem);
+EXPORT_SYMBOL(kthread_stop);
 
 static __init int helper_init(void)
 {