| .. | .. |
|---|
| 10 | 10 | module name. */ |
|---|
| 11 | 11 | #ifdef MODULE |
|---|
| 12 | 12 | #define MODULE_PARAM_PREFIX /* empty */ |
|---|
| 13 | +#define __MODULE_INFO_PREFIX /* empty */ |
|---|
| 13 | 14 | #else |
|---|
| 14 | 15 | #define MODULE_PARAM_PREFIX KBUILD_MODNAME "." |
|---|
| 16 | +/* We cannot use MODULE_PARAM_PREFIX because some modules override it. */ |
|---|
| 17 | +#define __MODULE_INFO_PREFIX KBUILD_MODNAME "." |
|---|
| 15 | 18 | #endif |
|---|
| 16 | 19 | |
|---|
| 17 | 20 | /* Chosen so that structs with an unsigned long line up. */ |
|---|
| 18 | 21 | #define MAX_PARAM_PREFIX_LEN (64 - sizeof(unsigned long)) |
|---|
| 19 | 22 | |
|---|
| 20 | | -#ifdef MODULE |
|---|
| 21 | 23 | #define __MODULE_INFO(tag, name, info) \ |
|---|
| 22 | 24 | static const char __UNIQUE_ID(name)[] \ |
|---|
| 23 | | - __used __attribute__((section(".modinfo"), unused, aligned(1))) \ |
|---|
| 24 | | - = __stringify(tag) "=" info |
|---|
| 25 | | -#else /* !MODULE */ |
|---|
| 26 | | -/* This struct is here for syntactic coherency, it is not used */ |
|---|
| 27 | | -#define __MODULE_INFO(tag, name, info) \ |
|---|
| 28 | | - struct __UNIQUE_ID(name) {} |
|---|
| 29 | | -#endif |
|---|
| 25 | + __used __section(".modinfo") __attribute__((unused, aligned(1))) \ |
|---|
| 26 | + = __MODULE_INFO_PREFIX __stringify(tag) "=" info |
|---|
| 27 | + |
|---|
| 30 | 28 | #define __MODULE_PARM_TYPE(name, _type) \ |
|---|
| 31 | 29 | __MODULE_INFO(parmtype, name##type, #name ":" _type) |
|---|
| 32 | 30 | |
|---|
| .. | .. |
|---|
| 102 | 100 | |
|---|
| 103 | 101 | /** |
|---|
| 104 | 102 | * module_param - typesafe helper for a module/cmdline parameter |
|---|
| 105 | | - * @value: the variable to alter, and exposed parameter name. |
|---|
| 103 | + * @name: the variable to alter, and exposed parameter name. |
|---|
| 106 | 104 | * @type: the type of the parameter |
|---|
| 107 | 105 | * @perm: visibility in sysfs. |
|---|
| 108 | 106 | * |
|---|
| 109 | | - * @value becomes the module parameter, or (prefixed by KBUILD_MODNAME and a |
|---|
| 107 | + * @name becomes the module parameter, or (prefixed by KBUILD_MODNAME and a |
|---|
| 110 | 108 | * ".") the kernel commandline parameter. Note that - is changed to _, so |
|---|
| 111 | 109 | * the user can use "foo-bar=1" even for variable "foo_bar". |
|---|
| 112 | 110 | * |
|---|
| 113 | | - * @perm is 0 if the the variable is not to appear in sysfs, or 0444 |
|---|
| 111 | + * @perm is 0 if the variable is not to appear in sysfs, or 0444 |
|---|
| 114 | 112 | * for world-readable, 0644 for root-writable, etc. Note that if it |
|---|
| 115 | 113 | * is writable, you may need to use kernel_param_lock() around |
|---|
| 116 | 114 | * accesses (esp. charp, which can be kfreed when it changes). |
|---|
| .. | .. |
|---|
| 120 | 118 | * you can create your own by defining those variables. |
|---|
| 121 | 119 | * |
|---|
| 122 | 120 | * Standard types are: |
|---|
| 123 | | - * byte, short, ushort, int, uint, long, ulong |
|---|
| 121 | + * byte, hexint, short, ushort, int, uint, long, ulong |
|---|
| 124 | 122 | * charp: a character pointer |
|---|
| 125 | 123 | * bool: a bool, values 0/1, y/n, Y/N. |
|---|
| 126 | 124 | * invbool: the above, only sense-reversed (N = true). |
|---|
| .. | .. |
|---|
| 130 | 128 | |
|---|
| 131 | 129 | /** |
|---|
| 132 | 130 | * module_param_unsafe - same as module_param but taints kernel |
|---|
| 131 | + * @name: the variable to alter, and exposed parameter name. |
|---|
| 132 | + * @type: the type of the parameter |
|---|
| 133 | + * @perm: visibility in sysfs. |
|---|
| 133 | 134 | */ |
|---|
| 134 | 135 | #define module_param_unsafe(name, type, perm) \ |
|---|
| 135 | 136 | module_param_named_unsafe(name, name, type, perm) |
|---|
| .. | .. |
|---|
| 152 | 153 | |
|---|
| 153 | 154 | /** |
|---|
| 154 | 155 | * module_param_named_unsafe - same as module_param_named but taints kernel |
|---|
| 156 | + * @name: a valid C identifier which is the parameter name. |
|---|
| 157 | + * @value: the actual lvalue to alter. |
|---|
| 158 | + * @type: the type of the parameter |
|---|
| 159 | + * @perm: visibility in sysfs. |
|---|
| 155 | 160 | */ |
|---|
| 156 | 161 | #define module_param_named_unsafe(name, value, type, perm) \ |
|---|
| 157 | 162 | param_check_##type(name, &(value)); \ |
|---|
| .. | .. |
|---|
| 162 | 167 | * module_param_cb - general callback for a module/cmdline parameter |
|---|
| 163 | 168 | * @name: a valid C identifier which is the parameter name. |
|---|
| 164 | 169 | * @ops: the set & get operations for this parameter. |
|---|
| 170 | + * @arg: args for @ops |
|---|
| 165 | 171 | * @perm: visibility in sysfs. |
|---|
| 166 | 172 | * |
|---|
| 167 | 173 | * The ops can have NULL set or get functions. |
|---|
| .. | .. |
|---|
| 173 | 179 | __module_param_call(MODULE_PARAM_PREFIX, name, ops, arg, perm, -1, \ |
|---|
| 174 | 180 | KERNEL_PARAM_FL_UNSAFE) |
|---|
| 175 | 181 | |
|---|
| 182 | +#define __level_param_cb(name, ops, arg, perm, level) \ |
|---|
| 183 | + __module_param_call(MODULE_PARAM_PREFIX, name, ops, arg, perm, level, 0) |
|---|
| 176 | 184 | /** |
|---|
| 177 | | - * <level>_param_cb - general callback for a module/cmdline parameter |
|---|
| 178 | | - * to be evaluated before certain initcall level |
|---|
| 185 | + * core_param_cb - general callback for a module/cmdline parameter |
|---|
| 186 | + * to be evaluated before core initcall level |
|---|
| 179 | 187 | * @name: a valid C identifier which is the parameter name. |
|---|
| 180 | 188 | * @ops: the set & get operations for this parameter. |
|---|
| 189 | + * @arg: args for @ops |
|---|
| 181 | 190 | * @perm: visibility in sysfs. |
|---|
| 182 | 191 | * |
|---|
| 183 | 192 | * The ops can have NULL set or get functions. |
|---|
| 184 | 193 | */ |
|---|
| 185 | | -#define __level_param_cb(name, ops, arg, perm, level) \ |
|---|
| 186 | | - __module_param_call(MODULE_PARAM_PREFIX, name, ops, arg, perm, level, 0) |
|---|
| 187 | | - |
|---|
| 188 | 194 | #define core_param_cb(name, ops, arg, perm) \ |
|---|
| 189 | 195 | __level_param_cb(name, ops, arg, perm, 1) |
|---|
| 190 | 196 | |
|---|
| 197 | +/** |
|---|
| 198 | + * postcore_param_cb - general callback for a module/cmdline parameter |
|---|
| 199 | + * to be evaluated before postcore initcall level |
|---|
| 200 | + * @name: a valid C identifier which is the parameter name. |
|---|
| 201 | + * @ops: the set & get operations for this parameter. |
|---|
| 202 | + * @arg: args for @ops |
|---|
| 203 | + * @perm: visibility in sysfs. |
|---|
| 204 | + * |
|---|
| 205 | + * The ops can have NULL set or get functions. |
|---|
| 206 | + */ |
|---|
| 191 | 207 | #define postcore_param_cb(name, ops, arg, perm) \ |
|---|
| 192 | 208 | __level_param_cb(name, ops, arg, perm, 2) |
|---|
| 193 | 209 | |
|---|
| 210 | +/** |
|---|
| 211 | + * arch_param_cb - general callback for a module/cmdline parameter |
|---|
| 212 | + * to be evaluated before arch initcall level |
|---|
| 213 | + * @name: a valid C identifier which is the parameter name. |
|---|
| 214 | + * @ops: the set & get operations for this parameter. |
|---|
| 215 | + * @arg: args for @ops |
|---|
| 216 | + * @perm: visibility in sysfs. |
|---|
| 217 | + * |
|---|
| 218 | + * The ops can have NULL set or get functions. |
|---|
| 219 | + */ |
|---|
| 194 | 220 | #define arch_param_cb(name, ops, arg, perm) \ |
|---|
| 195 | 221 | __level_param_cb(name, ops, arg, perm, 3) |
|---|
| 196 | 222 | |
|---|
| 223 | +/** |
|---|
| 224 | + * subsys_param_cb - general callback for a module/cmdline parameter |
|---|
| 225 | + * to be evaluated before subsys initcall level |
|---|
| 226 | + * @name: a valid C identifier which is the parameter name. |
|---|
| 227 | + * @ops: the set & get operations for this parameter. |
|---|
| 228 | + * @arg: args for @ops |
|---|
| 229 | + * @perm: visibility in sysfs. |
|---|
| 230 | + * |
|---|
| 231 | + * The ops can have NULL set or get functions. |
|---|
| 232 | + */ |
|---|
| 197 | 233 | #define subsys_param_cb(name, ops, arg, perm) \ |
|---|
| 198 | 234 | __level_param_cb(name, ops, arg, perm, 4) |
|---|
| 199 | 235 | |
|---|
| 236 | +/** |
|---|
| 237 | + * fs_param_cb - general callback for a module/cmdline parameter |
|---|
| 238 | + * to be evaluated before fs initcall level |
|---|
| 239 | + * @name: a valid C identifier which is the parameter name. |
|---|
| 240 | + * @ops: the set & get operations for this parameter. |
|---|
| 241 | + * @arg: args for @ops |
|---|
| 242 | + * @perm: visibility in sysfs. |
|---|
| 243 | + * |
|---|
| 244 | + * The ops can have NULL set or get functions. |
|---|
| 245 | + */ |
|---|
| 200 | 246 | #define fs_param_cb(name, ops, arg, perm) \ |
|---|
| 201 | 247 | __level_param_cb(name, ops, arg, perm, 5) |
|---|
| 202 | 248 | |
|---|
| 249 | +/** |
|---|
| 250 | + * device_param_cb - general callback for a module/cmdline parameter |
|---|
| 251 | + * to be evaluated before device initcall level |
|---|
| 252 | + * @name: a valid C identifier which is the parameter name. |
|---|
| 253 | + * @ops: the set & get operations for this parameter. |
|---|
| 254 | + * @arg: args for @ops |
|---|
| 255 | + * @perm: visibility in sysfs. |
|---|
| 256 | + * |
|---|
| 257 | + * The ops can have NULL set or get functions. |
|---|
| 258 | + */ |
|---|
| 203 | 259 | #define device_param_cb(name, ops, arg, perm) \ |
|---|
| 204 | 260 | __level_param_cb(name, ops, arg, perm, 6) |
|---|
| 205 | 261 | |
|---|
| 262 | +/** |
|---|
| 263 | + * late_param_cb - general callback for a module/cmdline parameter |
|---|
| 264 | + * to be evaluated before late initcall level |
|---|
| 265 | + * @name: a valid C identifier which is the parameter name. |
|---|
| 266 | + * @ops: the set & get operations for this parameter. |
|---|
| 267 | + * @arg: args for @ops |
|---|
| 268 | + * @perm: visibility in sysfs. |
|---|
| 269 | + * |
|---|
| 270 | + * The ops can have NULL set or get functions. |
|---|
| 271 | + */ |
|---|
| 206 | 272 | #define late_param_cb(name, ops, arg, perm) \ |
|---|
| 207 | 273 | __level_param_cb(name, ops, arg, perm, 7) |
|---|
| 208 | 274 | |
|---|
| .. | .. |
|---|
| 223 | 289 | static const char __param_str_##name[] = prefix #name; \ |
|---|
| 224 | 290 | static struct kernel_param __moduleparam_const __param_##name \ |
|---|
| 225 | 291 | __used \ |
|---|
| 226 | | - __attribute__ ((unused,__section__ ("__param"),aligned(sizeof(void *)))) \ |
|---|
| 292 | + __section("__param") __attribute__ ((unused, aligned(sizeof(void *)))) \ |
|---|
| 227 | 293 | = { __param_str_##name, THIS_MODULE, ops, \ |
|---|
| 228 | 294 | VERIFY_OCTAL_PERMISSIONS(perm), level, flags, { arg } } |
|---|
| 229 | 295 | |
|---|
| .. | .. |
|---|
| 265 | 331 | |
|---|
| 266 | 332 | /** |
|---|
| 267 | 333 | * core_param_unsafe - same as core_param but taints kernel |
|---|
| 334 | + * @name: the name of the cmdline and sysfs parameter (often the same as var) |
|---|
| 335 | + * @var: the variable |
|---|
| 336 | + * @type: the type of the parameter |
|---|
| 337 | + * @perm: visibility in sysfs |
|---|
| 268 | 338 | */ |
|---|
| 269 | 339 | #define core_param_unsafe(name, var, type, perm) \ |
|---|
| 270 | 340 | param_check_##type(name, &(var)); \ |
|---|
| .. | .. |
|---|
| 378 | 448 | extern int param_get_ullong(char *buffer, const struct kernel_param *kp); |
|---|
| 379 | 449 | #define param_check_ullong(name, p) __param_check(name, p, unsigned long long) |
|---|
| 380 | 450 | |
|---|
| 451 | +extern const struct kernel_param_ops param_ops_hexint; |
|---|
| 452 | +extern int param_set_hexint(const char *val, const struct kernel_param *kp); |
|---|
| 453 | +extern int param_get_hexint(char *buffer, const struct kernel_param *kp); |
|---|
| 454 | +#define param_check_hexint(name, p) param_check_uint(name, p) |
|---|
| 455 | + |
|---|
| 381 | 456 | extern const struct kernel_param_ops param_ops_charp; |
|---|
| 382 | 457 | extern int param_set_charp(const char *val, const struct kernel_param *kp); |
|---|
| 383 | 458 | extern int param_get_charp(char *buffer, const struct kernel_param *kp); |
|---|