fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / arch / alpha / kernel / pci.c
index b4c64d4..3c10b9a 100644 (file)
@@ -12,7 +12,6 @@
  * Nov 2000, Ivan Kokshaysky <ink@jurassic.park.msu.ru>
  *          PCI-PCI bridges cleanup
  */
-#include <linux/config.h>
 #include <linux/string.h>
 #include <linux/pci.h>
 #include <linux/init.h>
@@ -124,12 +123,12 @@ DECLARE_PCI_FIXUP_FINAL(PCI_ANY_ID, PCI_ANY_ID, pcibios_fixup_final);
 
 void
 pcibios_align_resource(void *data, struct resource *res,
-                      unsigned long size, unsigned long align)
+                      resource_size_t size, resource_size_t align)
 {
        struct pci_dev *dev = data;
        struct pci_controller *hose = dev->sysdata;
        unsigned long alignto;
-       unsigned long start = res->start;
+       resource_size_t start = res->start;
 
        if (res->flags & IORESOURCE_IO) {
                /* Make sure we start at our min on all hoses */
@@ -227,7 +226,7 @@ pdev_save_srm_config(struct pci_dev *dev)
        tmp->next = srm_saved_configs;
        tmp->dev = dev;
 
-       pci_save_state(dev, tmp->regs);
+       pci_save_state(dev);
 
        srm_saved_configs = tmp;
 }
@@ -243,7 +242,7 @@ pci_restore_srm_config(void)
 
        /* Restore SRM config. */
        for (tmp = srm_saved_configs; tmp; tmp = tmp->next) {
-               pci_restore_state(tmp->dev, tmp->regs);
+               pci_restore_state(tmp->dev);
        }
 }
 #endif
@@ -280,7 +279,6 @@ pcibios_fixup_bus(struct pci_bus *bus)
        /* Propagate hose info into the subordinate devices.  */
 
        struct pci_controller *hose = bus->sysdata;
-       struct list_head *ln;
        struct pci_dev *dev = bus->self;
 
        if (!dev) {
@@ -304,9 +302,7 @@ pcibios_fixup_bus(struct pci_bus *bus)
                pcibios_fixup_device_resources(dev, bus);
        } 
 
-       for (ln = bus->devices.next; ln != &bus->devices; ln = ln->next) {
-               struct pci_dev *dev = pci_dev_b(ln);
-
+       list_for_each_entry(dev, &bus->devices, bus_list) {
                pdev_save_srm_config(dev);
                if ((dev->class >> 8) != PCI_CLASS_BRIDGE_PCI)
                        pcibios_fixup_device_resources(dev, bus);
@@ -353,8 +349,24 @@ pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region,
        region->end = res->end - offset;
 }
 
+void pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res,
+                            struct pci_bus_region *region)
+{
+       struct pci_controller *hose = (struct pci_controller *)dev->sysdata;
+       unsigned long offset = 0;
+
+       if (res->flags & IORESOURCE_IO)
+               offset = hose->io_space->start;
+       else if (res->flags & IORESOURCE_MEM)
+               offset = hose->mem_space->start;
+
+       res->start = region->start + offset;
+       res->end = region->end + offset;
+}
+
 #ifdef CONFIG_HOTPLUG
 EXPORT_SYMBOL(pcibios_resource_to_bus);
+EXPORT_SYMBOL(pcibios_bus_to_resource);
 #endif
 
 int
@@ -403,11 +415,10 @@ pcibios_set_master(struct pci_dev *dev)
 static void __init
 pcibios_claim_one_bus(struct pci_bus *b)
 {
-       struct list_head *ld;
+       struct pci_dev *dev;
        struct pci_bus *child_bus;
 
-       for (ld = b->devices.next; ld != &b->devices; ld = ld->next) {
-               struct pci_dev *dev = pci_dev_b(ld);
+       list_for_each_entry(dev, &b->devices, bus_list) {
                int i;
 
                for (i = 0; i < PCI_NUM_RESOURCES; i++) {
@@ -426,12 +437,10 @@ pcibios_claim_one_bus(struct pci_bus *b)
 static void __init
 pcibios_claim_console_setup(void)
 {
-       struct list_head *lb;
+       struct pci_bus *b;
 
-       for(lb = pci_root_buses.next; lb != &pci_root_buses; lb = lb->next) {
-               struct pci_bus *b = pci_bus_b(lb);
+       list_for_each_entry(b, &pci_root_buses, node)
                pcibios_claim_one_bus(b);
-       }
 }
 
 void __init
@@ -507,10 +516,11 @@ sys_pciconfig_iobase(long which, unsigned long bus, unsigned long dfn)
                if (bus == 0 && dfn == 0) {
                        hose = pci_isa_hose;
                } else {
-                       dev = pci_find_slot(bus, dfn);
+                       dev = pci_get_bus_and_slot(bus, dfn);
                        if (!dev)
                                return -ENODEV;
                        hose = dev->sysdata;
+                       pci_dev_put(dev);
                }
        }