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