All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chaitanya Kulkarni <kch@nvidia.com>
To: <linux-block@vger.kernel.org>
Cc: <axboe@kernel.dk>, <kch@nvidia.com>,
	<damien.lemoal@opensource.wdc.com>, <johannes.thumshirn@wdc.com>,
	<ming.lei@redhat.com>, <bvanassche@acm.org>,
	<shinichiro.kawasaki@wdc.com>, <vincent.fu@samsung.com>
Subject: [PATCH V2 8/9] null_blk: avoid use global modparam g_queue_mode
Date: Thu, 30 Mar 2023 14:31:33 -0700	[thread overview]
Message-ID: <20230330213134.131298-9-kch@nvidia.com> (raw)
In-Reply-To: <20230330213134.131298-1-kch@nvidia.com>

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(-)

diff --git a/drivers/block/null_blk/main.c b/drivers/block/null_blk/main.c
index 96ced0485e35..5325ec57287d 100644
--- a/drivers/block/null_blk/main.c
+++ b/drivers/block/null_blk/main.c
@@ -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)");
 
-- 
2.29.0


  parent reply	other threads:[~2023-03-30 21:33 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-30 21:31 [PATCH V2 0/9] null_blk: add modparam checks Chaitanya Kulkarni
2023-03-30 21:31 ` [PATCH V2 1/9] null_blk: adjust null_param_store_val() Chaitanya Kulkarni
2023-03-30 21:31 ` [PATCH V2 2/9] null_blk: check for valid submit_queue value Chaitanya Kulkarni
2023-03-30 21:31 ` [PATCH V2 3/9] null_blk: check for valid poll_queue value Chaitanya Kulkarni
2023-03-30 21:31 ` [PATCH V2 4/9] null_blk: check for valid gb value Chaitanya Kulkarni
2023-03-30 21:31 ` [PATCH V2 5/9] null_blk: check for valid block size value Chaitanya Kulkarni
2023-03-30 22:45   ` Damien Le Moal
2023-03-30 22:52     ` Chaitanya Kulkarni
2023-03-30 22:59       ` Damien Le Moal
2023-03-30 21:31 ` [PATCH V2 6/9] null_blk: check for valid max_sectors value Chaitanya Kulkarni
2023-03-30 21:31 ` [PATCH V2 7/9] null_blk: check for valid queue depth value Chaitanya Kulkarni
2023-03-30 21:31 ` Chaitanya Kulkarni [this message]
2023-03-30 21:31 ` [PATCH V2 9/9] null_blk: avoid use global modparam g_irq_mode Chaitanya Kulkarni
2023-03-30 23:02 ` [PATCH V2 0/9] null_blk: add modparam checks Jens Axboe
2023-03-31  4:52   ` Chaitanya Kulkarni

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230330213134.131298-9-kch@nvidia.com \
    --to=kch@nvidia.com \
    --cc=axboe@kernel.dk \
    --cc=bvanassche@acm.org \
    --cc=damien.lemoal@opensource.wdc.com \
    --cc=johannes.thumshirn@wdc.com \
    --cc=linux-block@vger.kernel.org \
    --cc=ming.lei@redhat.com \
    --cc=shinichiro.kawasaki@wdc.com \
    --cc=vincent.fu@samsung.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.