Skip to content

Commit 2c7ccb3

Browse files
keesmcgrof
authored andcommitted
module: Clarify documentation of module_param_call()
Commit 9bbb9e5 ("param: use ops in struct kernel_param, rather than get and set fns directly") added the comment that module_param_call() was deprecated, during a large scale refactoring to bring sanity to type casting back then. In 2017 following more cleanups, it became useful again as it wraps a common pattern of creating an ops struct for a given get/set pair: b2f270e ("module: Prepare to convert all module_param_call() prototypes") ece1996 ("module: Do not paper over type mismatches in module_param_call()") static const struct kernel_param_ops __param_ops_##name = \ { .flags = 0, .set = _set, .get = _get }; \ __module_param_call(MODULE_PARAM_PREFIX, \ name, &__param_ops_##name, arg, perm, -1, 0) __module_param_call(MODULE_PARAM_PREFIX, name, ops, arg, perm, -1, 0) Many users of module_param_cb() appear to be almost universally open-coding the same thing that module_param_call() does now. Don't discourage[1] people from using module_param_call(): clarify the comment to show that module_param_cb() is useful if you repeatedly use the same pair of get/set functions. [1] https://lore.kernel.org/lkml/202308301546.5C789E5EC@keescook/ Cc: Luis Chamberlain <mcgrof@kernel.org> Cc: Johan Hovold <johan@kernel.org> Cc: Jessica Yu <jeyu@kernel.org> Cc: Sagi Grimberg <sagi@grimberg.me> Cc: Nick Desaulniers <ndesaulniers@gooogle.com> Cc: Miguel Ojeda <ojeda@kernel.org> Cc: Joe Perches <joe@perches.com> Cc: linux-modules@vger.kernel.org Reviewed-by: Miguel Ojeda <ojeda@kernel.org> Signed-off-by: Kees Cook <keescook@chromium.org> Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
1 parent 7d461b2 commit 2c7ccb3

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

include/linux/moduleparam.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,11 @@ struct kparam_array
293293
= { __param_str_##name, THIS_MODULE, ops, \
294294
VERIFY_OCTAL_PERMISSIONS(perm), level, flags, { arg } }
295295

296-
/* Obsolete - use module_param_cb() */
296+
/*
297+
* Useful for describing a set/get pair used only once (i.e. for this
298+
* parameter). For repeated set/get pairs (i.e. the same struct
299+
* kernel_param_ops), use module_param_cb() instead.
300+
*/
297301
#define module_param_call(name, _set, _get, arg, perm) \
298302
static const struct kernel_param_ops __param_ops_##name = \
299303
{ .flags = 0, .set = _set, .get = _get }; \

0 commit comments

Comments
 (0)