Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef _LINUX_MODULE_PARAMS_H
0003 #define _LINUX_MODULE_PARAMS_H
0004 /* (C) Copyright 2001, 2002 Rusty Russell IBM Corporation */
0005 #include <linux/init.h>
0006 #include <linux/stringify.h>
0007 #include <linux/kernel.h>
0008 
0009 /* You can override this manually, but generally this should match the
0010    module name. */
0011 #ifdef MODULE
0012 #define MODULE_PARAM_PREFIX /* empty */
0013 #define __MODULE_INFO_PREFIX /* empty */
0014 #else
0015 #define MODULE_PARAM_PREFIX KBUILD_MODNAME "."
0016 /* We cannot use MODULE_PARAM_PREFIX because some modules override it. */
0017 #define __MODULE_INFO_PREFIX KBUILD_MODNAME "."
0018 #endif
0019 
0020 /* Chosen so that structs with an unsigned long line up. */
0021 #define MAX_PARAM_PREFIX_LEN (64 - sizeof(unsigned long))
0022 
0023 #define __MODULE_INFO(tag, name, info)                    \
0024     static const char __UNIQUE_ID(name)[]                 \
0025         __used __section(".modinfo") __aligned(1)         \
0026         = __MODULE_INFO_PREFIX __stringify(tag) "=" info
0027 
0028 #define __MODULE_PARM_TYPE(name, _type)                   \
0029     __MODULE_INFO(parmtype, name##type, #name ":" _type)
0030 
0031 /* One for each parameter, describing how to use it.  Some files do
0032    multiple of these per line, so can't just use MODULE_INFO. */
0033 #define MODULE_PARM_DESC(_parm, desc) \
0034     __MODULE_INFO(parm, _parm, #_parm ":" desc)
0035 
0036 struct kernel_param;
0037 
0038 /*
0039  * Flags available for kernel_param_ops
0040  *
0041  * NOARG - the parameter allows for no argument (foo instead of foo=1)
0042  */
0043 enum {
0044     KERNEL_PARAM_OPS_FL_NOARG = (1 << 0)
0045 };
0046 
0047 struct kernel_param_ops {
0048     /* How the ops should behave */
0049     unsigned int flags;
0050     /* Returns 0, or -errno.  arg is in kp->arg. */
0051     int (*set)(const char *val, const struct kernel_param *kp);
0052     /* Returns length written or -errno.  Buffer is 4k (ie. be short!) */
0053     int (*get)(char *buffer, const struct kernel_param *kp);
0054     /* Optional function to free kp->arg when module unloaded. */
0055     void (*free)(void *arg);
0056 };
0057 
0058 /*
0059  * Flags available for kernel_param
0060  *
0061  * UNSAFE - the parameter is dangerous and setting it will taint the kernel
0062  * HWPARAM - Hardware param not permitted in lockdown mode
0063  */
0064 enum {
0065     KERNEL_PARAM_FL_UNSAFE  = (1 << 0),
0066     KERNEL_PARAM_FL_HWPARAM = (1 << 1),
0067 };
0068 
0069 struct kernel_param {
0070     const char *name;
0071     struct module *mod;
0072     const struct kernel_param_ops *ops;
0073     const u16 perm;
0074     s8 level;
0075     u8 flags;
0076     union {
0077         void *arg;
0078         const struct kparam_string *str;
0079         const struct kparam_array *arr;
0080     };
0081 };
0082 
0083 extern const struct kernel_param __start___param[], __stop___param[];
0084 
0085 /* Special one for strings we want to copy into */
0086 struct kparam_string {
0087     unsigned int maxlen;
0088     char *string;
0089 };
0090 
0091 /* Special one for arrays */
0092 struct kparam_array
0093 {
0094     unsigned int max;
0095     unsigned int elemsize;
0096     unsigned int *num;
0097     const struct kernel_param_ops *ops;
0098     void *elem;
0099 };
0100 
0101 /**
0102  * module_param - typesafe helper for a module/cmdline parameter
0103  * @name: the variable to alter, and exposed parameter name.
0104  * @type: the type of the parameter
0105  * @perm: visibility in sysfs.
0106  *
0107  * @name becomes the module parameter, or (prefixed by KBUILD_MODNAME and a
0108  * ".") the kernel commandline parameter.  Note that - is changed to _, so
0109  * the user can use "foo-bar=1" even for variable "foo_bar".
0110  *
0111  * @perm is 0 if the variable is not to appear in sysfs, or 0444
0112  * for world-readable, 0644 for root-writable, etc.  Note that if it
0113  * is writable, you may need to use kernel_param_lock() around
0114  * accesses (esp. charp, which can be kfreed when it changes).
0115  *
0116  * The @type is simply pasted to refer to a param_ops_##type and a
0117  * param_check_##type: for convenience many standard types are provided but
0118  * you can create your own by defining those variables.
0119  *
0120  * Standard types are:
0121  *  byte, hexint, short, ushort, int, uint, long, ulong
0122  *  charp: a character pointer
0123  *  bool: a bool, values 0/1, y/n, Y/N.
0124  *  invbool: the above, only sense-reversed (N = true).
0125  */
0126 #define module_param(name, type, perm)              \
0127     module_param_named(name, name, type, perm)
0128 
0129 /**
0130  * module_param_unsafe - same as module_param but taints kernel
0131  * @name: the variable to alter, and exposed parameter name.
0132  * @type: the type of the parameter
0133  * @perm: visibility in sysfs.
0134  */
0135 #define module_param_unsafe(name, type, perm)           \
0136     module_param_named_unsafe(name, name, type, perm)
0137 
0138 /**
0139  * module_param_named - typesafe helper for a renamed module/cmdline parameter
0140  * @name: a valid C identifier which is the parameter name.
0141  * @value: the actual lvalue to alter.
0142  * @type: the type of the parameter
0143  * @perm: visibility in sysfs.
0144  *
0145  * Usually it's a good idea to have variable names and user-exposed names the
0146  * same, but that's harder if the variable must be non-static or is inside a
0147  * structure.  This allows exposure under a different name.
0148  */
0149 #define module_param_named(name, value, type, perm)            \
0150     param_check_##type(name, &(value));                \
0151     module_param_cb(name, &param_ops_##type, &value, perm);        \
0152     __MODULE_PARM_TYPE(name, #type)
0153 
0154 /**
0155  * module_param_named_unsafe - same as module_param_named but taints kernel
0156  * @name: a valid C identifier which is the parameter name.
0157  * @value: the actual lvalue to alter.
0158  * @type: the type of the parameter
0159  * @perm: visibility in sysfs.
0160  */
0161 #define module_param_named_unsafe(name, value, type, perm)      \
0162     param_check_##type(name, &(value));             \
0163     module_param_cb_unsafe(name, &param_ops_##type, &value, perm);  \
0164     __MODULE_PARM_TYPE(name, #type)
0165 
0166 /**
0167  * module_param_cb - general callback for a module/cmdline parameter
0168  * @name: a valid C identifier which is the parameter name.
0169  * @ops: the set & get operations for this parameter.
0170  * @arg: args for @ops
0171  * @perm: visibility in sysfs.
0172  *
0173  * The ops can have NULL set or get functions.
0174  */
0175 #define module_param_cb(name, ops, arg, perm)                     \
0176     __module_param_call(MODULE_PARAM_PREFIX, name, ops, arg, perm, -1, 0)
0177 
0178 #define module_param_cb_unsafe(name, ops, arg, perm)                  \
0179     __module_param_call(MODULE_PARAM_PREFIX, name, ops, arg, perm, -1,    \
0180                 KERNEL_PARAM_FL_UNSAFE)
0181 
0182 #define __level_param_cb(name, ops, arg, perm, level)           \
0183     __module_param_call(MODULE_PARAM_PREFIX, name, ops, arg, perm, level, 0)
0184 /**
0185  * core_param_cb - general callback for a module/cmdline parameter
0186  *                 to be evaluated before core initcall level
0187  * @name: a valid C identifier which is the parameter name.
0188  * @ops: the set & get operations for this parameter.
0189  * @arg: args for @ops
0190  * @perm: visibility in sysfs.
0191  *
0192  * The ops can have NULL set or get functions.
0193  */
0194 #define core_param_cb(name, ops, arg, perm)     \
0195     __level_param_cb(name, ops, arg, perm, 1)
0196 
0197 /**
0198  * postcore_param_cb - general callback for a module/cmdline parameter
0199  *                     to be evaluated before postcore initcall level
0200  * @name: a valid C identifier which is the parameter name.
0201  * @ops: the set & get operations for this parameter.
0202  * @arg: args for @ops
0203  * @perm: visibility in sysfs.
0204  *
0205  * The ops can have NULL set or get functions.
0206  */
0207 #define postcore_param_cb(name, ops, arg, perm)     \
0208     __level_param_cb(name, ops, arg, perm, 2)
0209 
0210 /**
0211  * arch_param_cb - general callback for a module/cmdline parameter
0212  *                 to be evaluated before arch initcall level
0213  * @name: a valid C identifier which is the parameter name.
0214  * @ops: the set & get operations for this parameter.
0215  * @arg: args for @ops
0216  * @perm: visibility in sysfs.
0217  *
0218  * The ops can have NULL set or get functions.
0219  */
0220 #define arch_param_cb(name, ops, arg, perm)     \
0221     __level_param_cb(name, ops, arg, perm, 3)
0222 
0223 /**
0224  * subsys_param_cb - general callback for a module/cmdline parameter
0225  *                   to be evaluated before subsys initcall level
0226  * @name: a valid C identifier which is the parameter name.
0227  * @ops: the set & get operations for this parameter.
0228  * @arg: args for @ops
0229  * @perm: visibility in sysfs.
0230  *
0231  * The ops can have NULL set or get functions.
0232  */
0233 #define subsys_param_cb(name, ops, arg, perm)       \
0234     __level_param_cb(name, ops, arg, perm, 4)
0235 
0236 /**
0237  * fs_param_cb - general callback for a module/cmdline parameter
0238  *               to be evaluated before fs initcall level
0239  * @name: a valid C identifier which is the parameter name.
0240  * @ops: the set & get operations for this parameter.
0241  * @arg: args for @ops
0242  * @perm: visibility in sysfs.
0243  *
0244  * The ops can have NULL set or get functions.
0245  */
0246 #define fs_param_cb(name, ops, arg, perm)       \
0247     __level_param_cb(name, ops, arg, perm, 5)
0248 
0249 /**
0250  * device_param_cb - general callback for a module/cmdline parameter
0251  *                   to be evaluated before device initcall level
0252  * @name: a valid C identifier which is the parameter name.
0253  * @ops: the set & get operations for this parameter.
0254  * @arg: args for @ops
0255  * @perm: visibility in sysfs.
0256  *
0257  * The ops can have NULL set or get functions.
0258  */
0259 #define device_param_cb(name, ops, arg, perm)       \
0260     __level_param_cb(name, ops, arg, perm, 6)
0261 
0262 /**
0263  * late_param_cb - general callback for a module/cmdline parameter
0264  *                 to be evaluated before late initcall level
0265  * @name: a valid C identifier which is the parameter name.
0266  * @ops: the set & get operations for this parameter.
0267  * @arg: args for @ops
0268  * @perm: visibility in sysfs.
0269  *
0270  * The ops can have NULL set or get functions.
0271  */
0272 #define late_param_cb(name, ops, arg, perm)     \
0273     __level_param_cb(name, ops, arg, perm, 7)
0274 
0275 /* On alpha, ia64 and ppc64 relocations to global data cannot go into
0276    read-only sections (which is part of respective UNIX ABI on these
0277    platforms). So 'const' makes no sense and even causes compile failures
0278    with some compilers. */
0279 #if defined(CONFIG_ALPHA) || defined(CONFIG_IA64) || defined(CONFIG_PPC64)
0280 #define __moduleparam_const
0281 #else
0282 #define __moduleparam_const const
0283 #endif
0284 
0285 /* This is the fundamental function for registering boot/module
0286    parameters. */
0287 #define __module_param_call(prefix, name, ops, arg, perm, level, flags) \
0288     /* Default value instead of permissions? */         \
0289     static const char __param_str_##name[] = prefix #name;      \
0290     static struct kernel_param __moduleparam_const __param_##name   \
0291     __used __section("__param")                 \
0292     __aligned(__alignof__(struct kernel_param))         \
0293     = { __param_str_##name, THIS_MODULE, ops,           \
0294         VERIFY_OCTAL_PERMISSIONS(perm), level, flags, { arg } }
0295 
0296 /* Obsolete - use module_param_cb() */
0297 #define module_param_call(name, _set, _get, arg, perm)          \
0298     static const struct kernel_param_ops __param_ops_##name =   \
0299         { .flags = 0, .set = _set, .get = _get };       \
0300     __module_param_call(MODULE_PARAM_PREFIX,            \
0301                 name, &__param_ops_##name, arg, perm, -1, 0)
0302 
0303 #ifdef CONFIG_SYSFS
0304 extern void kernel_param_lock(struct module *mod);
0305 extern void kernel_param_unlock(struct module *mod);
0306 #else
0307 static inline void kernel_param_lock(struct module *mod)
0308 {
0309 }
0310 static inline void kernel_param_unlock(struct module *mod)
0311 {
0312 }
0313 #endif
0314 
0315 #ifndef MODULE
0316 /**
0317  * core_param - define a historical core kernel parameter.
0318  * @name: the name of the cmdline and sysfs parameter (often the same as var)
0319  * @var: the variable
0320  * @type: the type of the parameter
0321  * @perm: visibility in sysfs
0322  *
0323  * core_param is just like module_param(), but cannot be modular and
0324  * doesn't add a prefix (such as "printk.").  This is for compatibility
0325  * with __setup(), and it makes sense as truly core parameters aren't
0326  * tied to the particular file they're in.
0327  */
0328 #define core_param(name, var, type, perm)               \
0329     param_check_##type(name, &(var));               \
0330     __module_param_call("", name, &param_ops_##type, &var, perm, -1, 0)
0331 
0332 /**
0333  * core_param_unsafe - same as core_param but taints kernel
0334  * @name: the name of the cmdline and sysfs parameter (often the same as var)
0335  * @var: the variable
0336  * @type: the type of the parameter
0337  * @perm: visibility in sysfs
0338  */
0339 #define core_param_unsafe(name, var, type, perm)        \
0340     param_check_##type(name, &(var));               \
0341     __module_param_call("", name, &param_ops_##type, &var, perm,    \
0342                 -1, KERNEL_PARAM_FL_UNSAFE)
0343 
0344 #endif /* !MODULE */
0345 
0346 /**
0347  * module_param_string - a char array parameter
0348  * @name: the name of the parameter
0349  * @string: the string variable
0350  * @len: the maximum length of the string, incl. terminator
0351  * @perm: visibility in sysfs.
0352  *
0353  * This actually copies the string when it's set (unlike type charp).
0354  * @len is usually just sizeof(string).
0355  */
0356 #define module_param_string(name, string, len, perm)            \
0357     static const struct kparam_string __param_string_##name     \
0358         = { len, string };                  \
0359     __module_param_call(MODULE_PARAM_PREFIX, name,          \
0360                 &param_ops_string,              \
0361                 .str = &__param_string_##name, perm, -1, 0);\
0362     __MODULE_PARM_TYPE(name, "string")
0363 
0364 /**
0365  * parameq - checks if two parameter names match
0366  * @name1: parameter name 1
0367  * @name2: parameter name 2
0368  *
0369  * Returns true if the two parameter names are equal.
0370  * Dashes (-) are considered equal to underscores (_).
0371  */
0372 extern bool parameq(const char *name1, const char *name2);
0373 
0374 /**
0375  * parameqn - checks if two parameter names match
0376  * @name1: parameter name 1
0377  * @name2: parameter name 2
0378  * @n: the length to compare
0379  *
0380  * Similar to parameq(), except it compares @n characters.
0381  */
0382 extern bool parameqn(const char *name1, const char *name2, size_t n);
0383 
0384 /* Called on module insert or kernel boot */
0385 extern char *parse_args(const char *name,
0386               char *args,
0387               const struct kernel_param *params,
0388               unsigned num,
0389               s16 level_min,
0390               s16 level_max,
0391               void *arg,
0392               int (*unknown)(char *param, char *val,
0393                      const char *doing, void *arg));
0394 
0395 /* Called by module remove. */
0396 #ifdef CONFIG_SYSFS
0397 extern void destroy_params(const struct kernel_param *params, unsigned num);
0398 #else
0399 static inline void destroy_params(const struct kernel_param *params,
0400                   unsigned num)
0401 {
0402 }
0403 #endif /* !CONFIG_SYSFS */
0404 
0405 /* All the helper functions */
0406 /* The macros to do compile-time type checking stolen from Jakub
0407    Jelinek, who IIRC came up with this idea for the 2.4 module init code. */
0408 #define __param_check(name, p, type) \
0409     static inline type __always_unused *__check_##name(void) { return(p); }
0410 
0411 extern const struct kernel_param_ops param_ops_byte;
0412 extern int param_set_byte(const char *val, const struct kernel_param *kp);
0413 extern int param_get_byte(char *buffer, const struct kernel_param *kp);
0414 #define param_check_byte(name, p) __param_check(name, p, unsigned char)
0415 
0416 extern const struct kernel_param_ops param_ops_short;
0417 extern int param_set_short(const char *val, const struct kernel_param *kp);
0418 extern int param_get_short(char *buffer, const struct kernel_param *kp);
0419 #define param_check_short(name, p) __param_check(name, p, short)
0420 
0421 extern const struct kernel_param_ops param_ops_ushort;
0422 extern int param_set_ushort(const char *val, const struct kernel_param *kp);
0423 extern int param_get_ushort(char *buffer, const struct kernel_param *kp);
0424 #define param_check_ushort(name, p) __param_check(name, p, unsigned short)
0425 
0426 extern const struct kernel_param_ops param_ops_int;
0427 extern int param_set_int(const char *val, const struct kernel_param *kp);
0428 extern int param_get_int(char *buffer, const struct kernel_param *kp);
0429 #define param_check_int(name, p) __param_check(name, p, int)
0430 
0431 extern const struct kernel_param_ops param_ops_uint;
0432 extern int param_set_uint(const char *val, const struct kernel_param *kp);
0433 extern int param_get_uint(char *buffer, const struct kernel_param *kp);
0434 int param_set_uint_minmax(const char *val, const struct kernel_param *kp,
0435         unsigned int min, unsigned int max);
0436 #define param_check_uint(name, p) __param_check(name, p, unsigned int)
0437 
0438 extern const struct kernel_param_ops param_ops_long;
0439 extern int param_set_long(const char *val, const struct kernel_param *kp);
0440 extern int param_get_long(char *buffer, const struct kernel_param *kp);
0441 #define param_check_long(name, p) __param_check(name, p, long)
0442 
0443 extern const struct kernel_param_ops param_ops_ulong;
0444 extern int param_set_ulong(const char *val, const struct kernel_param *kp);
0445 extern int param_get_ulong(char *buffer, const struct kernel_param *kp);
0446 #define param_check_ulong(name, p) __param_check(name, p, unsigned long)
0447 
0448 extern const struct kernel_param_ops param_ops_ullong;
0449 extern int param_set_ullong(const char *val, const struct kernel_param *kp);
0450 extern int param_get_ullong(char *buffer, const struct kernel_param *kp);
0451 #define param_check_ullong(name, p) __param_check(name, p, unsigned long long)
0452 
0453 extern const struct kernel_param_ops param_ops_hexint;
0454 extern int param_set_hexint(const char *val, const struct kernel_param *kp);
0455 extern int param_get_hexint(char *buffer, const struct kernel_param *kp);
0456 #define param_check_hexint(name, p) param_check_uint(name, p)
0457 
0458 extern const struct kernel_param_ops param_ops_charp;
0459 extern int param_set_charp(const char *val, const struct kernel_param *kp);
0460 extern int param_get_charp(char *buffer, const struct kernel_param *kp);
0461 extern void param_free_charp(void *arg);
0462 #define param_check_charp(name, p) __param_check(name, p, char *)
0463 
0464 /* We used to allow int as well as bool.  We're taking that away! */
0465 extern const struct kernel_param_ops param_ops_bool;
0466 extern int param_set_bool(const char *val, const struct kernel_param *kp);
0467 extern int param_get_bool(char *buffer, const struct kernel_param *kp);
0468 #define param_check_bool(name, p) __param_check(name, p, bool)
0469 
0470 extern const struct kernel_param_ops param_ops_bool_enable_only;
0471 extern int param_set_bool_enable_only(const char *val,
0472                       const struct kernel_param *kp);
0473 /* getter is the same as for the regular bool */
0474 #define param_check_bool_enable_only param_check_bool
0475 
0476 extern const struct kernel_param_ops param_ops_invbool;
0477 extern int param_set_invbool(const char *val, const struct kernel_param *kp);
0478 extern int param_get_invbool(char *buffer, const struct kernel_param *kp);
0479 #define param_check_invbool(name, p) __param_check(name, p, bool)
0480 
0481 /* An int, which can only be set like a bool (though it shows as an int). */
0482 extern const struct kernel_param_ops param_ops_bint;
0483 extern int param_set_bint(const char *val, const struct kernel_param *kp);
0484 #define param_get_bint param_get_int
0485 #define param_check_bint param_check_int
0486 
0487 /**
0488  * module_param_array - a parameter which is an array of some type
0489  * @name: the name of the array variable
0490  * @type: the type, as per module_param()
0491  * @nump: optional pointer filled in with the number written
0492  * @perm: visibility in sysfs
0493  *
0494  * Input and output are as comma-separated values.  Commas inside values
0495  * don't work properly (eg. an array of charp).
0496  *
0497  * ARRAY_SIZE(@name) is used to determine the number of elements in the
0498  * array, so the definition must be visible.
0499  */
0500 #define module_param_array(name, type, nump, perm)      \
0501     module_param_array_named(name, name, type, nump, perm)
0502 
0503 /**
0504  * module_param_array_named - renamed parameter which is an array of some type
0505  * @name: a valid C identifier which is the parameter name
0506  * @array: the name of the array variable
0507  * @type: the type, as per module_param()
0508  * @nump: optional pointer filled in with the number written
0509  * @perm: visibility in sysfs
0510  *
0511  * This exposes a different name than the actual variable name.  See
0512  * module_param_named() for why this might be necessary.
0513  */
0514 #define module_param_array_named(name, array, type, nump, perm)     \
0515     param_check_##type(name, &(array)[0]);              \
0516     static const struct kparam_array __param_arr_##name     \
0517     = { .max = ARRAY_SIZE(array), .num = nump,                      \
0518         .ops = &param_ops_##type,                   \
0519         .elemsize = sizeof(array[0]), .elem = array };      \
0520     __module_param_call(MODULE_PARAM_PREFIX, name,          \
0521                 &param_array_ops,               \
0522                 .arr = &__param_arr_##name,         \
0523                 perm, -1, 0);               \
0524     __MODULE_PARM_TYPE(name, "array of " #type)
0525 
0526 enum hwparam_type {
0527     hwparam_ioport,     /* Module parameter configures an I/O port */
0528     hwparam_iomem,      /* Module parameter configures an I/O mem address */
0529     hwparam_ioport_or_iomem, /* Module parameter could be either, depending on other option */
0530     hwparam_irq,        /* Module parameter configures an IRQ */
0531     hwparam_dma,        /* Module parameter configures a DMA channel */
0532     hwparam_dma_addr,   /* Module parameter configures a DMA buffer address */
0533     hwparam_other,      /* Module parameter configures some other value */
0534 };
0535 
0536 /**
0537  * module_param_hw_named - A parameter representing a hw parameters
0538  * @name: a valid C identifier which is the parameter name.
0539  * @value: the actual lvalue to alter.
0540  * @type: the type of the parameter
0541  * @hwtype: what the value represents (enum hwparam_type)
0542  * @perm: visibility in sysfs.
0543  *
0544  * Usually it's a good idea to have variable names and user-exposed names the
0545  * same, but that's harder if the variable must be non-static or is inside a
0546  * structure.  This allows exposure under a different name.
0547  */
0548 #define module_param_hw_named(name, value, type, hwtype, perm)      \
0549     param_check_##type(name, &(value));             \
0550     __module_param_call(MODULE_PARAM_PREFIX, name,          \
0551                 &param_ops_##type, &value,          \
0552                 perm, -1,                   \
0553                 KERNEL_PARAM_FL_HWPARAM | (hwparam_##hwtype & 0));  \
0554     __MODULE_PARM_TYPE(name, #type)
0555 
0556 #define module_param_hw(name, type, hwtype, perm)       \
0557     module_param_hw_named(name, name, type, hwtype, perm)
0558 
0559 /**
0560  * module_param_hw_array - A parameter representing an array of hw parameters
0561  * @name: the name of the array variable
0562  * @type: the type, as per module_param()
0563  * @hwtype: what the value represents (enum hwparam_type)
0564  * @nump: optional pointer filled in with the number written
0565  * @perm: visibility in sysfs
0566  *
0567  * Input and output are as comma-separated values.  Commas inside values
0568  * don't work properly (eg. an array of charp).
0569  *
0570  * ARRAY_SIZE(@name) is used to determine the number of elements in the
0571  * array, so the definition must be visible.
0572  */
0573 #define module_param_hw_array(name, type, hwtype, nump, perm)       \
0574     param_check_##type(name, &(name)[0]);               \
0575     static const struct kparam_array __param_arr_##name     \
0576     = { .max = ARRAY_SIZE(name), .num = nump,           \
0577         .ops = &param_ops_##type,                   \
0578         .elemsize = sizeof(name[0]), .elem = name };        \
0579     __module_param_call(MODULE_PARAM_PREFIX, name,          \
0580                 &param_array_ops,               \
0581                 .arr = &__param_arr_##name,         \
0582                 perm, -1,                   \
0583                 KERNEL_PARAM_FL_HWPARAM | (hwparam_##hwtype & 0));  \
0584     __MODULE_PARM_TYPE(name, "array of " #type)
0585 
0586 
0587 extern const struct kernel_param_ops param_array_ops;
0588 
0589 extern const struct kernel_param_ops param_ops_string;
0590 extern int param_set_copystring(const char *val, const struct kernel_param *);
0591 extern int param_get_string(char *buffer, const struct kernel_param *kp);
0592 
0593 /* for exporting parameters in /sys/module/.../parameters */
0594 
0595 struct module;
0596 
0597 #if defined(CONFIG_SYSFS) && defined(CONFIG_MODULES)
0598 extern int module_param_sysfs_setup(struct module *mod,
0599                     const struct kernel_param *kparam,
0600                     unsigned int num_params);
0601 
0602 extern void module_param_sysfs_remove(struct module *mod);
0603 #else
0604 static inline int module_param_sysfs_setup(struct module *mod,
0605                  const struct kernel_param *kparam,
0606                  unsigned int num_params)
0607 {
0608     return 0;
0609 }
0610 
0611 static inline void module_param_sysfs_remove(struct module *mod)
0612 { }
0613 #endif
0614 
0615 #endif /* _LINUX_MODULE_PARAMS_H */