diff options
author | Klaus Jensen <k.jensen@samsung.com> | 2020-06-09 21:03:30 +0200 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2020-06-17 14:53:40 +0200 |
commit | 945cb8f4c20e01241ede4ab33593d18812a3c1e4 (patch) | |
tree | 32b55c4fc33fa7349a7838ef59c31e789fb846e3 /hw | |
parent | 0c35ad46b6ffec663f94e0ef47b8df856e180f98 (diff) | |
download | qemu-945cb8f4c20e01241ede4ab33593d18812a3c1e4.zip |
hw/block/nvme: factor out controller identify setup
Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com>
Reviewed-by: Keith Busch <kbusch@kernel.org>
Message-Id: <20200609190333.59390-20-its@irrelevant.dk>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'hw')
-rw-r--r-- | hw/block/nvme.c | 49 |
1 files changed, 26 insertions, 23 deletions
diff --git a/hw/block/nvme.c b/hw/block/nvme.c index 02a6a97df9..e10fc774fc 100644 --- a/hw/block/nvme.c +++ b/hw/block/nvme.c @@ -1533,32 +1533,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; - - 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); + uint8_t *pci_conf = pci_dev->config; - 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", ' '); @@ -1591,6 +1570,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); |