@@ -156,11 +156,15 @@ module_param_string(init_hctx, g_init_hctx_str, sizeof(g_init_hctx_str), 0444);
MODULE_PARM_DESC(init_hctx, "Fault injection to fail hctx init. init_hctx=<interval>,<probability>,<space>,<times>");
#endif
-static int g_queue_mode = NULL_Q_MQ;
-
static int null_set_queue_mode(const char *str, const struct kernel_param *kp)
{
- return null_param_store_int(str, &g_queue_mode, NULL_Q_BIO, NULL_Q_MQ);
+ int ret;
+
+ ret = null_param_store_int(str, kp->arg, NULL_Q_BIO, NULL_Q_MQ);
+ if (ret)
+ pr_err("queue_mode valid values BIO: %u, MQ: %u\n",
+ NULL_Q_BIO, NULL_Q_MQ);
+ return ret;
}
static const struct kernel_param_ops null_queue_mode_param_ops = {
@@ -168,6 +172,7 @@ static const struct kernel_param_ops null_queue_mode_param_ops = {
.get = param_get_int,
};
+static int g_queue_mode = NULL_Q_MQ;
device_param_cb(queue_mode, &null_queue_mode_param_ops, &g_queue_mode, 0444);
MODULE_PARM_DESC(queue_mode, "Block interface to use (0=bio,1=rq,2=multiqueue)");
The reference to module parameter is already present in the struct kernel_param dp->arg include/linux/moduleparam.h :- device_param_cb(name, ops, arg, perm) level_param_cb(name, ops, arg, perm, level) __module_param_call(prefix, name, ops, arg, perm, level, flags) 288 /* Default value instead of permissions? */ \ 289 static const char __param_str_##name[] = prefix #name; \ 290 static struct kernel_param __moduleparam_const __param_##name \ 291 __used __section("__param") \ 292 __aligned(__alignof__(struct kernel_param)) \ 293 = { __param_str_##name, THIS_MODULE, ops, \ 294 VERIFY_OCTAL_PERMISSIONS(perm), level, flags, { arg } } Replace global reference to the g_queue_mode in null_set_queue_mode() with the function parameter kp-arg and rearrage code that matches nicely with this patch series. Also, use this opportunity to print the error message with valid range. Signed-off-by: Chaitanya Kulkarni <kch@nvidia.com> --- drivers/block/null_blk/main.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)