]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/pci/probe.c
PCI: remove unused resource assignment in pci_read_bridge_bases()
[linux-2.6-omap-h63xx.git] / drivers / pci / probe.c
index afb9f1c0bc2867df2489be390156612f4cf430da..003a9b3c293fd6937682d061f2b4e242ab673adc 100644 (file)
@@ -42,72 +42,6 @@ int no_pci_devices(void)
 }
 EXPORT_SYMBOL(no_pci_devices);
 
-#ifdef HAVE_PCI_LEGACY
-/**
- * pci_create_legacy_files - create legacy I/O port and memory files
- * @b: bus to create files under
- *
- * Some platforms allow access to legacy I/O port and ISA memory space on
- * a per-bus basis.  This routine creates the files and ties them into
- * their associated read, write and mmap files from pci-sysfs.c
- *
- * On error unwind, but don't propogate the error to the caller
- * as it is ok to set up the PCI bus without these files.
- */
-static void pci_create_legacy_files(struct pci_bus *b)
-{
-       int error;
-
-       b->legacy_io = kzalloc(sizeof(struct bin_attribute) * 2,
-                              GFP_ATOMIC);
-       if (!b->legacy_io)
-               goto kzalloc_err;
-
-       b->legacy_io->attr.name = "legacy_io";
-       b->legacy_io->size = 0xffff;
-       b->legacy_io->attr.mode = S_IRUSR | S_IWUSR;
-       b->legacy_io->read = pci_read_legacy_io;
-       b->legacy_io->write = pci_write_legacy_io;
-       error = device_create_bin_file(&b->dev, b->legacy_io);
-       if (error)
-               goto legacy_io_err;
-
-       /* Allocated above after the legacy_io struct */
-       b->legacy_mem = b->legacy_io + 1;
-       b->legacy_mem->attr.name = "legacy_mem";
-       b->legacy_mem->size = 1024*1024;
-       b->legacy_mem->attr.mode = S_IRUSR | S_IWUSR;
-       b->legacy_mem->mmap = pci_mmap_legacy_mem;
-       error = device_create_bin_file(&b->dev, b->legacy_mem);
-       if (error)
-               goto legacy_mem_err;
-
-       return;
-
-legacy_mem_err:
-       device_remove_bin_file(&b->dev, b->legacy_io);
-legacy_io_err:
-       kfree(b->legacy_io);
-       b->legacy_io = NULL;
-kzalloc_err:
-       printk(KERN_WARNING "pci: warning: could not create legacy I/O port "
-              "and ISA memory resources to sysfs\n");
-       return;
-}
-
-void pci_remove_legacy_files(struct pci_bus *b)
-{
-       if (b->legacy_io) {
-               device_remove_bin_file(&b->dev, b->legacy_io);
-               device_remove_bin_file(&b->dev, b->legacy_mem);
-               kfree(b->legacy_io); /* both are allocated here */
-       }
-}
-#else /* !HAVE_PCI_LEGACY */
-static inline void pci_create_legacy_files(struct pci_bus *bus) { return; }
-void pci_remove_legacy_files(struct pci_bus *bus) { return; }
-#endif /* HAVE_PCI_LEGACY */
-
 /*
  * PCI Bus Class Devices
  */
@@ -364,9 +298,6 @@ void __devinit pci_read_bridge_bases(struct pci_bus *child)
                        child->resource[i] = child->parent->resource[i - 3];
        }
 
-       for(i=0; i<3; i++)
-               child->resource[i] = &dev->resource[PCI_BRIDGE_RESOURCES+i];
-
        res = child->resource[0];
        pci_read_config_byte(dev, PCI_IO_BASE, &io_base_lo);
        pci_read_config_byte(dev, PCI_IO_LIMIT, &io_limit_lo);
@@ -546,19 +477,27 @@ int __devinit pci_scan_bridge(struct pci_bus *bus, struct pci_dev *dev, int max,
        int is_cardbus = (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS);
        u32 buses, i, j = 0;
        u16 bctl;
+       int broken = 0;
 
        pci_read_config_dword(dev, PCI_PRIMARY_BUS, &buses);
 
        dev_dbg(&dev->dev, "scanning behind bridge, config %06x, pass %d\n",
                buses & 0xffffff, pass);
 
+       /* Check if setup is sensible at all */
+       if (!pass &&
+           ((buses & 0xff) != bus->number || ((buses >> 8) & 0xff) <= bus->number)) {
+               dev_dbg(&dev->dev, "bus configuration invalid, reconfiguring\n");
+               broken = 1;
+       }
+
        /* Disable MasterAbortMode during probing to avoid reporting
           of bus errors (in some architectures) */ 
        pci_read_config_word(dev, PCI_BRIDGE_CONTROL, &bctl);
        pci_write_config_word(dev, PCI_BRIDGE_CONTROL,
                              bctl & ~PCI_BRIDGE_CTL_MASTER_ABORT);
 
-       if ((buses & 0xffff00) && !pcibios_assign_all_busses() && !is_cardbus) {
+       if ((buses & 0xffff00) && !pcibios_assign_all_busses() && !is_cardbus && !broken) {
                unsigned int cmax, busnr;
                /*
                 * Bus already configured by firmware, process it in the first
@@ -596,7 +535,7 @@ int __devinit pci_scan_bridge(struct pci_bus *bus, struct pci_dev *dev, int max,
                 * do in the second pass.
                 */
                if (!pass) {
-                       if (pcibios_assign_all_busses())
+                       if (pcibios_assign_all_busses() || broken)
                                /* Temporarily disable forwarding of the
                                   configuration cycles on all bridges in
                                   this bus segment to avoid possible