On Mon, Jun 06, 2016 at 02:46:30PM +0200, Alexander Gordeev wrote: > Cc: Thomas Huth <thuth@xxxxxxxxxx> > Cc: Andrew Jones <drjones@xxxxxxxxxx> > Signed-off-by: Alexander Gordeev <agordeev@xxxxxxxxxx> > --- > lib/pci.c | 38 ++++++++++++++++++++------------------ > lib/pci.h | 2 +- > 2 files changed, 21 insertions(+), 19 deletions(-) > > diff --git a/lib/pci.c b/lib/pci.c > index 0058d70c888d..bfdaebac862e 100644 > --- a/lib/pci.c > +++ b/lib/pci.c > @@ -10,34 +10,36 @@ > /* Scan bus look for a specific device. Only bus 0 scanned for now. */ > pcidevaddr_t pci_find_dev(uint16_t vendor_id, uint16_t device_id) > { > - unsigned dev; > - for (dev = 0; dev < 256; ++dev) { > - uint32_t id = pci_config_read(dev, 0); > - if ((id & 0xFFFF) == vendor_id && (id >> 16) == device_id) { > - return dev; > - } > - } > - return PCIDEVADDR_INVALID; > + pcidevaddr_t dev; > + > + for (dev = 0; dev < 256; ++dev) { > + uint32_t id = pci_config_read(dev, 0); > + > + if ((id & 0xFFFF) == vendor_id && (id >> 16) == device_id) > + return dev; > + } > + > + return PCIDEVADDR_INVALID; > } > > unsigned long pci_bar_addr(pcidevaddr_t dev, int bar_num) > { > - uint32_t bar = pci_config_read(dev, PCI_BASE_ADDRESS_0 + bar_num * 4); > - if (bar & PCI_BASE_ADDRESS_SPACE_IO) { > - return bar & PCI_BASE_ADDRESS_IO_MASK; > - } else { > - return bar & PCI_BASE_ADDRESS_MEM_MASK; > - } > + uint32_t bar = pci_config_read(dev, PCI_BASE_ADDRESS_0 + bar_num * 4); > + > + if (bar & PCI_BASE_ADDRESS_SPACE_IO) > + return bar & PCI_BASE_ADDRESS_IO_MASK; > + else > + return bar & PCI_BASE_ADDRESS_MEM_MASK; > } > > bool pci_bar_is_memory(pcidevaddr_t dev, int bar_num) > { > - uint32_t bar = pci_config_read(dev, PCI_BASE_ADDRESS_0 + bar_num * 4); > - return !(bar & PCI_BASE_ADDRESS_SPACE_IO); > + uint32_t bar = pci_config_read(dev, PCI_BASE_ADDRESS_0 + bar_num * 4); no blank line here? > + return !(bar & PCI_BASE_ADDRESS_SPACE_IO); > } > > bool pci_bar_is_valid(pcidevaddr_t dev, int bar_num) > { > - uint32_t bar = pci_config_read(dev, PCI_BASE_ADDRESS_0 + bar_num * 4); > - return bar; > + uint32_t bar = pci_config_read(dev, PCI_BASE_ADDRESS_0 + bar_num * 4); > + return bar; can just do return pci_config_read(...) > } > diff --git a/lib/pci.h b/lib/pci.h > index 9160cfb5950d..88dc47c1f48d 100644 > --- a/lib/pci.h > +++ b/lib/pci.h > @@ -12,7 +12,7 @@ > > typedef uint16_t pcidevaddr_t; > enum { > - PCIDEVADDR_INVALID = 0xffff, > + PCIDEVADDR_INVALID = 0xffff, > }; > pcidevaddr_t pci_find_dev(uint16_t vendor_id, uint16_t device_id); > unsigned long pci_bar_addr(pcidevaddr_t dev, int bar_num); > -- > 1.8.3.1 > -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html