Linux-NVME Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Martin George <martinus.gpy@gmail.com>
To: linux-nvme@lists.infradead.org
Cc: hch@lst.de, kbusch@kernel.org, sagi@grimberg.me,
	Martin George <marting@netapp.com>
Subject: [PATCH] nvme: add nvme_is_disc_subsys() helper
Date: Thu, 22 Oct 2026 13:01:44 +0530	[thread overview]
Message-ID: <20261022073144.5239-1-marting@netapp.com> (raw)

Mirror the target's nvmet_is_disc_subsys() with a host-side
nvme_is_disc_subsys() helper, and use it for the open-coded
subtype == NVME_NQN_DISC checks in the host code to help
maintain consistency and improve code readability.

And while here, fix an error message to refer to the subsystem
rather than the controller.

Signed-off-by: Martin George <marting@netapp.com>
---
 drivers/nvme/host/core.c      | 4 ++--
 drivers/nvme/host/multipath.c | 6 +++---
 drivers/nvme/host/nvme.h      | 5 +++++
 3 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 531f9bb14bab..96b1dddf439b 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -3329,9 +3329,9 @@ static int nvme_init_subsystem(struct nvme_ctrl *ctrl, struct nvme_id_ctrl *id)
 	else
 		subsys->subtype = NVME_NQN_NVME;
 
-	if (nvme_discovery_ctrl(ctrl) && subsys->subtype != NVME_NQN_DISC) {
+	if (nvme_discovery_ctrl(ctrl) && !nvme_is_disc_subsys(subsys)) {
 		dev_err(ctrl->device,
-			"Subsystem %s is not a discovery controller",
+			"Subsystem %s is not a discovery subsystem",
 			subsys->subnqn);
 		kfree(subsys);
 		return -EINVAL;
diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c
index 87b934b46b85..1140491d58dd 100644
--- a/drivers/nvme/host/multipath.c
+++ b/drivers/nvme/host/multipath.c
@@ -1072,7 +1072,7 @@ static ssize_t nvme_subsys_iopolicy_show(struct device *dev,
 		container_of(dev, struct nvme_subsystem, dev);
 
 	/* A discovery subsystem has no namespaces and hence no I/O paths */
-	if (subsys->subtype == NVME_NQN_DISC)
+	if (nvme_is_disc_subsys(subsys))
 		return sysfs_emit(buf, "none\n");
 
 	return sysfs_emit(buf, "%s\n",
@@ -1109,7 +1109,7 @@ static ssize_t nvme_subsys_iopolicy_store(struct device *dev,
 		container_of(dev, struct nvme_subsystem, dev);
 	int policy;
 
-	if (subsys->subtype == NVME_NQN_DISC)
+	if (nvme_is_disc_subsys(subsys))
 		return -EOPNOTSUPP;
 
 	policy = nvme_iopolicy_parse(buf);
@@ -1129,7 +1129,7 @@ static ssize_t iopolicies_show(struct device *dev,
 		container_of(dev, struct nvme_subsystem, dev);
 	int i, len = 0;
 
-	if (subsys->subtype == NVME_NQN_DISC)
+	if (nvme_is_disc_subsys(subsys))
 		return sysfs_emit(buf, "none\n");
 
 	for (i = 0; i < ARRAY_SIZE(nvme_iopolicy_names); i++)
diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h
index a8ef62b8e34b..ace9119d0c09 100644
--- a/drivers/nvme/host/nvme.h
+++ b/drivers/nvme/host/nvme.h
@@ -522,6 +522,11 @@ struct nvme_subsystem {
 #endif
 };
 
+static inline bool nvme_is_disc_subsys(struct nvme_subsystem *subsys)
+{
+	return subsys->subtype != NVME_NQN_NVME;
+}
+
 /*
  * Container structure for uniqueue namespace identifiers.
  */
-- 
2.43.0



                 reply	other threads:[~2026-10-22  7:32 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20261022073144.5239-1-marting@netapp.com \
    --to=martinus.gpy@gmail.com \
    --cc=hch@lst.de \
    --cc=kbusch@kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=marting@netapp.com \
    --cc=sagi@grimberg.me \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox