summary refs log tree commit diff
path: root/kernel/kthread.c
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2010-06-29 10:07:09 +0200
committerTejun Heo <tj@kernel.org>2010-06-29 10:07:09 +0200
commit82805ab77d25643f579d90397dcd34f05d1b750a (patch)
tree4e5fd250d8625e032250fd02101c3b6ce595cbbf /kernel/kthread.c
parent7bc465605ffa90b281d6b774fcb13911636a6d45 (diff)
downloadlinux-82805ab77d25643f579d90397dcd34f05d1b750a.tar.gz
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/kthread.c')
-rw-r--r--kernel/kthread.c15
1 files changed, 15 insertions, 0 deletions
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
 
 struct kthread {
 	int should_stop;
+	void *data;
 	struct completion exited;
 };
 
@@ -56,6 +57,19 @@ int kthread_should_stop(void)
 }
 EXPORT_SYMBOL(kthread_should_stop);
 
+/**
+ * kthread_data - return data value specified on kthread creation
+ * @task: kthread task in question
+ *
+ * Return the data value specified when kthread @task was created.
+ * The caller is responsible for ensuring the validity of @task when
+ * calling this function.
+ */
+void *kthread_data(struct task_struct *task)
+{
+	return to_kthread(task)->data;
+}
+
 static int kthread(void *_create)
 {
 	/* Copy data: it's on kthread's stack */
@@ -66,6 +80,7 @@ static int kthread(void *_create)
 	int ret;
 
 	self.should_stop = 0;
+	self.data = data;
 	init_completion(&self.exited);
 	current->vfork_done = &self.exited;