1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * Copyright (c) 2020 Linaro Limited. All rights reserved.
4 * Author: Viresh Kumar <viresh.kumar@linaro.org>
5 */
6
7 #ifndef LAPI_INIT_MODULE_H__
8 #define LAPI_INIT_MODULE_H__
9
10 #include "config.h"
11 #include "lapi/syscalls.h"
12 #include "tst_test.h"
13
init_module(void * module_image,unsigned long len,const char * param_values)14 static inline int init_module(void *module_image, unsigned long len,
15 const char *param_values)
16 {
17 return tst_syscall(__NR_init_module, module_image, len, param_values);
18 }
19
finit_module(int fd,const char * param_values,int flags)20 static inline int finit_module(int fd, const char *param_values, int flags)
21 {
22 return tst_syscall(__NR_finit_module, fd, param_values, flags);
23 }
24
finit_module_supported_by_kernel(void)25 static inline void finit_module_supported_by_kernel(void)
26 {
27 long ret;
28
29 if ((tst_kvercmp(3, 8, 0)) < 0) {
30 /* Check if the syscall is backported on an older kernel */
31 ret = syscall(__NR_finit_module, 0, "", 0);
32 if (ret == -1 && errno == ENOSYS)
33 tst_brk(TCONF, "Test not supported on kernel version < v3.8");
34 }
35 }
36
37 #endif /* LAPI_INIT_MODULE_H__ */
38