aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci/bus.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/pci/bus.c')
-rw-r--r--drivers/pci/bus.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/drivers/pci/bus.c b/drivers/pci/bus.c
index 97a8194063b5..cef28a79103f 100644
--- a/drivers/pci/bus.c
+++ b/drivers/pci/bus.c
@@ -41,9 +41,14 @@ pci_bus_alloc_resource(struct pci_bus *bus, struct resource *res,
41 void *alignf_data) 41 void *alignf_data)
42{ 42{
43 int i, ret = -ENOMEM; 43 int i, ret = -ENOMEM;
44 resource_size_t max = -1;
44 45
45 type_mask |= IORESOURCE_IO | IORESOURCE_MEM; 46 type_mask |= IORESOURCE_IO | IORESOURCE_MEM;
46 47
48 /* don't allocate too high if the pref mem doesn't support 64bit*/
49 if (!(res->flags & IORESOURCE_MEM_64))
50 max = PCIBIOS_MAX_MEM_32;
51
47 for (i = 0; i < PCI_BUS_NUM_RESOURCES; i++) { 52 for (i = 0; i < PCI_BUS_NUM_RESOURCES; i++) {
48 struct resource *r = bus->resource[i]; 53 struct resource *r = bus->resource[i];
49 if (!r) 54 if (!r)
@@ -62,7 +67,7 @@ pci_bus_alloc_resource(struct pci_bus *bus, struct resource *res,
62 /* Ok, try it out.. */ 67 /* Ok, try it out.. */
63 ret = allocate_resource(r, res, size, 68 ret = allocate_resource(r, res, size,
64 r->start ? : min, 69 r->start ? : min,
65 -1, align, 70 max, align,
66 alignf, alignf_data); 71 alignf, alignf_data);
67 if (ret == 0) 72 if (ret == 0)
68 break; 73 break;
@@ -201,13 +206,18 @@ void pci_enable_bridges(struct pci_bus *bus)
201 * Walk the given bus, including any bridged devices 206 * Walk the given bus, including any bridged devices
202 * on buses under this bus. Call the provided callback 207 * on buses under this bus. Call the provided callback
203 * on each device found. 208 * on each device found.
209 *
210 * We check the return of @cb each time. If it returns anything
211 * other than 0, we break out.
212 *
204 */ 213 */
205void pci_walk_bus(struct pci_bus *top, void (*cb)(struct pci_dev *, void *), 214void pci_walk_bus(struct pci_bus *top, int (*cb)(struct pci_dev *, void *),
206 void *userdata) 215 void *userdata)
207{ 216{
208 struct pci_dev *dev; 217 struct pci_dev *dev;
209 struct pci_bus *bus; 218 struct pci_bus *bus;
210 struct list_head *next; 219 struct list_head *next;
220 int retval;
211 221
212 bus = top; 222 bus = top;
213 down_read(&pci_bus_sem); 223 down_read(&pci_bus_sem);
@@ -231,8 +241,10 @@ void pci_walk_bus(struct pci_bus *top, void (*cb)(struct pci_dev *, void *),
231 241
232 /* Run device routines with the device locked */ 242 /* Run device routines with the device locked */
233 down(&dev->dev.sem); 243 down(&dev->dev.sem);
234 cb(dev, userdata); 244 retval = cb(dev, userdata);
235 up(&dev->dev.sem); 245 up(&dev->dev.sem);
246 if (retval)
247 break;
236 } 248 }
237 up_read(&pci_bus_sem); 249 up_read(&pci_bus_sem);
238} 250}