diff --git a/hw/pci-host/piix.c b/hw/pci-host/piix.c index 7b2fbf9..42f847d 100644 --- a/hw/pci-host/piix.c +++ b/hw/pci-host/piix.c @@ -764,7 +764,6 @@ static int host_pci_config_read(int pos, int len, uint32_t val) /* Access real host bridge. */ int rc = snprintf(path, size, "/sys/bus/pci/devices/%04x:%02x:%02x.%d/%s", 0, 0, 0, 0, "config"); - int ret = 0; if (rc >= size || rc < 0) { return -ENODEV; @@ -774,20 +773,15 @@ static int host_pci_config_read(int pos, int len, uint32_t val) if (config_fd < 0) { return -ENODEV; } - - if (lseek(config_fd, pos, SEEK_SET) != pos) { - ret = -errno; - goto out; - } do { - rc = read(config_fd, (uint8_t *)&val, len); + rc = pread(config_fd, (uint8_t *)&val, len, pos); } while (rc < 0 && (errno == EINTR || errno == EAGAIN)); + close(config_fd); if (rc != len) { - ret = -errno; + return -errno; } -out: - close(config_fd); - return ret; + + return 0; } static int igd_pt_i440fx_initfn(struct PCIDevice *pci_dev)