diff options
author | Tejun Heo <tj@kernel.org> | 2010-06-29 04:07:09 -0400 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2010-06-29 04:07:09 -0400 |
commit | 82805ab77d25643f579d90397dcd34f05d1b750a (patch) | |
tree | 4e5fd250d8625e032250fd02101c3b6ce595cbbf /kernel | |
parent | 7bc465605ffa90b281d6b774fcb13911636a6d45 (diff) |
kthread: implement kthread_data()
Implement kthread_data() which takes @task pointing to a kthread and
returns @data specified when creating the kthread. The caller is
responsible for ensuring the validity of @task when calling this
function.
Signed-off-by: Tejun Heo <tj@kernel.org>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/kthread.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/kernel/kthread.c b/kernel/kthread.c index 8b63c7fee73..2dc3786349d 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 | ||