1419b0af8Sopenharmony_ci/*
2419b0af8Sopenharmony_ci * ko_adapt.h
3419b0af8Sopenharmony_ci *
4419b0af8Sopenharmony_ci * function for find symbols not exported
5419b0af8Sopenharmony_ci *
6419b0af8Sopenharmony_ci * Copyright (C) 2022 Huawei Technologies Co., Ltd.
7419b0af8Sopenharmony_ci *
8419b0af8Sopenharmony_ci * This software is licensed under the terms of the GNU General Public
9419b0af8Sopenharmony_ci * License version 2, as published by the Free Software Foundation, and
10419b0af8Sopenharmony_ci * may be copied, distributed, and modified under those terms.
11419b0af8Sopenharmony_ci *
12419b0af8Sopenharmony_ci * This program is distributed in the hope that it will be useful,
13419b0af8Sopenharmony_ci * but WITHOUT ANY WARRANTY; without even the implied warranty of
14419b0af8Sopenharmony_ci * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15419b0af8Sopenharmony_ci * GNU General Public License for more details.
16419b0af8Sopenharmony_ci */
17419b0af8Sopenharmony_ci
18419b0af8Sopenharmony_ci#ifndef KO_ADAPT_H
19419b0af8Sopenharmony_ci#define KO_ADAPT_H
20419b0af8Sopenharmony_ci
21419b0af8Sopenharmony_ci#include <linux/types.h>
22419b0af8Sopenharmony_ci#include <linux/cred.h>
23419b0af8Sopenharmony_ci#include <linux/version.h>
24419b0af8Sopenharmony_ci#if (KERNEL_VERSION(4, 14, 0) <= LINUX_VERSION_CODE)
25419b0af8Sopenharmony_ci#include <linux/sched/task.h>
26419b0af8Sopenharmony_ci#endif
27419b0af8Sopenharmony_ci#include <linux/kthread.h>
28419b0af8Sopenharmony_ci#include <linux/cpumask.h>
29419b0af8Sopenharmony_ci#include <linux/syscalls.h>
30419b0af8Sopenharmony_ci#include <linux/version.h>
31419b0af8Sopenharmony_ci#include <linux/gfp.h>
32419b0af8Sopenharmony_ci
33419b0af8Sopenharmony_ci#ifdef CONFIG_TZDRIVER_MODULE
34419b0af8Sopenharmony_ci
35419b0af8Sopenharmony_ciconst struct cred *koadpt_get_task_cred(struct task_struct *task);
36419b0af8Sopenharmony_civoid koadpt_kthread_bind_mask(struct task_struct *task,
37419b0af8Sopenharmony_ci	const struct cpumask *mask);
38419b0af8Sopenharmony_cistruct page *koadpt_alloc_pages(gfp_t gfp_mask, unsigned int order);
39419b0af8Sopenharmony_cistruct workqueue_attrs *koadpt_alloc_workqueue_attrs(gfp_t gfp_mask);
40419b0af8Sopenharmony_civoid koadpt_free_workqueue_attrs(struct workqueue_attrs *attrs);
41419b0af8Sopenharmony_ci
42419b0af8Sopenharmony_ci#else
43419b0af8Sopenharmony_ci
44419b0af8Sopenharmony_cistatic inline const struct cred *koadpt_get_task_cred(struct task_struct *task)
45419b0af8Sopenharmony_ci{
46419b0af8Sopenharmony_ci	return get_task_cred(task);
47419b0af8Sopenharmony_ci}
48419b0af8Sopenharmony_ci
49419b0af8Sopenharmony_cistatic inline void koadpt_kthread_bind_mask(struct task_struct *task,
50419b0af8Sopenharmony_ci	const struct cpumask *mask)
51419b0af8Sopenharmony_ci{
52419b0af8Sopenharmony_ci	kthread_bind_mask(task, mask);
53419b0af8Sopenharmony_ci}
54419b0af8Sopenharmony_ci
55419b0af8Sopenharmony_cistatic inline struct page *koadpt_alloc_pages(gfp_t gfp_mask, unsigned int order)
56419b0af8Sopenharmony_ci{
57419b0af8Sopenharmony_ci	return alloc_pages(gfp_mask, order);
58419b0af8Sopenharmony_ci}
59419b0af8Sopenharmony_ci
60419b0af8Sopenharmony_cistatic inline struct workqueue_attrs *koadpt_alloc_workqueue_attrs(
61419b0af8Sopenharmony_ci	gfp_t gfp_mask)
62419b0af8Sopenharmony_ci{
63419b0af8Sopenharmony_ci#if (LINUX_VERSION_CODE <= KERNEL_VERSION(4, 19, 0))
64419b0af8Sopenharmony_ci	return alloc_workqueue_attrs(gfp_mask);
65419b0af8Sopenharmony_ci#else
66419b0af8Sopenharmony_ci	(void)gfp_mask;
67419b0af8Sopenharmony_ci	return alloc_workqueue_attrs();
68419b0af8Sopenharmony_ci#endif
69419b0af8Sopenharmony_ci}
70419b0af8Sopenharmony_ci
71419b0af8Sopenharmony_cistatic inline void koadpt_free_workqueue_attrs(struct workqueue_attrs *attrs)
72419b0af8Sopenharmony_ci{
73419b0af8Sopenharmony_ci	return free_workqueue_attrs(attrs);
74419b0af8Sopenharmony_ci}
75419b0af8Sopenharmony_ci
76419b0af8Sopenharmony_ci#endif
77419b0af8Sopenharmony_ci
78419b0af8Sopenharmony_ci#endif
79