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 INIT_MODULE_H__
8 #define 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 if ((tst_kvercmp(3, 8, 0)) < 0) {
28 /* Check if the syscall is backported on an older kernel */
29 TEST(syscall(__NR_finit_module, 0, "", 0));
30 if (TST_RET == -1 && TST_ERR == ENOSYS)
31 tst_brk(TCONF, "Test not supported on kernel version < v3.8");
32 }
33 }
34
35 #endif /* INIT_MODULE_H__ */
36