[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v5 18/18] nvme: factor out controller identify setup
From: |
Klaus Jensen |
Subject: |
[PATCH v5 18/18] nvme: factor out controller identify setup |
Date: |
Tue, 5 May 2020 07:48:40 +0200 |
From: Klaus Jensen <address@hidden>
Signed-off-by: Klaus Jensen <address@hidden>
Reviewed-by: Philippe Mathieu-Daudé <address@hidden>
Reviewed-by: Maxim Levitsky <address@hidden>
Reviewed-by: Keith Busch <address@hidden>
---
hw/block/nvme.c | 49 ++++++++++++++++++++++++++-----------------------
1 file changed, 26 insertions(+), 23 deletions(-)
diff --git a/hw/block/nvme.c b/hw/block/nvme.c
index 6454f3810e5b..73489a1e0eb6 100644
--- a/hw/block/nvme.c
+++ b/hw/block/nvme.c
@@ -1531,32 +1531,11 @@ static void nvme_init_pci(NvmeCtrl *n, PCIDevice
*pci_dev)
}
}
-static void nvme_realize(PCIDevice *pci_dev, Error **errp)
+static void nvme_init_ctrl(NvmeCtrl *n, PCIDevice *pci_dev)
{
- NvmeCtrl *n = NVME(pci_dev);
NvmeIdCtrl *id = &n->id_ctrl;
- Error *local_err = NULL;
+ uint8_t *pci_conf = pci_dev->config;
- int i;
- uint8_t *pci_conf;
-
- nvme_check_constraints(n, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
- return;
- }
-
- nvme_init_state(n);
-
- nvme_init_blk(n, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
- return;
- }
-
- nvme_init_pci(n, pci_dev);
-
- pci_conf = pci_dev->config;
id->vid = cpu_to_le16(pci_get_word(pci_conf + PCI_VENDOR_ID));
id->ssvid = cpu_to_le16(pci_get_word(pci_conf + PCI_SUBSYSTEM_VENDOR_ID));
strpadcpy((char *)id->mn, sizeof(id->mn), "QEMU NVMe Ctrl", ' ');
@@ -1589,6 +1568,30 @@ static void nvme_realize(PCIDevice *pci_dev, Error
**errp)
n->bar.vs = 0x00010200;
n->bar.intmc = n->bar.intms = 0;
+}
+
+static void nvme_realize(PCIDevice *pci_dev, Error **errp)
+{
+ NvmeCtrl *n = NVME(pci_dev);
+ Error *local_err = NULL;
+
+ int i;
+
+ nvme_check_constraints(n, &local_err);
+ if (local_err) {
+ error_propagate(errp, local_err);
+ return;
+ }
+
+ nvme_init_state(n);
+ nvme_init_blk(n, &local_err);
+ if (local_err) {
+ error_propagate(errp, local_err);
+ return;
+ }
+
+ nvme_init_pci(n, pci_dev);
+ nvme_init_ctrl(n, pci_dev);
for (i = 0; i < n->num_namespaces; i++) {
nvme_init_namespace(n, &n->namespaces[i], &local_err);
--
2.26.2
- [PATCH v5 07/18] nvme: add max_ioqpairs device parameter, (continued)
- [PATCH v5 07/18] nvme: add max_ioqpairs device parameter, Klaus Jensen, 2020/05/05
- [PATCH v5 15/18] nvme: factor out cmb setup, Klaus Jensen, 2020/05/05
- [PATCH v5 14/18] nvme: factor out pci setup, Klaus Jensen, 2020/05/05
- [PATCH v5 09/18] nvme: factor out property/constraint checks, Klaus Jensen, 2020/05/05
- [PATCH v5 11/18] nvme: factor out block backend setup, Klaus Jensen, 2020/05/05
- [PATCH v5 12/18] nvme: add namespace helpers, Klaus Jensen, 2020/05/05
- [PATCH v5 17/18] nvme: do cmb/pmr init as part of pci init, Klaus Jensen, 2020/05/05
- [PATCH v5 13/18] nvme: factor out namespace setup, Klaus Jensen, 2020/05/05
- [PATCH v5 16/18] nvme: factor out pmr setup, Klaus Jensen, 2020/05/05
- [PATCH v5 18/18] nvme: factor out controller identify setup,
Klaus Jensen <=
- Re: [PATCH v5 00/18] nvme: refactoring and cleanups, Philippe Mathieu-Daudé, 2020/05/05
- Re: [PATCH v5 00/18] nvme: refactoring and cleanups, Klaus Jensen, 2020/05/11