Message ID | 20210813151734.1236324-3-jim.cromie@gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | dyndbg: add DEFINE_DYNAMIC_DEBUG_CATEGORIES and use in DRM | expand |
On Fri, Aug 13, 2021 at 09:17:10AM -0600, Jim Cromie wrote: > Add a const void* data member to the struct, to allow attaching > private data that will be used soon by a setter method (via kp->data) > to perform more elaborate actions. > > To attach the data at compile time, add new macros: > > module_param_cbd() derives from module_param_cb(), adding data param, > and latter is redefined to use former. > > It calls __module_param_call_wdata(), which accepts a new data param > and inits .data with it. Re-define __module_param_call() to use it. > > Use of this new data member will be rare, it might be worth redoing > this as a separate/sub-type to de-bloat the base case. ... > +#define module_param_cbd(name, ops, arg, perm, data) \ > + __module_param_call_wdata(MODULE_PARAM_PREFIX, name, ops, arg, perm, -1, 0, data) Cryptic name. Moreover, inconsistent with the rest. What about module_param_cb_data() ? > #define module_param_cb_unsafe(name, ops, arg, perm) \ > __module_param_call(MODULE_PARAM_PREFIX, name, ops, arg, perm, -1, \ > KERNEL_PARAM_FL_UNSAFE) (above left for the above comment) ... > +#define __module_param_call_wdata(prefix, name, ops, arg, perm, level, flags, data) \ Similar __module_param_call_with_data()
On Fri, Aug 13, 2021 at 9:44 AM Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote: > > On Fri, Aug 13, 2021 at 09:17:10AM -0600, Jim Cromie wrote: > > Add a const void* data member to the struct, to allow attaching > > private data that will be used soon by a setter method (via kp->data) > > to perform more elaborate actions. > > > > To attach the data at compile time, add new macros: > > > > module_param_cbd() derives from module_param_cb(), adding data param, > > and latter is redefined to use former. > > > > It calls __module_param_call_wdata(), which accepts a new data param > > and inits .data with it. Re-define __module_param_call() to use it. > > > > Use of this new data member will be rare, it might be worth redoing > > this as a separate/sub-type to de-bloat the base case. > > ... > > > +#define module_param_cbd(name, ops, arg, perm, data) \ > > + __module_param_call_wdata(MODULE_PARAM_PREFIX, name, ops, arg, perm, -1, 0, data) > > Cryptic name. Moreover, inconsistent with the rest. > What about module_param_cb_data() ? > > > #define module_param_cb_unsafe(name, ops, arg, perm) \ > > __module_param_call(MODULE_PARAM_PREFIX, name, ops, arg, perm, -1, \ > > KERNEL_PARAM_FL_UNSAFE) > > (above left for the above comment) > > ... > > > +#define __module_param_call_wdata(prefix, name, ops, arg, perm, level, flags, data) \ > > Similar __module_param_call_with_data() > > -- > With Best Regards, > Andy Shevchenko > > yes to all renames, revised. thanks
diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h index eed280fae433..878387e0b2d9 100644 --- a/include/linux/moduleparam.h +++ b/include/linux/moduleparam.h @@ -78,6 +78,7 @@ struct kernel_param { const struct kparam_string *str; const struct kparam_array *arr; }; + const void *data; }; extern const struct kernel_param __start___param[], __stop___param[]; @@ -175,6 +176,9 @@ struct kparam_array #define module_param_cb(name, ops, arg, perm) \ __module_param_call(MODULE_PARAM_PREFIX, name, ops, arg, perm, -1, 0) +#define module_param_cbd(name, ops, arg, perm, data) \ + __module_param_call_wdata(MODULE_PARAM_PREFIX, name, ops, arg, perm, -1, 0, data) + #define module_param_cb_unsafe(name, ops, arg, perm) \ __module_param_call(MODULE_PARAM_PREFIX, name, ops, arg, perm, -1, \ KERNEL_PARAM_FL_UNSAFE) @@ -284,14 +288,17 @@ struct kparam_array /* This is the fundamental function for registering boot/module parameters. */ -#define __module_param_call(prefix, name, ops, arg, perm, level, flags) \ +#define __module_param_call(prefix, name, ops, arg, perm, level, flags) \ + __module_param_call_wdata(prefix, name, ops, arg, perm, level, flags, NULL) + +#define __module_param_call_wdata(prefix, name, ops, arg, perm, level, flags, data) \ /* Default value instead of permissions? */ \ static const char __param_str_##name[] = prefix #name; \ static struct kernel_param __moduleparam_const __param_##name \ __used __section("__param") \ __aligned(__alignof__(struct kernel_param)) \ = { __param_str_##name, THIS_MODULE, ops, \ - VERIFY_OCTAL_PERMISSIONS(perm), level, flags, { arg } } + VERIFY_OCTAL_PERMISSIONS(perm), level, flags, { arg }, data } /* Obsolete - use module_param_cb() */ #define module_param_call(name, _set, _get, arg, perm) \
Add a const void* data member to the struct, to allow attaching private data that will be used soon by a setter method (via kp->data) to perform more elaborate actions. To attach the data at compile time, add new macros: module_param_cbd() derives from module_param_cb(), adding data param, and latter is redefined to use former. It calls __module_param_call_wdata(), which accepts a new data param and inits .data with it. Re-define __module_param_call() to use it. Use of this new data member will be rare, it might be worth redoing this as a separate/sub-type to de-bloat the base case. --- v4+: . const void* data - <emil.l.velikov@gmail.com> Signed-off-by: Jim Cromie <jim.cromie@gmail.com> --- include/linux/moduleparam.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)