From 9ffa69dc755a3472be246e587f79fbdc19205fe4 Mon Sep 17 00:00:00 2001 From: Shuhei Matsumoto Date: Mon, 14 Jun 2021 05:18:31 +0900 Subject: [PATCH] bdev/nvme: Inline _nvme_bdev_ctrlr_create() into nvme_bdev_ctrlr_create() Inline _nvme_bdev_ctrlr_create() into nvme_bdev_ctrlr_create(). This simplifies the nesting structure. Signed-off-by: Shuhei Matsumoto Change-Id: I903a9cee670dc0bf32d272e8c1d18c98a51ade8a Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/8315 Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins Reviewed-by: Ziye Yang Reviewed-by: Ben Walker Reviewed-by: Aleksey Marchuk --- module/bdev/nvme/bdev_nvme.c | 34 ++++++---------------------------- 1 file changed, 6 insertions(+), 28 deletions(-) diff --git a/module/bdev/nvme/bdev_nvme.c b/module/bdev/nvme/bdev_nvme.c index a0dd5e0ae..5c164cb87 100644 --- a/module/bdev/nvme/bdev_nvme.c +++ b/module/bdev/nvme/bdev_nvme.c @@ -1807,11 +1807,11 @@ populate_namespaces_cb(struct nvme_async_probe_ctx *ctx, size_t count, int rc) } static int -_nvme_bdev_ctrlr_create(struct spdk_nvme_ctrlr *ctrlr, - const char *name, - const struct spdk_nvme_transport_id *trid, - uint32_t prchk_flags, - struct nvme_bdev_ctrlr **_nvme_bdev_ctrlr) +nvme_bdev_ctrlr_create(struct spdk_nvme_ctrlr *ctrlr, + const char *name, + const struct spdk_nvme_transport_id *trid, + uint32_t prchk_flags, + struct nvme_async_probe_ctx *ctx) { struct nvme_bdev_ctrlr *nvme_bdev_ctrlr; struct nvme_bdev_ctrlr_trid *trid_entry; @@ -1905,9 +1905,7 @@ _nvme_bdev_ctrlr_create(struct spdk_nvme_ctrlr *ctrlr, TAILQ_INSERT_HEAD(&nvme_bdev_ctrlr->trids, trid_entry, link); - if (_nvme_bdev_ctrlr != NULL) { - *_nvme_bdev_ctrlr = nvme_bdev_ctrlr; - } + nvme_ctrlr_populate_namespaces(nvme_bdev_ctrlr, ctx); return 0; err_init_ocssd: @@ -1927,26 +1925,6 @@ err_init_mutex: return rc; } -static int -nvme_bdev_ctrlr_create(struct spdk_nvme_ctrlr *ctrlr, - const char *name, - const struct spdk_nvme_transport_id *trid, - uint32_t prchk_flags, - struct nvme_async_probe_ctx *ctx) -{ - struct nvme_bdev_ctrlr *nvme_bdev_ctrlr = NULL; - int rc; - - rc = _nvme_bdev_ctrlr_create(ctrlr, name, trid, prchk_flags, &nvme_bdev_ctrlr); - if (rc != 0) { - SPDK_ERRLOG("Failed to create new NVMe controller\n"); - return rc; - } - - nvme_ctrlr_populate_namespaces(nvme_bdev_ctrlr, ctx); - return 0; -} - static void attach_cb(void *cb_ctx, const struct spdk_nvme_transport_id *trid, struct spdk_nvme_ctrlr *ctrlr, const struct spdk_nvme_ctrlr_opts *opts)