diff options
Diffstat (limited to 'drivers/pci/probe.c')
| -rw-r--r-- | drivers/pci/probe.c | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index adfad4fd6a13..a10ed9dab2c2 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c | |||
| @@ -33,10 +33,9 @@ LIST_HEAD(pci_devices); | |||
| 33 | */ | 33 | */ |
| 34 | static void pci_create_legacy_files(struct pci_bus *b) | 34 | static void pci_create_legacy_files(struct pci_bus *b) |
| 35 | { | 35 | { |
| 36 | b->legacy_io = kmalloc(sizeof(struct bin_attribute) * 2, | 36 | b->legacy_io = kzalloc(sizeof(struct bin_attribute) * 2, |
| 37 | GFP_ATOMIC); | 37 | GFP_ATOMIC); |
| 38 | if (b->legacy_io) { | 38 | if (b->legacy_io) { |
| 39 | memset(b->legacy_io, 0, sizeof(struct bin_attribute) * 2); | ||
| 40 | b->legacy_io->attr.name = "legacy_io"; | 39 | b->legacy_io->attr.name = "legacy_io"; |
| 41 | b->legacy_io->size = 0xffff; | 40 | b->legacy_io->size = 0xffff; |
| 42 | b->legacy_io->attr.mode = S_IRUSR | S_IWUSR; | 41 | b->legacy_io->attr.mode = S_IRUSR | S_IWUSR; |
| @@ -320,9 +319,8 @@ static struct pci_bus * __devinit pci_alloc_bus(void) | |||
| 320 | { | 319 | { |
| 321 | struct pci_bus *b; | 320 | struct pci_bus *b; |
| 322 | 321 | ||
| 323 | b = kmalloc(sizeof(*b), GFP_KERNEL); | 322 | b = kzalloc(sizeof(*b), GFP_KERNEL); |
| 324 | if (b) { | 323 | if (b) { |
| 325 | memset(b, 0, sizeof(*b)); | ||
| 326 | INIT_LIST_HEAD(&b->node); | 324 | INIT_LIST_HEAD(&b->node); |
| 327 | INIT_LIST_HEAD(&b->children); | 325 | INIT_LIST_HEAD(&b->children); |
| 328 | INIT_LIST_HEAD(&b->devices); | 326 | INIT_LIST_HEAD(&b->devices); |
| @@ -347,6 +345,7 @@ pci_alloc_child_bus(struct pci_bus *parent, struct pci_dev *bridge, int busnr) | |||
| 347 | child->parent = parent; | 345 | child->parent = parent; |
| 348 | child->ops = parent->ops; | 346 | child->ops = parent->ops; |
| 349 | child->sysdata = parent->sysdata; | 347 | child->sysdata = parent->sysdata; |
| 348 | child->bus_flags = parent->bus_flags; | ||
| 350 | child->bridge = get_device(&bridge->dev); | 349 | child->bridge = get_device(&bridge->dev); |
| 351 | 350 | ||
| 352 | child->class_dev.class = &pcibus_class; | 351 | child->class_dev.class = &pcibus_class; |
| @@ -456,7 +455,7 @@ int __devinit pci_scan_bridge(struct pci_bus *bus, struct pci_dev * dev, int max | |||
| 456 | * pass and just note the configuration. | 455 | * pass and just note the configuration. |
| 457 | */ | 456 | */ |
| 458 | if (pass) | 457 | if (pass) |
| 459 | return max; | 458 | goto out; |
| 460 | busnr = (buses >> 8) & 0xFF; | 459 | busnr = (buses >> 8) & 0xFF; |
| 461 | 460 | ||
| 462 | /* | 461 | /* |
| @@ -466,12 +465,12 @@ int __devinit pci_scan_bridge(struct pci_bus *bus, struct pci_dev * dev, int max | |||
| 466 | if (pci_find_bus(pci_domain_nr(bus), busnr)) { | 465 | if (pci_find_bus(pci_domain_nr(bus), busnr)) { |
| 467 | printk(KERN_INFO "PCI: Bus %04x:%02x already known\n", | 466 | printk(KERN_INFO "PCI: Bus %04x:%02x already known\n", |
| 468 | pci_domain_nr(bus), busnr); | 467 | pci_domain_nr(bus), busnr); |
| 469 | return max; | 468 | goto out; |
| 470 | } | 469 | } |
| 471 | 470 | ||
| 472 | child = pci_add_new_bus(bus, dev, busnr); | 471 | child = pci_add_new_bus(bus, dev, busnr); |
| 473 | if (!child) | 472 | if (!child) |
| 474 | return max; | 473 | goto out; |
| 475 | child->primary = buses & 0xFF; | 474 | child->primary = buses & 0xFF; |
| 476 | child->subordinate = (buses >> 16) & 0xFF; | 475 | child->subordinate = (buses >> 16) & 0xFF; |
| 477 | child->bridge_ctl = bctl; | 476 | child->bridge_ctl = bctl; |
| @@ -496,7 +495,7 @@ int __devinit pci_scan_bridge(struct pci_bus *bus, struct pci_dev * dev, int max | |||
| 496 | bus ranges. */ | 495 | bus ranges. */ |
| 497 | pci_write_config_dword(dev, PCI_PRIMARY_BUS, | 496 | pci_write_config_dword(dev, PCI_PRIMARY_BUS, |
| 498 | buses & ~0xffffff); | 497 | buses & ~0xffffff); |
| 499 | return max; | 498 | goto out; |
| 500 | } | 499 | } |
| 501 | 500 | ||
| 502 | /* Clear errors */ | 501 | /* Clear errors */ |
| @@ -505,7 +504,7 @@ int __devinit pci_scan_bridge(struct pci_bus *bus, struct pci_dev * dev, int max | |||
| 505 | /* Prevent assigning a bus number that already exists. | 504 | /* Prevent assigning a bus number that already exists. |
| 506 | * This can happen when a bridge is hot-plugged */ | 505 | * This can happen when a bridge is hot-plugged */ |
| 507 | if (pci_find_bus(pci_domain_nr(bus), max+1)) | 506 | if (pci_find_bus(pci_domain_nr(bus), max+1)) |
| 508 | return max; | 507 | goto out; |
| 509 | child = pci_add_new_bus(bus, dev, ++max); | 508 | child = pci_add_new_bus(bus, dev, ++max); |
| 510 | buses = (buses & 0xff000000) | 509 | buses = (buses & 0xff000000) |
| 511 | | ((unsigned int)(child->primary) << 0) | 510 | | ((unsigned int)(child->primary) << 0) |
| @@ -537,6 +536,11 @@ int __devinit pci_scan_bridge(struct pci_bus *bus, struct pci_dev * dev, int max | |||
| 537 | pci_fixup_parent_subordinate_busnr(child, max); | 536 | pci_fixup_parent_subordinate_busnr(child, max); |
| 538 | /* Now we can scan all subordinate buses... */ | 537 | /* Now we can scan all subordinate buses... */ |
| 539 | max = pci_scan_child_bus(child); | 538 | max = pci_scan_child_bus(child); |
| 539 | /* | ||
| 540 | * now fix it up again since we have found | ||
| 541 | * the real value of max. | ||
| 542 | */ | ||
| 543 | pci_fixup_parent_subordinate_busnr(child, max); | ||
| 540 | } else { | 544 | } else { |
| 541 | /* | 545 | /* |
| 542 | * For CardBus bridges, we leave 4 bus numbers | 546 | * For CardBus bridges, we leave 4 bus numbers |
| @@ -576,8 +580,6 @@ int __devinit pci_scan_bridge(struct pci_bus *bus, struct pci_dev * dev, int max | |||
| 576 | pci_write_config_byte(dev, PCI_SUBORDINATE_BUS, max); | 580 | pci_write_config_byte(dev, PCI_SUBORDINATE_BUS, max); |
| 577 | } | 581 | } |
| 578 | 582 | ||
| 579 | pci_write_config_word(dev, PCI_BRIDGE_CONTROL, bctl); | ||
| 580 | |||
| 581 | sprintf(child->name, (is_cardbus ? "PCI CardBus #%02x" : "PCI Bus #%02x"), child->number); | 583 | sprintf(child->name, (is_cardbus ? "PCI CardBus #%02x" : "PCI Bus #%02x"), child->number); |
| 582 | 584 | ||
| 583 | while (bus->parent) { | 585 | while (bus->parent) { |
| @@ -585,17 +587,22 @@ int __devinit pci_scan_bridge(struct pci_bus *bus, struct pci_dev * dev, int max | |||
| 585 | (child->number > bus->subordinate) || | 587 | (child->number > bus->subordinate) || |
| 586 | (child->number < bus->number) || | 588 | (child->number < bus->number) || |
| 587 | (child->subordinate < bus->number)) { | 589 | (child->subordinate < bus->number)) { |
| 588 | printk(KERN_WARNING "PCI: Bus #%02x (-#%02x) may be " | 590 | printk(KERN_WARNING "PCI: Bus #%02x (-#%02x) is " |
| 589 | "hidden behind%s bridge #%02x (-#%02x)%s\n", | 591 | "hidden behind%s bridge #%02x (-#%02x)%s\n", |
| 590 | child->number, child->subordinate, | 592 | child->number, child->subordinate, |
| 591 | bus->self->transparent ? " transparent" : " ", | 593 | bus->self->transparent ? " transparent" : " ", |
| 592 | bus->number, bus->subordinate, | 594 | bus->number, bus->subordinate, |
| 593 | pcibios_assign_all_busses() ? " " : | 595 | pcibios_assign_all_busses() ? " " : |
| 594 | " (try 'pci=assign-busses')"); | 596 | " (try 'pci=assign-busses')"); |
| 597 | printk(KERN_WARNING "Please report the result to " | ||
| 598 | "linux-kernel to fix this permanently\n"); | ||
| 595 | } | 599 | } |
| 596 | bus = bus->parent; | 600 | bus = bus->parent; |
| 597 | } | 601 | } |
| 598 | 602 | ||
| 603 | out: | ||
| 604 | pci_write_config_word(dev, PCI_BRIDGE_CONTROL, bctl); | ||
| 605 | |||
| 599 | return max; | 606 | return max; |
| 600 | } | 607 | } |
| 601 | 608 | ||
| @@ -788,11 +795,10 @@ pci_scan_device(struct pci_bus *bus, int devfn) | |||
| 788 | if (pci_bus_read_config_byte(bus, devfn, PCI_HEADER_TYPE, &hdr_type)) | 795 | if (pci_bus_read_config_byte(bus, devfn, PCI_HEADER_TYPE, &hdr_type)) |
| 789 | return NULL; | 796 | return NULL; |
| 790 | 797 | ||
| 791 | dev = kmalloc(sizeof(struct pci_dev), GFP_KERNEL); | 798 | dev = kzalloc(sizeof(struct pci_dev), GFP_KERNEL); |
| 792 | if (!dev) | 799 | if (!dev) |
| 793 | return NULL; | 800 | return NULL; |
| 794 | 801 | ||
| 795 | memset(dev, 0, sizeof(struct pci_dev)); | ||
| 796 | dev->bus = bus; | 802 | dev->bus = bus; |
| 797 | dev->sysdata = bus->sysdata; | 803 | dev->sysdata = bus->sysdata; |
| 798 | dev->dev.parent = bus->bridge; | 804 | dev->dev.parent = bus->bridge; |
