From 8d734dd915d4c060a53b8bb9d9e9eb7e79676884 Mon Sep 17 00:00:00 2001 From: Fei Li Date: Wed, 19 Oct 2022 11:05:54 +0800 Subject: [PATCH] hv: pci: use mmio_read/write directly Use mmio_read/write directly. Tracked-On: #8255 Signed-off-by: Fei Li --- hypervisor/hw/pci.c | 29 +++-------------------------- 1 file changed, 3 insertions(+), 26 deletions(-) diff --git a/hypervisor/hw/pci.c b/hypervisor/hw/pci.c index bac7b8dc9..be5c32d77 100644 --- a/hypervisor/hw/pci.c +++ b/hypervisor/hw/pci.c @@ -179,24 +179,10 @@ static uint32_t pci_mmcfg_read_cfg(union pci_bdf bdf, uint32_t offset, uint32_t { uint32_t addr = mmcfg_off_to_address(bdf, offset); void *hva = hpa2hva(addr); - uint32_t val; - ASSERT(pci_is_valid_access(offset, bytes), "the offset should be aligned with 2/4 byte\n"); - switch (bytes) { - case 1U: - val = (uint32_t)mmio_read8(hva); - break; - case 2U: - val = (uint32_t)mmio_read16(hva); - break; - default: - val = mmio_read32(hva); - break; - } - - return val; + return (uint32_t)mmio_read(hva, bytes); } /* @@ -211,17 +197,8 @@ static void pci_mmcfg_write_cfg(union pci_bdf bdf, uint32_t offset, uint32_t byt void *hva = hpa2hva(addr); ASSERT(pci_is_valid_access(offset, bytes), "the offset should be aligned with 2/4 byte\n"); - switch (bytes) { - case 1U: - mmio_write8((uint8_t)val, hva); - break; - case 2U: - mmio_write16((uint16_t)val, hva); - break; - default: - mmio_write32(val, hva); - break; - } + + mmio_write(hva, bytes, val); } static const struct pci_cfg_ops pci_mmcfg_cfg_ops = {