Rev 5270 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
5270 | serge | 1 | #ifndef _LINUX_MODULE_PARAMS_H |
2 | #define _LINUX_MODULE_PARAMS_H |
||
3 | /* (C) Copyright 2001, 2002 Rusty Russell IBM Corporation */ |
||
4 | #include |
||
6082 | serge | 5 | /** |
6 | * module_param - typesafe helper for a module/cmdline parameter |
||
7 | * @value: the variable to alter, and exposed parameter name. |
||
8 | * @type: the type of the parameter |
||
9 | * @perm: visibility in sysfs. |
||
10 | * |
||
11 | * @value becomes the module parameter, or (prefixed by KBUILD_MODNAME and a |
||
12 | * ".") the kernel commandline parameter. Note that - is changed to _, so |
||
13 | * the user can use "foo-bar=1" even for variable "foo_bar". |
||
14 | * |
||
15 | * @perm is 0 if the the variable is not to appear in sysfs, or 0444 |
||
16 | * for world-readable, 0644 for root-writable, etc. Note that if it |
||
17 | * is writable, you may need to use kernel_param_lock() around |
||
18 | * accesses (esp. charp, which can be kfreed when it changes). |
||
19 | * |
||
20 | * The @type is simply pasted to refer to a param_ops_##type and a |
||
21 | * param_check_##type: for convenience many standard types are provided but |
||
22 | * you can create your own by defining those variables. |
||
23 | * |
||
24 | * Standard types are: |
||
25 | * byte, short, ushort, int, uint, long, ulong |
||
26 | * charp: a character pointer |
||
27 | * bool: a bool, values 0/1, y/n, Y/N. |
||
28 | * invbool: the above, only sense-reversed (N = true). |
||
29 | */ |
||
30 | #define module_param(name, type, perm) \ |
||
31 | module_param_named(name, name, type, perm) |
||
3031 | serge | 32 | |
6082 | serge | 33 | /** |
34 | * module_param_unsafe - same as module_param but taints kernel |
||
35 | */ |
||
36 | #define module_param_unsafe(name, type, perm) \ |
||
37 | module_param_named_unsafe(name, name, type, perm) |
||
38 | |||
39 | /** |
||
40 | * module_param_named - typesafe helper for a renamed module/cmdline parameter |
||
41 | * @name: a valid C identifier which is the parameter name. |
||
42 | * @value: the actual lvalue to alter. |
||
43 | * @type: the type of the parameter |
||
44 | * @perm: visibility in sysfs. |
||
45 | * |
||
46 | * Usually it's a good idea to have variable names and user-exposed names the |
||
47 | * same, but that's harder if the variable must be non-static or is inside a |
||
48 | * structure. This allows exposure under a different name. |
||
49 | */ |
||
3031 | serge | 50 | #define module_param_named(name, value, type, perm) |
6082 | serge | 51 | /** |
52 | * module_param_named_unsafe - same as module_param_named but taints kernel |
||
53 | */ |
||
54 | |||
5270 | serge | 55 | #define module_param_named_unsafe(name, value, type, perm) |
56 | |||
6082 | serge | 57 | #define MODULE_PARM_DESC(_parm, desc) |
58 | |||
59 | #ifdef CONFIG_SYSFS |
||
60 | extern void kernel_param_lock(struct module *mod); |
||
61 | extern void kernel_param_unlock(struct module *mod); |
||
62 | #else |
||
63 | static inline void kernel_param_lock(struct module *mod) |
||
64 | { |
||
65 | } |
||
66 | static inline void kernel_param_unlock(struct module *mod) |
||
67 | { |
||
68 | } |
||
5270 | serge | 69 | #endif |
6082 | serge | 70 | #endif |