summaryrefslogtreecommitdiff
path: root/drivers/nvme/host/fc.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2017-10-18 14:25:42 +0300
committerChristoph Hellwig <hch@lst.de>2017-10-27 09:04:07 +0300
commitd22524a4782a943bb02a9cf6885ac470210aabfc (patch)
tree660bfba4f33f5a4cd6199bdca79f83438b70bcb6 /drivers/nvme/host/fc.c
parentc6424a90da446cff6c67be06767fc0d0be787110 (diff)
downloadlinux-d22524a4782a943bb02a9cf6885ac470210aabfc.tar.xz
nvme: switch controller refcounting to use struct device
Instead of allocating a separate struct device for the character device handle embedd it into struct nvme_ctrl and use it for the main controller refcounting. This removes double refcounting and gets us an automatic reference for the character device operations. We keep ctrl->device as a pointer for now to avoid chaning printks all over, but in the future we could look into message printing helpers that take a controller structure similar to what other subsystems do. Note the delete_ctrl operation always already has a reference (either through sysfs due this change, or because every open file on the /dev/nvme-fabrics node has a refernece) when it is entered now, so we don't need to do the unless_zero variant there. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Hannes Reinecke <hare@suse.com>
Diffstat (limited to 'drivers/nvme/host/fc.c')
-rw-r--r--drivers/nvme/host/fc.c8
1 files changed, 2 insertions, 6 deletions
diff --git a/drivers/nvme/host/fc.c b/drivers/nvme/host/fc.c
index c6c903f1b172..aa9aec6923bb 100644
--- a/drivers/nvme/host/fc.c
+++ b/drivers/nvme/host/fc.c
@@ -2692,14 +2692,10 @@ nvme_fc_del_nvme_ctrl(struct nvme_ctrl *nctrl)
struct nvme_fc_ctrl *ctrl = to_fc_ctrl(nctrl);
int ret;
- if (!kref_get_unless_zero(&ctrl->ctrl.kref))
- return -EBUSY;
-
+ nvme_get_ctrl(&ctrl->ctrl);
ret = __nvme_fc_del_ctrl(ctrl);
-
if (!ret)
flush_workqueue(nvme_wq);
-
nvme_put_ctrl(&ctrl->ctrl);
return ret;
@@ -2918,7 +2914,7 @@ nvme_fc_init_ctrl(struct device *dev, struct nvmf_ctrl_options *opts,
return ERR_PTR(ret);
}
- kref_get(&ctrl->ctrl.kref);
+ nvme_get_ctrl(&ctrl->ctrl);
dev_info(ctrl->ctrl.device,
"NVME-FC{%d}: new ctrl: NQN \"%s\"\n",