1/* 2 * ko_adapt.h 3 * 4 * function for find symbols not exported 5 * 6 * Copyright (C) 2022 Huawei Technologies Co., Ltd. 7 * 8 * This software is licensed under the terms of the GNU General Public 9 * License version 2, as published by the Free Software Foundation, and 10 * may be copied, distributed, and modified under those terms. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 */ 17 18#ifndef KO_ADAPT_H 19#define KO_ADAPT_H 20 21#include <linux/types.h> 22#include <linux/cred.h> 23#include <linux/version.h> 24#if (KERNEL_VERSION(4, 14, 0) <= LINUX_VERSION_CODE) 25#include <linux/sched/task.h> 26#endif 27#include <linux/kthread.h> 28#include <linux/cpumask.h> 29#include <linux/syscalls.h> 30#include <linux/version.h> 31#include <linux/gfp.h> 32 33#ifdef CONFIG_TZDRIVER_MODULE 34 35const struct cred *koadpt_get_task_cred(struct task_struct *task); 36void koadpt_kthread_bind_mask(struct task_struct *task, 37 const struct cpumask *mask); 38struct page *koadpt_alloc_pages(gfp_t gfp_mask, unsigned int order); 39struct workqueue_attrs *koadpt_alloc_workqueue_attrs(gfp_t gfp_mask); 40void koadpt_free_workqueue_attrs(struct workqueue_attrs *attrs); 41 42#else 43 44static inline const struct cred *koadpt_get_task_cred(struct task_struct *task) 45{ 46 return get_task_cred(task); 47} 48 49static inline void koadpt_kthread_bind_mask(struct task_struct *task, 50 const struct cpumask *mask) 51{ 52 kthread_bind_mask(task, mask); 53} 54 55static inline struct page *koadpt_alloc_pages(gfp_t gfp_mask, unsigned int order) 56{ 57 return alloc_pages(gfp_mask, order); 58} 59 60static inline struct workqueue_attrs *koadpt_alloc_workqueue_attrs( 61 gfp_t gfp_mask) 62{ 63#if (LINUX_VERSION_CODE <= KERNEL_VERSION(4, 19, 0)) 64 return alloc_workqueue_attrs(gfp_mask); 65#else 66 (void)gfp_mask; 67 return alloc_workqueue_attrs(); 68#endif 69} 70 71static inline void koadpt_free_workqueue_attrs(struct workqueue_attrs *attrs) 72{ 73 return free_workqueue_attrs(attrs); 74} 75 76#endif 77 78#endif 79