[PATCH 07/14] nvme-core: add helper to init ctrl subsys quirk
From: Chaitanya Kulkarni <hidden>
Date: 2021-02-17 00:11:35
Subsystem:
nvm express driver, the rest · Maintainers:
Keith Busch, Jens Axboe, Christoph Hellwig, Sagi Grimberg, Linus Torvalds
The function nvme_init_identify() has grown over the period of time about ~200 lines given the size of nvme id_ctrl data structure. Just like the tail of the function it has small helpers to initialize the independent fields that needs some extra checking, add a new helper nvme_init_ctrl_subsys_and_quirks() to initialize ctrl subsystem and quirks. Signed-off-by: Chaitanya Kulkarni <redacted> --- drivers/nvme/host/core.c | 43 +++++++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 16 deletions(-)
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 77f79a2a396f..4a59a46193e8 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c@@ -3057,6 +3057,32 @@ static int nvme_get_effects_log(struct nvme_ctrl *ctrl, u8 csi, return 0; } +static int nvme_init_ctrl_subsys_and_quirks(struct nvme_ctrl *ctrl, + struct nvme_id_ctrl *id) +{ + unsigned int i; + int ret; + + ret = nvme_init_subsystem(ctrl, id); + if (ret) + return ret; + + /* + * Check for quirks. Quirk can depend on firmware version, + * so, in principle, the set of quirks present can change + * across a reset. As a possible future enhancement, we + * could re-scan for quirks every time we reinitialize + * the device, but we'd have to make sure that the driver + * behaves intelligently if the quirks change. + */ + for (i = 0; i < ARRAY_SIZE(core_quirks); i++) { + if (quirk_matches(id, &core_quirks[i])) + ctrl->quirks |= core_quirks[i].quirks; + } + + return 0; +} + static int nvme_init_identify_transport(struct nvme_ctrl *ctrl, struct nvme_id_ctrl *id) {
@@ -3151,24 +3177,9 @@ int nvme_init_identify(struct nvme_ctrl *ctrl) ctrl->cntlid = le16_to_cpu(id->cntlid); if (!ctrl->identified) { - unsigned int i; - - ret = nvme_init_subsystem(ctrl, id); + ret = nvme_init_ctrl_subsys_and_quirks(ctrl, id); if (ret) goto out_free; - - /* - * Check for quirks. Quirk can depend on firmware version, - * so, in principle, the set of quirks present can change - * across a reset. As a possible future enhancement, we - * could re-scan for quirks every time we reinitialize - * the device, but we'd have to make sure that the driver - * behaves intelligently if the quirks change. - */ - for (i = 0; i < ARRAY_SIZE(core_quirks); i++) { - if (quirk_matches(id, &core_quirks[i])) - ctrl->quirks |= core_quirks[i].quirks; - } } if (force_apst && (ctrl->quirks & NVME_QUIRK_NO_DEEPEST_PS)) {
--
2.22.1
_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme