diff options
author | Christoph Hellwig <hch@lst.de> | 2021-04-07 14:36:47 +0200 |
---|---|---|
committer | Christoph Hellwig <hch@lst.de> | 2021-04-15 08:12:55 +0200 |
commit | f5b9a51db29c31f4e486b08d1d823d6f75f2c2c7 (patch) | |
tree | 16fdd3fc81075e9c8bda9a13c3e11203d26625b1 /drivers/nvme/host | |
parent | 1496bd4936d215fed40b008e9486c38e6acf01db (diff) |
nvme: factor out nvme_ns_open and nvme_ns_release helpers
These will be reused for the per-namespace character devices.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Keith Busch <kbusch@kernel.org>
Reviewed-by: Javier González <javier.gonz@samsung.com>
Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Diffstat (limited to 'drivers/nvme/host')
-rw-r--r-- | drivers/nvme/host/core.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index b1f8d94bbe09..ded60d50fc56 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -1483,9 +1483,8 @@ void nvme_put_ns_from_disk(struct nvme_ns_head *head, int idx) srcu_read_unlock(&head->srcu, idx); } -static int nvme_open(struct block_device *bdev, fmode_t mode) +static int nvme_ns_open(struct nvme_ns *ns) { - struct nvme_ns *ns = bdev->bd_disk->private_data; /* should never be called due to GENHD_FL_HIDDEN */ if (WARN_ON_ONCE(nvme_ns_head_multipath(ns->head))) @@ -1503,14 +1502,23 @@ fail: return -ENXIO; } -static void nvme_release(struct gendisk *disk, fmode_t mode) +static void nvme_ns_release(struct nvme_ns *ns) { - struct nvme_ns *ns = disk->private_data; module_put(ns->ctrl->ops->module); nvme_put_ns(ns); } +static int nvme_open(struct block_device *bdev, fmode_t mode) +{ + return nvme_ns_open(bdev->bd_disk->private_data); +} + +static void nvme_release(struct gendisk *disk, fmode_t mode) +{ + nvme_ns_release(disk->private_data); +} + int nvme_getgeo(struct block_device *bdev, struct hd_geometry *geo) { /* some standard values */ |