All of lore.kernel.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>,
	<hare@suse.de>, Chaitanya Kulkarni <kch@nvidia.com>
Subject: [PATCH V2 5/8] nvme-core: open code nvme_delete_ctrl_sync()
Date: Sun, 26 Mar 2023 23:04:15 -0700	[thread overview]
Message-ID: <20230327060418.86655-6-kch@nvidia.com> (raw)
In-Reply-To: <20230327060418.86655-1-kch@nvidia.com>

There is only one caller for the nvme_delete_ctrl_sync() i.e.
nvme_sysfs_delete(). Just open code the function in the caller.

Also, add a meaningful comment since we don't have the function name to
indicate synchronous deletion of the controller.

Signed-off-by: Chaitanya Kulkarni <kch@nvidia.com>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
---
 drivers/nvme/host/core.c | 26 ++++++++++++--------------
 1 file changed, 12 insertions(+), 14 deletions(-)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index cf9469e486ec..c4372855924d 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -237,18 +237,6 @@ int nvme_delete_ctrl(struct nvme_ctrl *ctrl)
 }
 EXPORT_SYMBOL_GPL(nvme_delete_ctrl);
 
-static void nvme_delete_ctrl_sync(struct nvme_ctrl *ctrl)
-{
-	/*
-	 * Keep a reference until nvme_do_delete_ctrl() complete,
-	 * since ->delete_ctrl can free the controller.
-	 */
-	nvme_get_ctrl(ctrl);
-	if (nvme_change_ctrl_state(ctrl, NVME_CTRL_DELETING))
-		nvme_do_delete_ctrl(ctrl);
-	nvme_put_ctrl(ctrl);
-}
-
 static blk_status_t nvme_error_status(u16 status)
 {
 	switch (status & 0x7ff) {
@@ -3591,8 +3579,18 @@ static ssize_t nvme_sysfs_delete(struct device *dev,
 {
 	struct nvme_ctrl *ctrl = dev_get_drvdata(dev);
 
-	if (device_remove_file_self(dev, attr))
-		nvme_delete_ctrl_sync(ctrl);
+	if (!device_remove_file_self(dev, attr))
+		return count;
+
+	/*
+	 * Delete the controller synchronously but keep a reference until
+	 * nvme_do_delete_ctrl() complete, since ->delete_ctrl can free the
+	 * controller.
+	 */
+	nvme_get_ctrl(ctrl);
+	if (nvme_change_ctrl_state(ctrl, NVME_CTRL_DELETING))
+		nvme_do_delete_ctrl(ctrl);
+	nvme_put_ctrl(ctrl);
 	return count;
 }
 static DEVICE_ATTR(delete_controller, S_IWUSR, NULL, nvme_sysfs_delete);
-- 
2.29.0



  parent reply	other threads:[~2023-03-27  6:05 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-27  6:04 [PATCH V2 0/8] nvme-core: trivial cleanups Chaitanya Kulkarni
2023-03-27  6:04 ` [PATCH V2 1/8] nvme-core: remove unnecessary else Chaitanya Kulkarni
2023-03-28  0:40   ` Christoph Hellwig
2023-03-27  6:04 ` [PATCH V2 2/8] nvme-core: remvoe extra line at end of function Chaitanya Kulkarni
2023-03-27  6:04 ` [PATCH V2 3/8] nvme-core: code cleanup for __nvme_check_ready() Chaitanya Kulkarni
2023-03-27 11:15   ` Pankaj Raghav
2023-03-27  6:04 ` [PATCH V2 4/8] nvme-core: use normal pattern Chaitanya Kulkarni
2023-03-28  0:42   ` Christoph Hellwig
2023-03-27  6:04 ` Chaitanya Kulkarni [this message]
2023-03-27  6:04 ` [PATCH V2 6/8] nvme-core: cleanup for nvme_set_latency_tolerance Chaitanya Kulkarni
2023-03-27  6:04 ` [PATCH V2 7/8] nvme-core: remove unneacessary else Chaitanya Kulkarni
2023-03-27  6:04 ` [PATCH V2 8/8] nvme-core: fix nvme_submit_sync_cmd() args Chaitanya Kulkarni
2023-03-28  0:43   ` Christoph Hellwig
2023-03-28  5:46     ` Chaitanya Kulkarni
2023-03-28  6:12 ` [PATCH V2 0/8] nvme-core: trivial cleanups 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=20230327060418.86655-6-kch@nvidia.com \
    --to=kch@nvidia.com \
    --cc=hare@suse.de \
    --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 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.