public inbox for linux-nvme@lists.infradead.org
 help / color / mirror / Atom feed
From: Chaitanya Kulkarni <kch@nvidia.com>
To: <linux-nvme@lists.infradead.org>
Cc: <kbusch@kernel.org>, <hch@lst.de>, <sagi@grimberg.me>,
	Chaitanya Kulkarni <kch@nvidia.com>
Subject: [PATCH 2/2] nvme: export and use previously added helper
Date: Sun, 11 Feb 2024 20:26:41 -0800	[thread overview]
Message-ID: <20240212042641.227821-2-kch@nvidia.com> (raw)
In-Reply-To: <20240212042641.227821-1-kch@nvidia.com>

Export nvme_ctrl_state_str() and use it in the host/sysfs.c:
nvme_sysfs_show_state().

Signed-off-by: Chaitanya Kulkarni <kch@nvidia.com>
---
 drivers/nvme/host/core.c  |  2 +-
 drivers/nvme/host/nvme.h  |  1 +
 drivers/nvme/host/sysfs.c | 16 ++--------------
 3 files changed, 4 insertions(+), 15 deletions(-)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index daeb2409f989..acde9e377c00 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -544,7 +544,7 @@ void nvme_cancel_admin_tagset(struct nvme_ctrl *ctrl)
 }
 EXPORT_SYMBOL_GPL(nvme_cancel_admin_tagset);
 
-static const char *nvme_ctrl_state_str(enum nvme_ctrl_state st)
+const char *nvme_ctrl_state_str(enum nvme_ctrl_state st)
 {
 	static const char *const str[] = {
 		[NVME_CTRL_NEW]			= "new",
diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h
index 3ca486fe927c..3584c3861d6c 100644
--- a/drivers/nvme/host/nvme.h
+++ b/drivers/nvme/host/nvme.h
@@ -1094,6 +1094,7 @@ void nvme_passthru_end(struct nvme_ctrl *ctrl, struct nvme_ns *ns, u32 effects,
 struct nvme_ctrl *nvme_ctrl_from_file(struct file *file);
 struct nvme_ns *nvme_find_get_ns(struct nvme_ctrl *ctrl, unsigned nsid);
 void nvme_put_ns(struct nvme_ns *ns);
+const char *nvme_ctrl_state_str(enum nvme_ctrl_state st);
 
 static inline bool nvme_multi_css(struct nvme_ctrl *ctrl)
 {
diff --git a/drivers/nvme/host/sysfs.c b/drivers/nvme/host/sysfs.c
index f2832f70e7e0..a067feaba5ae 100644
--- a/drivers/nvme/host/sysfs.c
+++ b/drivers/nvme/host/sysfs.c
@@ -368,21 +368,9 @@ static ssize_t nvme_sysfs_show_state(struct device *dev,
 				     char *buf)
 {
 	struct nvme_ctrl *ctrl = dev_get_drvdata(dev);
-	unsigned state = (unsigned)nvme_ctrl_state(ctrl);
-	static const char *const state_name[] = {
-		[NVME_CTRL_NEW]		= "new",
-		[NVME_CTRL_LIVE]	= "live",
-		[NVME_CTRL_RESETTING]	= "resetting",
-		[NVME_CTRL_CONNECTING]	= "connecting",
-		[NVME_CTRL_DELETING]	= "deleting",
-		[NVME_CTRL_DELETING_NOIO]= "deleting (no IO)",
-		[NVME_CTRL_DEAD]	= "dead",
-	};
-
-	if (state < ARRAY_SIZE(state_name) && state_name[state])
-		return sysfs_emit(buf, "%s\n", state_name[state]);
 
-	return sysfs_emit(buf, "unknown state\n");
+	return sysfs_emit(buf, "%s\n",
+			  nvme_ctrl_state_str(nvme_ctrl_state(ctrl)));
 }
 
 static DEVICE_ATTR(state, S_IRUGO, nvme_sysfs_show_state, NULL);
-- 
2.40.0



  reply	other threads:[~2024-02-12  4:27 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20240212070024epcas5p15af7a6b038a30b3918adc517641b8eb1@epcas5p1.samsung.com>
2024-02-12  4:26 ` [PATCH 1/2] nvme-core: add ctrl state transition debug helper Chaitanya Kulkarni
2024-02-12  4:26   ` Chaitanya Kulkarni [this message]
2024-02-12  6:54     ` [PATCH 2/2] nvme: export and use previously added helper Nitesh Shetty
2024-03-07  8:03     ` Sagi Grimberg
2024-02-12  6:53   ` [PATCH 1/2] nvme-core: add ctrl state transition debug helper Nitesh Shetty
2024-02-21  5:34   ` Chaitanya Kulkarni
2024-03-05  4:34     ` Chaitanya Kulkarni
2024-03-05 16:34   ` Keith Busch
2024-03-06  5:21     ` Chaitanya Kulkarni
2024-03-07  8:03     ` Sagi Grimberg
2024-03-07  8:03   ` Sagi Grimberg

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=20240212042641.227821-2-kch@nvidia.com \
    --to=kch@nvidia.com \
    --cc=hch@lst.de \
    --cc=kbusch@kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --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