[PATCH 6/9] nvme-core: open code nvme_delete_ctrl_sync()
Chaitanya Kulkarni
kch at nvidia.com
Wed Mar 22 20:36:33 PDT 2023
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 at nvidia.com>
---
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 3eb2299a81fc..06dac97c5b0f 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
More information about the Linux-nvme
mailing list