1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _LINUX_MODULE_PARAMS_H
3 #define _LINUX_MODULE_PARAMS_H
4 /* (C) Copyright 2001, 2002 Rusty Russell IBM Corporation */
5 #include <linux/init.h>
6 #include <linux/stringify.h>
7 #include <linux/kernel.h>
8
9 /*
10 * The maximum module name length, including the NUL byte.
11 * Chosen so that structs with an unsigned long line up, specifically
12 * modversion_info.
13 */
14 #define __MODULE_NAME_LEN (64 - sizeof(unsigned long))
15
16 /* You can override this manually, but generally this should match the
17 module name. */
18 #ifdef MODULE
19 #define MODULE_PARAM_PREFIX /* empty */
20 #define __MODULE_INFO_PREFIX /* empty */
21 #else
22 #define MODULE_PARAM_PREFIX KBUILD_MODNAME "."
23 /* We cannot use MODULE_PARAM_PREFIX because some modules override it. */
24 #define __MODULE_INFO_PREFIX KBUILD_MODNAME "."
25 #endif
26
27 #define __MODULE_INFO(tag, name, info) \
28 static const char __UNIQUE_ID(name)[] \
29 __used __section(".modinfo") __aligned(1) \
30 = __MODULE_INFO_PREFIX __stringify(tag) "=" info
31
32 #define __MODULE_PARM_TYPE(name, _type) \
33 __MODULE_INFO(parmtype, name##type, #name ":" _type)
34
35 /* One for each parameter, describing how to use it. Some files do
36 multiple of these per line, so can't just use MODULE_INFO. */
37 #define MODULE_PARM_DESC(_parm, desc) \
38 __MODULE_INFO(parm, _parm, #_parm ":" desc)
39
40 struct kernel_param;
41
42 /*
43 * Flags available for kernel_param_ops
44 *
45 * NOARG - the parameter allows for no argument (foo instead of foo=1)
46 */
47 enum {
48 KERNEL_PARAM_OPS_FL_NOARG = (1 << 0)
49 };
50
51 struct kernel_param_ops {
52 /* How the ops should behave */
53 unsigned int flags;
54 /* Returns 0, or -errno. arg is in kp->arg. */
55 int (*set)(const char *val, const struct kernel_param *kp);
56 /* Returns length written or -errno. Buffer is 4k (ie. be short!) */
57 int (*get)(char *buffer, const struct kernel_param *kp);
58 /* Optional function to free kp->arg when module unloaded. */
59 void (*free)(void *arg);
60 };
61
62 /*
63 * Flags available for kernel_param
64 *
65 * UNSAFE - the parameter is dangerous and setting it will taint the kernel
66 * HWPARAM - Hardware param not permitted in lockdown mode
67 */
68 enum {
69 KERNEL_PARAM_FL_UNSAFE = (1 << 0),
70 KERNEL_PARAM_FL_HWPARAM = (1 << 1),
71 };
72
73 struct kernel_param {
74 const char *name;
75 struct module *mod;
76 const struct kernel_param_ops *ops;
77 const u16 perm;
78 s8 level;
79 u8 flags;
80 union {
81 void *arg;
82 const struct kparam_string *str;
83 const struct kparam_array *arr;
84 };
85 };
86
87 extern const struct kernel_param __start___param[], __stop___param[];
88
89 /* Special one for strings we want to copy into */
90 struct kparam_string {
91 unsigned int maxlen;
92 char *string;
93 };
94
95 /* Special one for arrays */
96 struct kparam_array
97 {
98 unsigned int max;
99 unsigned int elemsize;
100 unsigned int *num;
101 const struct kernel_param_ops *ops;
102 void *elem;
103 };
104
105 /**
106 * module_param - typesafe helper for a module/cmdline parameter
107 * @name: the variable to alter, and exposed parameter name.
108 * @type: the type of the parameter
109 * @perm: visibility in sysfs.
110 *
111 * @name becomes the module parameter, or (prefixed by KBUILD_MODNAME and a
112 * ".") the kernel commandline parameter. Note that - is changed to _, so
113 * the user can use "foo-bar=1" even for variable "foo_bar".
114 *
115 * @perm is 0 if the variable is not to appear in sysfs, or 0444
116 * for world-readable, 0644 for root-writable, etc. Note that if it
117 * is writable, you may need to use kernel_param_lock() around
118 * accesses (esp. charp, which can be kfreed when it changes).
119 *
120 * The @type is simply pasted to refer to a param_ops_##type and a
121 * param_check_##type: for convenience many standard types are provided but
122 * you can create your own by defining those variables.
123 *
124 * Standard types are:
125 * byte, hexint, short, ushort, int, uint, long, ulong
126 * charp: a character pointer
127 * bool: a bool, values 0/1, y/n, Y/N.
128 * invbool: the above, only sense-reversed (N = true).
129 */
130 #define module_param(name, type, perm) \
131 module_param_named(name, name, type, perm)
132
133 /**
134 * module_param_unsafe - same as module_param but taints kernel
135 * @name: the variable to alter, and exposed parameter name.
136 * @type: the type of the parameter
137 * @perm: visibility in sysfs.
138 */
139 #define module_param_unsafe(name, type, perm) \
140 module_param_named_unsafe(name, name, type, perm)
141
142 /**
143 * module_param_named - typesafe helper for a renamed module/cmdline parameter
144 * @name: a valid C identifier which is the parameter name.
145 * @value: the actual lvalue to alter.
146 * @type: the type of the parameter
147 * @perm: visibility in sysfs.
148 *
149 * Usually it's a good idea to have variable names and user-exposed names the
150 * same, but that's harder if the variable must be non-static or is inside a
151 * structure. This allows exposure under a different name.
152 */
153 #define module_param_named(name, value, type, perm) \
154 param_check_##type(name, &(value)); \
155 module_param_cb(name, ¶m_ops_##type, &value, perm); \
156 __MODULE_PARM_TYPE(name, #type)
157
158 /**
159 * module_param_named_unsafe - same as module_param_named but taints kernel
160 * @name: a valid C identifier which is the parameter name.
161 * @value: the actual lvalue to alter.
162 * @type: the type of the parameter
163 * @perm: visibility in sysfs.
164 */
165 #define module_param_named_unsafe(name, value, type, perm) \
166 param_check_##type(name, &(value)); \
167 module_param_cb_unsafe(name, ¶m_ops_##type, &value, perm); \
168 __MODULE_PARM_TYPE(name, #type)
169
170 /**
171 * module_param_cb - general callback for a module/cmdline parameter
172 * @name: a valid C identifier which is the parameter name.
173 * @ops: the set & get operations for this parameter.
174 * @arg: args for @ops
175 * @perm: visibility in sysfs.
176 *
177 * The ops can have NULL set or get functions.
178 */
179 #define module_param_cb(name, ops, arg, perm) \
180 __module_param_call(MODULE_PARAM_PREFIX, name, ops, arg, perm, -1, 0)
181
182 #define module_param_cb_unsafe(name, ops, arg, perm) \
183 __module_param_call(MODULE_PARAM_PREFIX, name, ops, arg, perm, -1, \
184 KERNEL_PARAM_FL_UNSAFE)
185
186 #define __level_param_cb(name, ops, arg, perm, level) \
187 __module_param_call(MODULE_PARAM_PREFIX, name, ops, arg, perm, level, 0)
188 /**
189 * core_param_cb - general callback for a module/cmdline parameter
190 * to be evaluated before core initcall level
191 * @name: a valid C identifier which is the parameter name.
192 * @ops: the set & get operations for this parameter.
193 * @arg: args for @ops
194 * @perm: visibility in sysfs.
195 *
196 * The ops can have NULL set or get functions.
197 */
198 #define core_param_cb(name, ops, arg, perm) \
199 __level_param_cb(name, ops, arg, perm, 1)
200
201 /**
202 * postcore_param_cb - general callback for a module/cmdline parameter
203 * to be evaluated before postcore initcall level
204 * @name: a valid C identifier which is the parameter name.
205 * @ops: the set & get operations for this parameter.
206 * @arg: args for @ops
207 * @perm: visibility in sysfs.
208 *
209 * The ops can have NULL set or get functions.
210 */
211 #define postcore_param_cb(name, ops, arg, perm) \
212 __level_param_cb(name, ops, arg, perm, 2)
213
214 /**
215 * arch_param_cb - general callback for a module/cmdline parameter
216 * to be evaluated before arch initcall level
217 * @name: a valid C identifier which is the parameter name.
218 * @ops: the set & get operations for this parameter.
219 * @arg: args for @ops
220 * @perm: visibility in sysfs.
221 *
222 * The ops can have NULL set or get functions.
223 */
224 #define arch_param_cb(name, ops, arg, perm) \
225 __level_param_cb(name, ops, arg, perm, 3)
226
227 /**
228 * subsys_param_cb - general callback for a module/cmdline parameter
229 * to be evaluated before subsys initcall level
230 * @name: a valid C identifier which is the parameter name.
231 * @ops: the set & get operations for this parameter.
232 * @arg: args for @ops
233 * @perm: visibility in sysfs.
234 *
235 * The ops can have NULL set or get functions.
236 */
237 #define subsys_param_cb(name, ops, arg, perm) \
238 __level_param_cb(name, ops, arg, perm, 4)
239
240 /**
241 * fs_param_cb - general callback for a module/cmdline parameter
242 * to be evaluated before fs initcall level
243 * @name: a valid C identifier which is the parameter name.
244 * @ops: the set & get operations for this parameter.
245 * @arg: args for @ops
246 * @perm: visibility in sysfs.
247 *
248 * The ops can have NULL set or get functions.
249 */
250 #define fs_param_cb(name, ops, arg, perm) \
251 __level_param_cb(name, ops, arg, perm, 5)
252
253 /**
254 * device_param_cb - general callback for a module/cmdline parameter
255 * to be evaluated before device initcall level
256 * @name: a valid C identifier which is the parameter name.
257 * @ops: the set & get operations for this parameter.
258 * @arg: args for @ops
259 * @perm: visibility in sysfs.
260 *
261 * The ops can have NULL set or get functions.
262 */
263 #define device_param_cb(name, ops, arg, perm) \
264 __level_param_cb(name, ops, arg, perm, 6)
265
266 /**
267 * late_param_cb - general callback for a module/cmdline parameter
268 * to be evaluated before late initcall level
269 * @name: a valid C identifier which is the parameter name.
270 * @ops: the set & get operations for this parameter.
271 * @arg: args for @ops
272 * @perm: visibility in sysfs.
273 *
274 * The ops can have NULL set or get functions.
275 */
276 #define late_param_cb(name, ops, arg, perm) \
277 __level_param_cb(name, ops, arg, perm, 7)
278
279 /* On alpha, ia64 and ppc64 relocations to global data cannot go into
280 read-only sections (which is part of respective UNIX ABI on these
281 platforms). So 'const' makes no sense and even causes compile failures
282 with some compilers. */
283 #if defined(CONFIG_ALPHA) || defined(CONFIG_PPC64)
284 #define __moduleparam_const
285 #else
286 #define __moduleparam_const const
287 #endif
288
289 /* This is the fundamental function for registering boot/module parameters. */
290 #define __module_param_call(prefix, name, ops, arg, perm, level, flags) \
291 static_assert(sizeof(""prefix) - 1 <= __MODULE_NAME_LEN); \
292 static const char __param_str_##name[] = prefix #name; \
293 static struct kernel_param __moduleparam_const __param_##name \
294 __used __section("__param") \
295 __aligned(__alignof__(struct kernel_param)) \
296 = { __param_str_##name, THIS_MODULE, ops, \
297 VERIFY_OCTAL_PERMISSIONS(perm), level, flags, { arg } }
298
299 /*
300 * Useful for describing a set/get pair used only once (i.e. for this
301 * parameter). For repeated set/get pairs (i.e. the same struct
302 * kernel_param_ops), use module_param_cb() instead.
303 */
304 #define module_param_call(name, _set, _get, arg, perm) \
305 static const struct kernel_param_ops __param_ops_##name = \
306 { .flags = 0, .set = _set, .get = _get }; \
307 __module_param_call(MODULE_PARAM_PREFIX, \
308 name, &__param_ops_##name, arg, perm, -1, 0)
309
310 #ifdef CONFIG_SYSFS
311 extern void kernel_param_lock(struct module *mod);
312 extern void kernel_param_unlock(struct module *mod);
313 #else
kernel_param_lock(struct module * mod)314 static inline void kernel_param_lock(struct module *mod)
315 {
316 }
kernel_param_unlock(struct module * mod)317 static inline void kernel_param_unlock(struct module *mod)
318 {
319 }
320 #endif
321
322 #ifndef MODULE
323 /**
324 * core_param - define a historical core kernel parameter.
325 * @name: the name of the cmdline and sysfs parameter (often the same as var)
326 * @var: the variable
327 * @type: the type of the parameter
328 * @perm: visibility in sysfs
329 *
330 * core_param is just like module_param(), but cannot be modular and
331 * doesn't add a prefix (such as "printk."). This is for compatibility
332 * with __setup(), and it makes sense as truly core parameters aren't
333 * tied to the particular file they're in.
334 */
335 #define core_param(name, var, type, perm) \
336 param_check_##type(name, &(var)); \
337 __module_param_call("", name, ¶m_ops_##type, &var, perm, -1, 0)
338
339 /**
340 * core_param_unsafe - same as core_param but taints kernel
341 * @name: the name of the cmdline and sysfs parameter (often the same as var)
342 * @var: the variable
343 * @type: the type of the parameter
344 * @perm: visibility in sysfs
345 */
346 #define core_param_unsafe(name, var, type, perm) \
347 param_check_##type(name, &(var)); \
348 __module_param_call("", name, ¶m_ops_##type, &var, perm, \
349 -1, KERNEL_PARAM_FL_UNSAFE)
350
351 #endif /* !MODULE */
352
353 /**
354 * module_param_string - a char array parameter
355 * @name: the name of the parameter
356 * @string: the string variable
357 * @len: the maximum length of the string, incl. terminator
358 * @perm: visibility in sysfs.
359 *
360 * This actually copies the string when it's set (unlike type charp).
361 * @len is usually just sizeof(string).
362 */
363 #define module_param_string(name, string, len, perm) \
364 static const struct kparam_string __param_string_##name \
365 = { len, string }; \
366 __module_param_call(MODULE_PARAM_PREFIX, name, \
367 ¶m_ops_string, \
368 .str = &__param_string_##name, perm, -1, 0);\
369 __MODULE_PARM_TYPE(name, "string")
370
371 /**
372 * parameq - checks if two parameter names match
373 * @name1: parameter name 1
374 * @name2: parameter name 2
375 *
376 * Returns true if the two parameter names are equal.
377 * Dashes (-) are considered equal to underscores (_).
378 */
379 extern bool parameq(const char *name1, const char *name2);
380
381 /**
382 * parameqn - checks if two parameter names match
383 * @name1: parameter name 1
384 * @name2: parameter name 2
385 * @n: the length to compare
386 *
387 * Similar to parameq(), except it compares @n characters.
388 */
389 extern bool parameqn(const char *name1, const char *name2, size_t n);
390
391 typedef int (*parse_unknown_fn)(char *param, char *val, const char *doing, void *arg);
392
393 /* Called on module insert or kernel boot */
394 extern char *parse_args(const char *name,
395 char *args,
396 const struct kernel_param *params,
397 unsigned num,
398 s16 level_min,
399 s16 level_max,
400 void *arg, parse_unknown_fn unknown);
401
402 /* Called by module remove. */
403 #ifdef CONFIG_SYSFS
404 extern void destroy_params(const struct kernel_param *params, unsigned num);
405 #else
destroy_params(const struct kernel_param * params,unsigned num)406 static inline void destroy_params(const struct kernel_param *params,
407 unsigned num)
408 {
409 }
410 #endif /* !CONFIG_SYSFS */
411
412 /* All the helper functions */
413 /* The macros to do compile-time type checking stolen from Jakub
414 Jelinek, who IIRC came up with this idea for the 2.4 module init code. */
415 #define __param_check(name, p, type) \
416 static inline type __always_unused *__check_##name(void) { return(p); }
417
418 extern const struct kernel_param_ops param_ops_byte;
419 extern int param_set_byte(const char *val, const struct kernel_param *kp);
420 extern int param_get_byte(char *buffer, const struct kernel_param *kp);
421 #define param_check_byte(name, p) __param_check(name, p, unsigned char)
422
423 extern const struct kernel_param_ops param_ops_short;
424 extern int param_set_short(const char *val, const struct kernel_param *kp);
425 extern int param_get_short(char *buffer, const struct kernel_param *kp);
426 #define param_check_short(name, p) __param_check(name, p, short)
427
428 extern const struct kernel_param_ops param_ops_ushort;
429 extern int param_set_ushort(const char *val, const struct kernel_param *kp);
430 extern int param_get_ushort(char *buffer, const struct kernel_param *kp);
431 #define param_check_ushort(name, p) __param_check(name, p, unsigned short)
432
433 extern const struct kernel_param_ops param_ops_int;
434 extern int param_set_int(const char *val, const struct kernel_param *kp);
435 extern int param_get_int(char *buffer, const struct kernel_param *kp);
436 #define param_check_int(name, p) __param_check(name, p, int)
437
438 extern const struct kernel_param_ops param_ops_uint;
439 extern int param_set_uint(const char *val, const struct kernel_param *kp);
440 extern int param_get_uint(char *buffer, const struct kernel_param *kp);
441 int param_set_uint_minmax(const char *val, const struct kernel_param *kp,
442 unsigned int min, unsigned int max);
443 #define param_check_uint(name, p) __param_check(name, p, unsigned int)
444
445 extern const struct kernel_param_ops param_ops_long;
446 extern int param_set_long(const char *val, const struct kernel_param *kp);
447 extern int param_get_long(char *buffer, const struct kernel_param *kp);
448 #define param_check_long(name, p) __param_check(name, p, long)
449
450 extern const struct kernel_param_ops param_ops_ulong;
451 extern int param_set_ulong(const char *val, const struct kernel_param *kp);
452 extern int param_get_ulong(char *buffer, const struct kernel_param *kp);
453 #define param_check_ulong(name, p) __param_check(name, p, unsigned long)
454
455 extern const struct kernel_param_ops param_ops_ullong;
456 extern int param_set_ullong(const char *val, const struct kernel_param *kp);
457 extern int param_get_ullong(char *buffer, const struct kernel_param *kp);
458 #define param_check_ullong(name, p) __param_check(name, p, unsigned long long)
459
460 extern const struct kernel_param_ops param_ops_hexint;
461 extern int param_set_hexint(const char *val, const struct kernel_param *kp);
462 extern int param_get_hexint(char *buffer, const struct kernel_param *kp);
463 #define param_check_hexint(name, p) param_check_uint(name, p)
464
465 extern const struct kernel_param_ops param_ops_charp;
466 extern int param_set_charp(const char *val, const struct kernel_param *kp);
467 extern int param_get_charp(char *buffer, const struct kernel_param *kp);
468 extern void param_free_charp(void *arg);
469 #define param_check_charp(name, p) __param_check(name, p, char *)
470
471 /* We used to allow int as well as bool. We're taking that away! */
472 extern const struct kernel_param_ops param_ops_bool;
473 extern int param_set_bool(const char *val, const struct kernel_param *kp);
474 extern int param_get_bool(char *buffer, const struct kernel_param *kp);
475 #define param_check_bool(name, p) __param_check(name, p, bool)
476
477 extern const struct kernel_param_ops param_ops_bool_enable_only;
478 extern int param_set_bool_enable_only(const char *val,
479 const struct kernel_param *kp);
480 /* getter is the same as for the regular bool */
481 #define param_check_bool_enable_only param_check_bool
482
483 extern const struct kernel_param_ops param_ops_invbool;
484 extern int param_set_invbool(const char *val, const struct kernel_param *kp);
485 extern int param_get_invbool(char *buffer, const struct kernel_param *kp);
486 #define param_check_invbool(name, p) __param_check(name, p, bool)
487
488 /* An int, which can only be set like a bool (though it shows as an int). */
489 extern const struct kernel_param_ops param_ops_bint;
490 extern int param_set_bint(const char *val, const struct kernel_param *kp);
491 #define param_get_bint param_get_int
492 #define param_check_bint param_check_int
493
494 /**
495 * module_param_array - a parameter which is an array of some type
496 * @name: the name of the array variable
497 * @type: the type, as per module_param()
498 * @nump: optional pointer filled in with the number written
499 * @perm: visibility in sysfs
500 *
501 * Input and output are as comma-separated values. Commas inside values
502 * don't work properly (eg. an array of charp).
503 *
504 * ARRAY_SIZE(@name) is used to determine the number of elements in the
505 * array, so the definition must be visible.
506 */
507 #define module_param_array(name, type, nump, perm) \
508 module_param_array_named(name, name, type, nump, perm)
509
510 /**
511 * module_param_array_named - renamed parameter which is an array of some type
512 * @name: a valid C identifier which is the parameter name
513 * @array: the name of the array variable
514 * @type: the type, as per module_param()
515 * @nump: optional pointer filled in with the number written
516 * @perm: visibility in sysfs
517 *
518 * This exposes a different name than the actual variable name. See
519 * module_param_named() for why this might be necessary.
520 */
521 #define module_param_array_named(name, array, type, nump, perm) \
522 param_check_##type(name, &(array)[0]); \
523 static const struct kparam_array __param_arr_##name \
524 = { .max = ARRAY_SIZE(array), .num = nump, \
525 .ops = ¶m_ops_##type, \
526 .elemsize = sizeof(array[0]), .elem = array }; \
527 __module_param_call(MODULE_PARAM_PREFIX, name, \
528 ¶m_array_ops, \
529 .arr = &__param_arr_##name, \
530 perm, -1, 0); \
531 __MODULE_PARM_TYPE(name, "array of " #type)
532
533 enum hwparam_type {
534 hwparam_ioport, /* Module parameter configures an I/O port */
535 hwparam_iomem, /* Module parameter configures an I/O mem address */
536 hwparam_ioport_or_iomem, /* Module parameter could be either, depending on other option */
537 hwparam_irq, /* Module parameter configures an IRQ */
538 hwparam_dma, /* Module parameter configures a DMA channel */
539 hwparam_dma_addr, /* Module parameter configures a DMA buffer address */
540 hwparam_other, /* Module parameter configures some other value */
541 };
542
543 /**
544 * module_param_hw_named - A parameter representing a hw parameters
545 * @name: a valid C identifier which is the parameter name.
546 * @value: the actual lvalue to alter.
547 * @type: the type of the parameter
548 * @hwtype: what the value represents (enum hwparam_type)
549 * @perm: visibility in sysfs.
550 *
551 * Usually it's a good idea to have variable names and user-exposed names the
552 * same, but that's harder if the variable must be non-static or is inside a
553 * structure. This allows exposure under a different name.
554 */
555 #define module_param_hw_named(name, value, type, hwtype, perm) \
556 param_check_##type(name, &(value)); \
557 __module_param_call(MODULE_PARAM_PREFIX, name, \
558 ¶m_ops_##type, &value, \
559 perm, -1, \
560 KERNEL_PARAM_FL_HWPARAM | (hwparam_##hwtype & 0)); \
561 __MODULE_PARM_TYPE(name, #type)
562
563 #define module_param_hw(name, type, hwtype, perm) \
564 module_param_hw_named(name, name, type, hwtype, perm)
565
566 /**
567 * module_param_hw_array - A parameter representing an array of hw parameters
568 * @name: the name of the array variable
569 * @type: the type, as per module_param()
570 * @hwtype: what the value represents (enum hwparam_type)
571 * @nump: optional pointer filled in with the number written
572 * @perm: visibility in sysfs
573 *
574 * Input and output are as comma-separated values. Commas inside values
575 * don't work properly (eg. an array of charp).
576 *
577 * ARRAY_SIZE(@name) is used to determine the number of elements in the
578 * array, so the definition must be visible.
579 */
580 #define module_param_hw_array(name, type, hwtype, nump, perm) \
581 param_check_##type(name, &(name)[0]); \
582 static const struct kparam_array __param_arr_##name \
583 = { .max = ARRAY_SIZE(name), .num = nump, \
584 .ops = ¶m_ops_##type, \
585 .elemsize = sizeof(name[0]), .elem = name }; \
586 __module_param_call(MODULE_PARAM_PREFIX, name, \
587 ¶m_array_ops, \
588 .arr = &__param_arr_##name, \
589 perm, -1, \
590 KERNEL_PARAM_FL_HWPARAM | (hwparam_##hwtype & 0)); \
591 __MODULE_PARM_TYPE(name, "array of " #type)
592
593
594 extern const struct kernel_param_ops param_array_ops;
595
596 extern const struct kernel_param_ops param_ops_string;
597 extern int param_set_copystring(const char *val, const struct kernel_param *);
598 extern int param_get_string(char *buffer, const struct kernel_param *kp);
599
600 /* for exporting parameters in /sys/module/.../parameters */
601
602 struct module;
603
604 #if defined(CONFIG_SYSFS) && defined(CONFIG_MODULES)
605 extern int module_param_sysfs_setup(struct module *mod,
606 const struct kernel_param *kparam,
607 unsigned int num_params);
608
609 extern void module_param_sysfs_remove(struct module *mod);
610 #else
module_param_sysfs_setup(struct module * mod,const struct kernel_param * kparam,unsigned int num_params)611 static inline int module_param_sysfs_setup(struct module *mod,
612 const struct kernel_param *kparam,
613 unsigned int num_params)
614 {
615 return 0;
616 }
617
module_param_sysfs_remove(struct module * mod)618 static inline void module_param_sysfs_remove(struct module *mod)
619 { }
620 #endif
621
622 #endif /* _LINUX_MODULE_PARAMS_H */
623