summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLucas Stach <dev@lynxeye.de>2014-11-12 21:24:35 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2014-11-17 08:35:49 +0100
commitcc9026585ae3f93797de7625b2ac9612537e44bb (patch)
treeef971289f4d00004fcc94fec3d905011512423ab
parent8e2c7b3de35488363ba331466fa45f75ae93fb4f (diff)
downloadbarebox-cc9026585ae3f93797de7625b2ac9612537e44bb.tar.gz
pci: correct BAR size calculation
The previous math would return negative sizes for some BARs. Signed-off-by: Lucas Stach <dev@lynxeye.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r--drivers/pci/pci.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index ba9d097..87c2fca 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -154,7 +154,7 @@ static void setup_device(struct pci_dev *dev, int max_bar)
}
if (mask & 0x01) { /* IO */
- size = -(mask & 0xfffffffe);
+ size = ((~(mask & 0xfffffffe)) & 0xffff) + 1;
DBG(" PCI: pbar%d: mask=%08x io %d bytes\n", bar, mask, size);
if (last_io + size >
dev->bus->resource[PCI_BUS_RESOURCE_IO]->end) {
@@ -167,7 +167,7 @@ static void setup_device(struct pci_dev *dev, int max_bar)
last_io += size;
} else if ((mask & PCI_BASE_ADDRESS_MEM_PREFETCH) &&
last_mem_pref) /* prefetchable MEM */ {
- size = -(mask & 0xfffffff0);
+ size = (~(mask & 0xfffffff0)) + 1;
DBG(" PCI: pbar%d: mask=%08x P memory %d bytes\n",
bar, mask, size);
if (last_mem_pref + size >
@@ -181,7 +181,7 @@ static void setup_device(struct pci_dev *dev, int max_bar)
last_addr = last_mem_pref;
last_mem_pref += size;
} else { /* non-prefetch MEM */
- size = -(mask & 0xfffffff0);
+ size = (~(mask & 0xfffffff0)) + 1;
DBG(" PCI: pbar%d: mask=%08x NP memory %d bytes\n",
bar, mask, size);
if (last_mem + size >