Skip to content

Commit

Permalink
[PATCH] powerpc: pci_address_to_pio fix
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Benjamin Herrenschmidt authored and Paul Mackerras committed Jan 9, 2006
1 parent a04c878 commit f2c4583
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 17 deletions.
11 changes: 6 additions & 5 deletions arch/powerpc/kernel/pci_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions arch/powerpc/kernel/prom_parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 6 additions & 4 deletions arch/ppc/kernel/pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -1811,17 +1811,19 @@ 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;

for (; hose; hose = hose->next) {
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;
}
Expand Down
6 changes: 3 additions & 3 deletions include/asm-powerpc/pci-bridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 3 additions & 3 deletions include/asm-ppc/pci-bridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit f2c4583

Please sign in to comment.