diff options
Diffstat (limited to 'drivers/gpu/nvgpu/common/linux')
-rw-r--r-- | drivers/gpu/nvgpu/common/linux/thread.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/drivers/gpu/nvgpu/common/linux/thread.c b/drivers/gpu/nvgpu/common/linux/thread.c new file mode 100644 index 00000000..d37b2a10 --- /dev/null +++ b/drivers/gpu/nvgpu/common/linux/thread.c | |||
@@ -0,0 +1,42 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved. | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify it | ||
5 | * under the terms and conditions of the GNU General Public License, | ||
6 | * version 2, as published by the Free Software Foundation. | ||
7 | * | ||
8 | * This program is distributed in the hope it will be useful, but WITHOUT | ||
9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
11 | * more details. | ||
12 | * | ||
13 | * You should have received a copy of the GNU General Public License | ||
14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
15 | */ | ||
16 | |||
17 | #include <linux/kthread.h> | ||
18 | |||
19 | #include <nvgpu/thread.h> | ||
20 | |||
21 | int nvgpu_thread_create(struct nvgpu_thread *thread, | ||
22 | void *data, | ||
23 | int (*threadfn)(void *data), const char *name) | ||
24 | { | ||
25 | struct task_struct *task = kthread_create(threadfn, data, name); | ||
26 | if (IS_ERR(task)) | ||
27 | return PTR_ERR(task); | ||
28 | |||
29 | thread->task = task; | ||
30 | wake_up_process(task); | ||
31 | return 0; | ||
32 | }; | ||
33 | |||
34 | void nvgpu_thread_stop(struct nvgpu_thread *thread) | ||
35 | { | ||
36 | kthread_stop(thread->task); | ||
37 | }; | ||
38 | |||
39 | bool nvgpu_thread_should_stop(struct nvgpu_thread *thread) | ||
40 | { | ||
41 | return kthread_should_stop(); | ||
42 | }; | ||