summaryrefslogtreecommitdiff
path: root/include/linux/module.h
blob: 1dce3f7c47d84d15a06398110e8a48e10facdc61 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#ifndef _LINUX_MODULE_H
#define _LINUX_MODULE_H

#include <linux/stat.h>
#include <linux/compiler.h>
#include <linux/export.h>

struct module;

#define module_init(initfn)					\
	__attribute__((constructor(120)))			\
	static void __call_##initfn(void) { BUG_ON(initfn()); }

#if 0
#define module_exit(exitfn)					\
	__attribute__((destructor(109)))			\
	static void __call_##exitfn(void) { exitfn(); }
#endif

#define module_exit(exitfn)					\
	__attribute__((unused))					\
	static void __call_##exitfn(void) { exitfn(); }

#define MODULE_INFO(tag, info)
#define MODULE_ALIAS(_alias)
#define MODULE_SOFTDEP(_softdep)
#define MODULE_LICENSE(_license)
#define MODULE_AUTHOR(_author)
#define MODULE_DESCRIPTION(_description)
#define MODULE_VERSION(_version)

static inline void __module_get(struct module *module)
{
}

static inline int try_module_get(struct module *module)
{
	return 1;
}

static inline void module_put(struct module *module)
{
}

#define module_param_named(name, value, type, perm)
#define MODULE_PARM_DESC(_parm, desc)

#define __MODULE_PARM_TYPE(name, _type)
#define module_param_cb(name, ops, arg, perm)

struct kernel_param;

enum {
	KERNEL_PARAM_OPS_FL_NOARG = (1 << 0)
};

struct kernel_param_ops {
	/* How the ops should behave */
	unsigned int flags;
	/* Returns 0, or -errno.  arg is in kp->arg. */
	int (*set)(const char *val, const struct kernel_param *kp);
	/* Returns length written or -errno.  Buffer is 4k (ie. be short!) */
	int (*get)(char *buffer, const struct kernel_param *kp);
	/* Optional function to free kp->arg when module unloaded. */
	void (*free)(void *arg);
};

struct kernel_param {
	const char *name;
	struct module *mod;
	const struct kernel_param_ops *ops;
	const u16 perm;
	s8 level;
	u8 flags;
	union {
		void *arg;
		const struct kparam_string *str;
		const struct kparam_array *arr;
	};
};

extern int param_set_bool(const char *val, const struct kernel_param *kp);

#endif /* _LINUX_MODULE_H */