aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/moduleparam.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/moduleparam.h')
-rw-r--r--include/linux/moduleparam.h65
1 files changed, 64 insertions, 1 deletions
diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
index 52666d90ca94..6be1949ebcdf 100644
--- a/include/linux/moduleparam.h
+++ b/include/linux/moduleparam.h
@@ -60,9 +60,11 @@ struct kernel_param_ops {
60 * Flags available for kernel_param 60 * Flags available for kernel_param
61 * 61 *
62 * UNSAFE - the parameter is dangerous and setting it will taint the kernel 62 * UNSAFE - the parameter is dangerous and setting it will taint the kernel
63 * HWPARAM - Hardware param not permitted in lockdown mode
63 */ 64 */
64enum { 65enum {
65 KERNEL_PARAM_FL_UNSAFE = (1 << 0) 66 KERNEL_PARAM_FL_UNSAFE = (1 << 0),
67 KERNEL_PARAM_FL_HWPARAM = (1 << 1),
66}; 68};
67 69
68struct kernel_param { 70struct kernel_param {
@@ -451,6 +453,67 @@ extern int param_set_bint(const char *val, const struct kernel_param *kp);
451 perm, -1, 0); \ 453 perm, -1, 0); \
452 __MODULE_PARM_TYPE(name, "array of " #type) 454 __MODULE_PARM_TYPE(name, "array of " #type)
453 455
456enum hwparam_type {
457 hwparam_ioport, /* Module parameter configures an I/O port */
458 hwparam_iomem, /* Module parameter configures an I/O mem address */
459 hwparam_ioport_or_iomem, /* Module parameter could be either, depending on other option */
460 hwparam_irq, /* Module parameter configures an I/O port */
461 hwparam_dma, /* Module parameter configures a DMA channel */
462 hwparam_dma_addr, /* Module parameter configures a DMA buffer address */
463 hwparam_other, /* Module parameter configures some other value */
464};
465
466/**
467 * module_param_hw_named - A parameter representing a hw parameters
468 * @name: a valid C identifier which is the parameter name.
469 * @value: the actual lvalue to alter.
470 * @type: the type of the parameter
471 * @hwtype: what the value represents (enum hwparam_type)
472 * @perm: visibility in sysfs.
473 *
474 * Usually it's a good idea to have variable names and user-exposed names the
475 * same, but that's harder if the variable must be non-static or is inside a
476 * structure. This allows exposure under a different name.
477 */
478#define module_param_hw_named(name, value, type, hwtype, perm) \
479 param_check_##type(name, &(value)); \
480 __module_param_call(MODULE_PARAM_PREFIX, name, \
481 &param_ops_##type, &value, \
482 perm, -1, \
483 KERNEL_PARAM_FL_HWPARAM | (hwparam_##hwtype & 0)); \
484 __MODULE_PARM_TYPE(name, #type)
485
486#define module_param_hw(name, type, hwtype, perm) \
487 module_param_hw_named(name, name, type, hwtype, perm)
488
489/**
490 * module_param_hw_array - A parameter representing an array of hw parameters
491 * @name: the name of the array variable
492 * @type: the type, as per module_param()
493 * @hwtype: what the value represents (enum hwparam_type)
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_hw_array(name, type, hwtype, nump, perm) \
504 param_check_##type(name, &(name)[0]); \
505 static const struct kparam_array __param_arr_##name \
506 = { .max = ARRAY_SIZE(name), .num = nump, \
507 .ops = &param_ops_##type, \
508 .elemsize = sizeof(name[0]), .elem = name }; \
509 __module_param_call(MODULE_PARAM_PREFIX, name, \
510 &param_array_ops, \
511 .arr = &__param_arr_##name, \
512 perm, -1, \
513 KERNEL_PARAM_FL_HWPARAM | (hwparam_##hwtype & 0)); \
514 __MODULE_PARM_TYPE(name, "array of " #type)
515
516
454extern const struct kernel_param_ops param_array_ops; 517extern const struct kernel_param_ops param_array_ops;
455 518
456extern const struct kernel_param_ops param_ops_string; 519extern const struct kernel_param_ops param_ops_string;