aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>2005-12-14 23:00:57 -0500
committerPaul Mackerras <paulus@samba.org>2006-01-08 23:05:56 -0500
commitf2c4583a381c584c8c025048071a120cc9562ded (patch)
tree53d6a1d30a3be72f021738c97853cff55a800070
parenta04c8780fd234aeeba5e87f7e37beffd05ef21ae (diff)
[PATCH] powerpc: pci_address_to_pio fix
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>
-rw-r--r--arch/powerpc/kernel/pci_64.c11
-rw-r--r--arch/powerpc/kernel/prom_parse.c4
-rw-r--r--arch/ppc/kernel/pci.c10
-rw-r--r--include/asm-powerpc/pci-bridge.h6
-rw-r--r--include/asm-ppc/pci-bridge.h6
5 files changed, 20 insertions, 17 deletions
diff --git a/arch/powerpc/kernel/pci_64.c b/arch/powerpc/kernel/pci_64.c
index f73a16e9867..fc60a773af7 100644
--- a/arch/powerpc/kernel/pci_64.c
+++ b/arch/powerpc/kernel/pci_64.c
@@ -1365,16 +1365,17 @@ struct pci_controller* pci_find_hose_for_OF_device(struct device_node* node)
1365 1365
1366#endif /* CONFIG_PPC_MULTIPLATFORM */ 1366#endif /* CONFIG_PPC_MULTIPLATFORM */
1367 1367
1368unsigned int pci_address_to_pio(phys_addr_t address) 1368unsigned long pci_address_to_pio(phys_addr_t address)
1369{ 1369{
1370 struct pci_controller *hose, *tmp; 1370 struct pci_controller *hose, *tmp;
1371 1371
1372 list_for_each_entry_safe(hose, tmp, &hose_list, list_node) { 1372 list_for_each_entry_safe(hose, tmp, &hose_list, list_node) {
1373 if (address >= hose->io_base_phys && 1373 if (address >= hose->io_base_phys &&
1374 address < (hose->io_base_phys + hose->pci_io_size)) 1374 address < (hose->io_base_phys + hose->pci_io_size)) {
1375 return (unsigned int) 1375 unsigned long base =
1376 ((unsigned long)hose->io_base_virt + 1376 (unsigned long)hose->io_base_virt - pci_io_base;
1377 (address - hose->io_base_phys)); 1377 return base + (address - hose->io_base_phys);
1378 }
1378 } 1379 }
1379 return (unsigned int)-1; 1380 return (unsigned int)-1;
1380} 1381}
diff --git a/arch/powerpc/kernel/prom_parse.c b/arch/powerpc/kernel/prom_parse.c
index 5b764277f47..309ae1d5fa7 100644
--- a/arch/powerpc/kernel/prom_parse.c
+++ b/arch/powerpc/kernel/prom_parse.c
@@ -503,9 +503,9 @@ static int __of_address_to_resource(struct device_node *dev, u32 *addrp,
503 return -EINVAL; 503 return -EINVAL;
504 memset(r, 0, sizeof(struct resource)); 504 memset(r, 0, sizeof(struct resource));
505 if (flags & IORESOURCE_IO) { 505 if (flags & IORESOURCE_IO) {
506 unsigned int port; 506 unsigned long port;
507 port = pci_address_to_pio(taddr); 507 port = pci_address_to_pio(taddr);
508 if (port == (unsigned int)-1) 508 if (port == (unsigned long)-1)
509 return -EINVAL; 509 return -EINVAL;
510 r->start = port; 510 r->start = port;
511 r->end = port + size - 1; 511 r->end = port + size - 1;
diff --git a/arch/ppc/kernel/pci.c b/arch/ppc/kernel/pci.c
index 8de320308e8..c8b48f17169 100644
--- a/arch/ppc/kernel/pci.c
+++ b/arch/ppc/kernel/pci.c
@@ -1811,7 +1811,7 @@ void pci_iounmap(struct pci_dev *dev, void __iomem *addr)
1811EXPORT_SYMBOL(pci_iomap); 1811EXPORT_SYMBOL(pci_iomap);
1812EXPORT_SYMBOL(pci_iounmap); 1812EXPORT_SYMBOL(pci_iounmap);
1813 1813
1814unsigned int pci_address_to_pio(phys_addr_t address) 1814unsigned long pci_address_to_pio(phys_addr_t address)
1815{ 1815{
1816 struct pci_controller* hose = hose_head; 1816 struct pci_controller* hose = hose_head;
1817 1817
@@ -1819,9 +1819,11 @@ unsigned int pci_address_to_pio(phys_addr_t address)
1819 unsigned int size = hose->io_resource.end - 1819 unsigned int size = hose->io_resource.end -
1820 hose->io_resource.start + 1; 1820 hose->io_resource.start + 1;
1821 if (address >= hose->io_base_phys && 1821 if (address >= hose->io_base_phys &&
1822 address < (hose->io_base_phys + size)) 1822 address < (hose->io_base_phys + size)) {
1823 return (unsigned int)hose->io_base_virt + 1823 unsigned long base =
1824 (address - hose->io_base_phys); 1824 (unsigned long)hose->io_base_virt - _IO_BASE;
1825 return base + (address - hose->io_base_phys);
1826
1825 } 1827 }
1826 return (unsigned int)-1; 1828 return (unsigned int)-1;
1827} 1829}
diff --git a/include/asm-powerpc/pci-bridge.h b/include/asm-powerpc/pci-bridge.h
index 3d94e55f25d..443c75a1657 100644
--- a/include/asm-powerpc/pci-bridge.h
+++ b/include/asm-powerpc/pci-bridge.h
@@ -158,11 +158,11 @@ pcibios_alloc_controller(struct device_node *dev);
158extern void pcibios_free_controller(struct pci_controller *phb); 158extern void pcibios_free_controller(struct pci_controller *phb);
159 159
160#ifdef CONFIG_PCI 160#ifdef CONFIG_PCI
161extern unsigned int pci_address_to_pio(phys_addr_t address); 161extern unsigned long pci_address_to_pio(phys_addr_t address);
162#else 162#else
163static inline unsigned int pci_address_to_pio(phys_addr_t address) 163static inline unsigned long pci_address_to_pio(phys_addr_t address)
164{ 164{
165 return (unsigned int)-1; 165 return (unsigned long)-1;
166} 166}
167#endif 167#endif
168 168
diff --git a/include/asm-ppc/pci-bridge.h b/include/asm-ppc/pci-bridge.h
index 95672ddfe52..9d5230689b3 100644
--- a/include/asm-ppc/pci-bridge.h
+++ b/include/asm-ppc/pci-bridge.h
@@ -138,11 +138,11 @@ static inline unsigned char bridge_swizzle(unsigned char pin,
138extern int pciauto_bus_scan(struct pci_controller *, int); 138extern int pciauto_bus_scan(struct pci_controller *, int);
139 139
140#ifdef CONFIG_PCI 140#ifdef CONFIG_PCI
141extern unsigned int pci_address_to_pio(phys_addr_t address); 141extern unsigned long pci_address_to_pio(phys_addr_t address);
142#else 142#else
143static inline unsigned int pci_address_to_pio(phys_addr_t address) 143static inline unsigned long pci_address_to_pio(phys_addr_t address)
144{ 144{
145 return (unsigned int)-1; 145 return (unsigned long)-1;
146} 146}
147#endif 147#endif
148 148