From 260c0cd3d985e51b15870ff47e17b7b930efbda1 Mon Sep 17 00:00:00 2001 From: Isaku Yamahata Date: Fri, 30 Oct 2009 21:21:20 +0900 Subject: [PATCH] pci: use range helper functions. clean up pci_default_write_config() by the range helper functions. Suggested by Michael S. Tsirkin Cc: Michael S. Tsirkin Signed-off-by: Isaku Yamahata Signed-off-by: Anthony Liguori --- hw/pci.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/hw/pci.c b/hw/pci.c index 67133b661d..d9fd564b49 100644 --- a/hw/pci.c +++ b/hw/pci.c @@ -699,19 +699,15 @@ uint32_t pci_default_read_config(PCIDevice *d, void pci_default_write_config(PCIDevice *d, uint32_t addr, uint32_t val, int l) { - uint8_t orig[PCI_CONFIG_SPACE_SIZE]; int i; uint32_t config_size = pci_config_size(d); - /* not efficient, but simple */ - memcpy(orig, d->config, PCI_CONFIG_SPACE_SIZE); for(i = 0; i < l && addr < config_size; val >>= 8, ++i, ++addr) { uint8_t wmask = d->wmask[addr]; d->config[addr] = (d->config[addr] & ~wmask) | (val & wmask); } - if (memcmp(orig + PCI_BASE_ADDRESS_0, d->config + PCI_BASE_ADDRESS_0, 24) - || ((orig[PCI_COMMAND] ^ d->config[PCI_COMMAND]) - & (PCI_COMMAND_MEMORY | PCI_COMMAND_IO))) + if (ranges_overlap(addr, l, PCI_BASE_ADDRESS_0, 24) || + range_covers_byte(addr, l, PCI_COMMAND)) pci_update_mappings(d); } -- 2.11.0