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