[PATCH 05/21] PCI: Convert postscan_setup_bridge() to use a loop

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Simplify postscan_setup_bridge() by folding limit setting code into a
loop. No functional change intended.

Signed-off-by: Andrey Smirnov <andrew.smirnov@xxxxxxxxx>
---
 drivers/pci/pci.c | 26 +++++++-------------------
 1 file changed, 7 insertions(+), 19 deletions(-)

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 02b7f091f7..b5e13e5dbc 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -330,28 +330,16 @@ static void prescan_setup_bridge(struct pci_dev *dev)
 
 static void postscan_setup_bridge(struct pci_dev *dev)
 {
+	int r;
+
 	/* limit subordinate to last used bus number */
 	pci_write_config_byte(dev, PCI_SUBORDINATE_BUS, last[PCI_BUS_RESOURCE_BUSN] - 1);
 
-	if (last[PCI_BUS_RESOURCE_MEM]) {
-		last[PCI_BUS_RESOURCE_MEM] = ALIGN(last[PCI_BUS_RESOURCE_MEM], SZ_1M);
-		pr_debug("bridge NP limit at %pa\n", &last[PCI_BUS_RESOURCE_MEM]);
-		pci_set_limit(dev, PCI_BUS_RESOURCE_MEM,
-			      last[PCI_BUS_RESOURCE_MEM] - 1);
-	}
-
-	if (last[PCI_BUS_RESOURCE_MEM_PREF]) {
-		last[PCI_BUS_RESOURCE_MEM_PREF] = ALIGN(last[PCI_BUS_RESOURCE_MEM_PREF], SZ_1M);
-		pr_debug("bridge P limit at %pa\n", &last[PCI_BUS_RESOURCE_MEM_PREF]);
-		pci_set_limit(dev, PCI_BUS_RESOURCE_MEM_PREF,
-			      last[PCI_BUS_RESOURCE_MEM_PREF] - 1);
-	}
-
-	if (last[PCI_BUS_RESOURCE_IO]) {
-		last[PCI_BUS_RESOURCE_IO] = ALIGN(last[PCI_BUS_RESOURCE_IO], SZ_4K);
-		pr_debug("bridge IO limit at %pa\n", &last[PCI_BUS_RESOURCE_IO]);
-		pci_set_limit(dev, PCI_BUS_RESOURCE_IO,
-			      last[PCI_BUS_RESOURCE_IO] - 1);
+	for (r = PCI_BUS_RESOURCE_IO; r <= PCI_BUS_RESOURCE_MEM_PREF; r++) {
+		if (last[r]) {
+			last[r] = ALIGN(last[r], pci_resource_to_alignment(r));
+			pci_set_limit(dev, r, last[r] - 1);
+		}
 	}
 }
 
-- 
2.20.1


_______________________________________________
barebox mailing list
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux