diff options
| -rw-r--r-- | include/linux/kthread.h | 1 | ||||
| -rw-r--r-- | kernel/kthread.c | 15 |
2 files changed, 16 insertions, 0 deletions
diff --git a/include/linux/kthread.h b/include/linux/kthread.h index f93cb6979edc..685ea65eb803 100644 --- a/include/linux/kthread.h +++ b/include/linux/kthread.h | |||
| @@ -30,6 +30,7 @@ struct task_struct *kthread_create(int (*threadfn)(void *data), | |||
| 30 | void kthread_bind(struct task_struct *k, unsigned int cpu); | 30 | void kthread_bind(struct task_struct *k, unsigned int cpu); |
| 31 | int kthread_stop(struct task_struct *k); | 31 | int kthread_stop(struct task_struct *k); |
| 32 | int kthread_should_stop(void); | 32 | int kthread_should_stop(void); |
| 33 | void *kthread_data(struct task_struct *k); | ||
| 33 | 34 | ||
| 34 | int kthreadd(void *unused); | 35 | int kthreadd(void *unused); |
| 35 | extern struct task_struct *kthreadd_task; | 36 | extern struct task_struct *kthreadd_task; |
diff --git a/kernel/kthread.c b/kernel/kthread.c index 8b63c7fee73b..2dc3786349d1 100644 --- a/kernel/kthread.c +++ b/kernel/kthread.c | |||
| @@ -37,6 +37,7 @@ struct kthread_create_info | |||
| 37 | 37 | ||
| 38 | struct kthread { | 38 | struct kthread { |
| 39 | int should_stop; | 39 | int should_stop; |
| 40 | void *data; | ||
| 40 | struct completion exited; | 41 | struct completion exited; |
| 41 | }; | 42 | }; |
| 42 | 43 | ||
| @@ -56,6 +57,19 @@ int kthread_should_stop(void) | |||
| 56 | } | 57 | } |
| 57 | EXPORT_SYMBOL(kthread_should_stop); | 58 | EXPORT_SYMBOL(kthread_should_stop); |
| 58 | 59 | ||
| 60 | /** | ||
| 61 | * kthread_data - return data value specified on kthread creation | ||
| 62 | * @task: kthread task in question | ||
| 63 | * | ||
| 64 | * Return the data value specified when kthread @task was created. | ||
| 65 | * The caller is responsible for ensuring the validity of @task when | ||
| 66 | * calling this function. | ||
| 67 | */ | ||
| 68 | void *kthread_data(struct task_struct *task) | ||
| 69 | { | ||
| 70 | return to_kthread(task)->data; | ||
| 71 | } | ||
| 72 | |||
| 59 | static int kthread(void *_create) | 73 | static int kthread(void *_create) |
| 60 | { | 74 | { |
| 61 | /* Copy data: it's on kthread's stack */ | 75 | /* Copy data: it's on kthread's stack */ |
| @@ -66,6 +80,7 @@ static int kthread(void *_create) | |||
| 66 | int ret; | 80 | int ret; |
| 67 | 81 | ||
| 68 | self.should_stop = 0; | 82 | self.should_stop = 0; |
| 83 | self.data = data; | ||
| 69 | init_completion(&self.exited); | 84 | init_completion(&self.exited); |
| 70 | current->vfork_done = &self.exited; | 85 | current->vfork_done = &self.exited; |
| 71 | 86 | ||
