]> pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
[PATCH] powerpc: pci_address_to_pio fix
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>
Thu, 15 Dec 2005 04:00:57 +0000 (15:00 +1100)
committerPaul Mackerras <paulus@samba.org>
Mon, 9 Jan 2006 04:05:56 +0000 (15:05 +1100)
This fixes pci_address_to_pio() to return an unsigned long (to be safe)
and fixes a bug in the implementation that caused it to return a bogus
IO port number

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Paul Mackerras <paulus@samba.org>
arch/powerpc/kernel/pci_64.c
arch/powerpc/kernel/prom_parse.c
arch/ppc/kernel/pci.c
include/asm-powerpc/pci-bridge.h
include/asm-ppc/pci-bridge.h

index f73a16e9867aadd433feb77c6bf08e6e14ef1f5f..fc60a773af7db3a4652ded23e5f0e9ada5e0cb63 100644 (file)
@@ -1365,16 +1365,17 @@ struct pci_controller* pci_find_hose_for_OF_device(struct device_node* node)
 
 #endif /* CONFIG_PPC_MULTIPLATFORM */
 
-unsigned int pci_address_to_pio(phys_addr_t address)
+unsigned long pci_address_to_pio(phys_addr_t address)
 {
        struct pci_controller *hose, *tmp;
 
        list_for_each_entry_safe(hose, tmp, &hose_list, list_node) {
                if (address >= hose->io_base_phys &&
-                   address < (hose->io_base_phys + hose->pci_io_size))
-                       return (unsigned int)
-                               ((unsigned long)hose->io_base_virt +
-                                (address - hose->io_base_phys));
+                   address < (hose->io_base_phys + hose->pci_io_size)) {
+                       unsigned long base =
+                               (unsigned long)hose->io_base_virt - pci_io_base;
+                       return base + (address - hose->io_base_phys);
+               }
        }
        return (unsigned int)-1;
 }
index 5b764277f4702dc13448141a6c1dc68b0a735ecd..309ae1d5fa77c0d007d05ff5560a0f45fbc1aed5 100644 (file)
@@ -503,9 +503,9 @@ static int __of_address_to_resource(struct device_node *dev, u32 *addrp,
                return -EINVAL;
        memset(r, 0, sizeof(struct resource));
        if (flags & IORESOURCE_IO) {
-               unsigned int port;
+               unsigned long port;
                port = pci_address_to_pio(taddr);
-               if (port == (unsigned int)-1)
+               if (port == (unsigned long)-1)
                        return -EINVAL;
                r->start = port;
                r->end = port + size - 1;
index 8de320308e87664f4c420d948eeb16640c61aefd..c8b48f171699aab9e504b49ed977457b369a7da2 100644 (file)
@@ -1811,7 +1811,7 @@ void pci_iounmap(struct pci_dev *dev, void __iomem *addr)
 EXPORT_SYMBOL(pci_iomap);
 EXPORT_SYMBOL(pci_iounmap);
 
-unsigned int pci_address_to_pio(phys_addr_t address)
+unsigned long pci_address_to_pio(phys_addr_t address)
 {
        struct pci_controller* hose = hose_head;
 
@@ -1819,9 +1819,11 @@ unsigned int pci_address_to_pio(phys_addr_t address)
                unsigned int size = hose->io_resource.end -
                        hose->io_resource.start + 1;
                if (address >= hose->io_base_phys &&
-                   address < (hose->io_base_phys + size))
-                       return (unsigned int)hose->io_base_virt +
-                               (address - hose->io_base_phys);
+                   address < (hose->io_base_phys + size)) {
+                       unsigned long base =
+                               (unsigned long)hose->io_base_virt - _IO_BASE;
+                       return base + (address - hose->io_base_phys);
+
        }
        return (unsigned int)-1;
 }
index 3d94e55f25d61414948b92c48669dc62a1cd0a3c..443c75a16571e68646617aa934056168c2d03acc 100644 (file)
@@ -158,11 +158,11 @@ pcibios_alloc_controller(struct device_node *dev);
 extern void pcibios_free_controller(struct pci_controller *phb);
 
 #ifdef CONFIG_PCI
-extern unsigned int pci_address_to_pio(phys_addr_t address);
+extern unsigned long pci_address_to_pio(phys_addr_t address);
 #else
-static inline unsigned int pci_address_to_pio(phys_addr_t address)
+static inline unsigned long pci_address_to_pio(phys_addr_t address)
 {
-       return (unsigned int)-1;
+       return (unsigned long)-1;
 }
 #endif
 
index 95672ddfe5288811f4a16b5edb95dc22effcc6fe..9d5230689b31dbf3d2e4b549301c82c9cca21dd2 100644 (file)
@@ -138,11 +138,11 @@ static inline unsigned char bridge_swizzle(unsigned char pin,
 extern int pciauto_bus_scan(struct pci_controller *, int);
 
 #ifdef CONFIG_PCI
-extern unsigned int pci_address_to_pio(phys_addr_t address);
+extern unsigned long pci_address_to_pio(phys_addr_t address);
 #else
-static inline unsigned int pci_address_to_pio(phys_addr_t address)
+static inline unsigned long pci_address_to_pio(phys_addr_t address)
 {
-       return (unsigned int)-1;
+       return (unsigned long)-1;
 }
 #endif