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