diff options
author | Dominik Brodowski <linux@dominikbrodowski.net> | 2005-08-04 21:06:21 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2005-08-05 00:32:46 -0400 |
commit | 43c34735524d5b1c9b9e5d63b49dd4c1b394bde4 (patch) | |
tree | a61c11d4075f149be9c0aae6b6c0a935c94571af | |
parent | fec59a711eef002d4ef9eb8de09dd0a26986eb77 (diff) |
[PATCH] pci and yenta: pcibios_bus_to_resource
In yenta_socket, we default to using the resource setting of the CardBus
bridge. However, this is a PCI-bus-centric view of resources and thus needs
to be converted to generic resources first. Therefore, add a call to
pcibios_bus_to_resource() call in between. This function is a mere wrapper on
x86 and friends, however on some others it already exists, is added in this
patch (alpha, arm, ppc, ppc64) or still needs to be provided (parisc -- where
is its pcibios_resource_to_bus() ?).
Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r-- | arch/alpha/kernel/pci.c | 16 | ||||
-rw-r--r-- | arch/arm/kernel/bios32.c | 17 | ||||
-rw-r--r-- | arch/ppc/kernel/pci.c | 15 | ||||
-rw-r--r-- | arch/ppc64/kernel/pci.c | 20 | ||||
-rw-r--r-- | drivers/pcmcia/yenta_socket.c | 15 | ||||
-rw-r--r-- | include/asm-alpha/pci.h | 3 | ||||
-rw-r--r-- | include/asm-arm/pci.h | 4 | ||||
-rw-r--r-- | include/asm-generic/pci.h | 8 | ||||
-rw-r--r-- | include/asm-parisc/pci.h | 4 | ||||
-rw-r--r-- | include/asm-ppc/pci.h | 4 | ||||
-rw-r--r-- | include/asm-ppc64/pci.h | 4 |
11 files changed, 101 insertions, 9 deletions
diff --git a/arch/alpha/kernel/pci.c b/arch/alpha/kernel/pci.c index 1f36bbd0ed5d..2a8b364c822e 100644 --- a/arch/alpha/kernel/pci.c +++ b/arch/alpha/kernel/pci.c | |||
@@ -350,8 +350,24 @@ pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region, | |||
350 | region->end = res->end - offset; | 350 | region->end = res->end - offset; |
351 | } | 351 | } |
352 | 352 | ||
353 | void pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res, | ||
354 | struct pci_bus_region *region) | ||
355 | { | ||
356 | struct pci_controller *hose = (struct pci_controller *)dev->sysdata; | ||
357 | unsigned long offset = 0; | ||
358 | |||
359 | if (res->flags & IORESOURCE_IO) | ||
360 | offset = hose->io_space->start; | ||
361 | else if (res->flags & IORESOURCE_MEM) | ||
362 | offset = hose->mem_space->start; | ||
363 | |||
364 | res->start = region->start + offset; | ||
365 | res->end = region->end + offset; | ||
366 | } | ||
367 | |||
353 | #ifdef CONFIG_HOTPLUG | 368 | #ifdef CONFIG_HOTPLUG |
354 | EXPORT_SYMBOL(pcibios_resource_to_bus); | 369 | EXPORT_SYMBOL(pcibios_resource_to_bus); |
370 | EXPORT_SYMBOL(pcibios_bus_to_resource); | ||
355 | #endif | 371 | #endif |
356 | 372 | ||
357 | int | 373 | int |
diff --git a/arch/arm/kernel/bios32.c b/arch/arm/kernel/bios32.c index ad26e98f1e62..c4923fac8dff 100644 --- a/arch/arm/kernel/bios32.c +++ b/arch/arm/kernel/bios32.c | |||
@@ -447,9 +447,26 @@ pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region, | |||
447 | region->end = res->end - offset; | 447 | region->end = res->end - offset; |
448 | } | 448 | } |
449 | 449 | ||
450 | void __devinit | ||
451 | pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res, | ||
452 | struct pci_bus_region *region) | ||
453 | { | ||
454 | struct pci_sys_data *root = dev->sysdata; | ||
455 | unsigned long offset = 0; | ||
456 | |||
457 | if (res->flags & IORESOURCE_IO) | ||
458 | offset = root->io_offset; | ||
459 | if (res->flags & IORESOURCE_MEM) | ||
460 | offset = root->mem_offset; | ||
461 | |||
462 | res->start = region->start + offset; | ||
463 | res->end = region->end + offset; | ||
464 | } | ||
465 | |||
450 | #ifdef CONFIG_HOTPLUG | 466 | #ifdef CONFIG_HOTPLUG |
451 | EXPORT_SYMBOL(pcibios_fixup_bus); | 467 | EXPORT_SYMBOL(pcibios_fixup_bus); |
452 | EXPORT_SYMBOL(pcibios_resource_to_bus); | 468 | EXPORT_SYMBOL(pcibios_resource_to_bus); |
469 | EXPORT_SYMBOL(pcibios_bus_to_resource); | ||
453 | #endif | 470 | #endif |
454 | 471 | ||
455 | /* | 472 | /* |
diff --git a/arch/ppc/kernel/pci.c b/arch/ppc/kernel/pci.c index 70cfb6ffd877..7b3586a3bf30 100644 --- a/arch/ppc/kernel/pci.c +++ b/arch/ppc/kernel/pci.c | |||
@@ -160,6 +160,21 @@ void pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region, | |||
160 | } | 160 | } |
161 | EXPORT_SYMBOL(pcibios_resource_to_bus); | 161 | EXPORT_SYMBOL(pcibios_resource_to_bus); |
162 | 162 | ||
163 | void pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res, | ||
164 | struct pci_bus_region *region) | ||
165 | { | ||
166 | unsigned long offset = 0; | ||
167 | struct pci_controller *hose = dev->sysdata; | ||
168 | |||
169 | if (hose && res->flags & IORESOURCE_IO) | ||
170 | offset = (unsigned long)hose->io_base_virt - isa_io_base; | ||
171 | else if (hose && res->flags & IORESOURCE_MEM) | ||
172 | offset = hose->pci_mem_offset; | ||
173 | res->start = region->start + offset; | ||
174 | res->end = region->end + offset; | ||
175 | } | ||
176 | EXPORT_SYMBOL(pcibios_bus_to_resource); | ||
177 | |||
163 | /* | 178 | /* |
164 | * We need to avoid collisions with `mirrored' VGA ports | 179 | * We need to avoid collisions with `mirrored' VGA ports |
165 | * and other strange ISA hardware, so we always want the | 180 | * and other strange ISA hardware, so we always want the |
diff --git a/arch/ppc64/kernel/pci.c b/arch/ppc64/kernel/pci.c index ae6f579d3fa0..d0d55c7908ef 100644 --- a/arch/ppc64/kernel/pci.c +++ b/arch/ppc64/kernel/pci.c | |||
@@ -108,8 +108,28 @@ void pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region | |||
108 | region->end = res->end - offset; | 108 | region->end = res->end - offset; |
109 | } | 109 | } |
110 | 110 | ||
111 | void pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res, | ||
112 | struct pci_bus_region *region) | ||
113 | { | ||
114 | unsigned long offset = 0; | ||
115 | struct pci_controller *hose = pci_bus_to_host(dev->bus); | ||
116 | |||
117 | if (!hose) | ||
118 | return; | ||
119 | |||
120 | if (res->flags & IORESOURCE_IO) | ||
121 | offset = (unsigned long)hose->io_base_virt - pci_io_base; | ||
122 | |||
123 | if (res->flags & IORESOURCE_MEM) | ||
124 | offset = hose->pci_mem_offset; | ||
125 | |||
126 | res->start = region->start + offset; | ||
127 | res->end = region->end + offset; | ||
128 | } | ||
129 | |||
111 | #ifdef CONFIG_HOTPLUG | 130 | #ifdef CONFIG_HOTPLUG |
112 | EXPORT_SYMBOL(pcibios_resource_to_bus); | 131 | EXPORT_SYMBOL(pcibios_resource_to_bus); |
132 | EXPORT_SYMBOL(pcibios_bus_to_resource); | ||
113 | #endif | 133 | #endif |
114 | 134 | ||
115 | /* | 135 | /* |
diff --git a/drivers/pcmcia/yenta_socket.c b/drivers/pcmcia/yenta_socket.c index 91e7457d5b04..62fd705203fb 100644 --- a/drivers/pcmcia/yenta_socket.c +++ b/drivers/pcmcia/yenta_socket.c | |||
@@ -605,9 +605,8 @@ static int yenta_search_res(struct yenta_socket *socket, struct resource *res, | |||
605 | 605 | ||
606 | static void yenta_allocate_res(struct yenta_socket *socket, int nr, unsigned type, int addr_start, int addr_end) | 606 | static void yenta_allocate_res(struct yenta_socket *socket, int nr, unsigned type, int addr_start, int addr_end) |
607 | { | 607 | { |
608 | struct pci_bus *bus; | ||
609 | struct resource *root, *res; | 608 | struct resource *root, *res; |
610 | u32 start, end; | 609 | struct pci_bus_region region; |
611 | unsigned mask; | 610 | unsigned mask; |
612 | 611 | ||
613 | res = socket->dev->resource + PCI_BRIDGE_RESOURCES + nr; | 612 | res = socket->dev->resource + PCI_BRIDGE_RESOURCES + nr; |
@@ -620,15 +619,13 @@ static void yenta_allocate_res(struct yenta_socket *socket, int nr, unsigned typ | |||
620 | if (type & IORESOURCE_IO) | 619 | if (type & IORESOURCE_IO) |
621 | mask = ~3; | 620 | mask = ~3; |
622 | 621 | ||
623 | bus = socket->dev->subordinate; | 622 | res->name = socket->dev->subordinate->name; |
624 | res->name = bus->name; | ||
625 | res->flags = type; | 623 | res->flags = type; |
626 | 624 | ||
627 | start = config_readl(socket, addr_start) & mask; | 625 | region.start = config_readl(socket, addr_start) & mask; |
628 | end = config_readl(socket, addr_end) | ~mask; | 626 | region.end = config_readl(socket, addr_end) | ~mask; |
629 | if (start && end > start && !override_bios) { | 627 | if (region.start && region.end > region.start && !override_bios) { |
630 | res->start = start; | 628 | pcibios_bus_to_resource(socket->dev, res, ®ion); |
631 | res->end = end; | ||
632 | root = pci_find_parent_resource(socket->dev, res); | 629 | root = pci_find_parent_resource(socket->dev, res); |
633 | if (root && (request_resource(root, res) == 0)) | 630 | if (root && (request_resource(root, res) == 0)) |
634 | return; | 631 | return; |
diff --git a/include/asm-alpha/pci.h b/include/asm-alpha/pci.h index 28957697e59c..f681e675b823 100644 --- a/include/asm-alpha/pci.h +++ b/include/asm-alpha/pci.h | |||
@@ -251,6 +251,9 @@ static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel) | |||
251 | extern void pcibios_resource_to_bus(struct pci_dev *, struct pci_bus_region *, | 251 | extern void pcibios_resource_to_bus(struct pci_dev *, struct pci_bus_region *, |
252 | struct resource *); | 252 | struct resource *); |
253 | 253 | ||
254 | extern void pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res, | ||
255 | struct pci_bus_region *region); | ||
256 | |||
254 | #define pci_domain_nr(bus) ((struct pci_controller *)(bus)->sysdata)->index | 257 | #define pci_domain_nr(bus) ((struct pci_controller *)(bus)->sysdata)->index |
255 | 258 | ||
256 | static inline int pci_proc_domain(struct pci_bus *bus) | 259 | static inline int pci_proc_domain(struct pci_bus *bus) |
diff --git a/include/asm-arm/pci.h b/include/asm-arm/pci.h index b28f1c95dd62..38ea5899a580 100644 --- a/include/asm-arm/pci.h +++ b/include/asm-arm/pci.h | |||
@@ -60,6 +60,10 @@ extern void | |||
60 | pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region, | 60 | pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region, |
61 | struct resource *res); | 61 | struct resource *res); |
62 | 62 | ||
63 | extern void | ||
64 | pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res, | ||
65 | struct pci_bus_region *region); | ||
66 | |||
63 | static inline void pcibios_add_platform_entries(struct pci_dev *dev) | 67 | static inline void pcibios_add_platform_entries(struct pci_dev *dev) |
64 | { | 68 | { |
65 | } | 69 | } |
diff --git a/include/asm-generic/pci.h b/include/asm-generic/pci.h index 9d4cc47bde39..ee1d8b5d8168 100644 --- a/include/asm-generic/pci.h +++ b/include/asm-generic/pci.h | |||
@@ -22,6 +22,14 @@ pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region, | |||
22 | region->end = res->end; | 22 | region->end = res->end; |
23 | } | 23 | } |
24 | 24 | ||
25 | static inline void | ||
26 | pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res, | ||
27 | struct pci_bus_region *region) | ||
28 | { | ||
29 | res->start = region->start; | ||
30 | res->end = region->end; | ||
31 | } | ||
32 | |||
25 | #define pcibios_scan_all_fns(a, b) 0 | 33 | #define pcibios_scan_all_fns(a, b) 0 |
26 | 34 | ||
27 | #ifndef HAVE_ARCH_PCI_GET_LEGACY_IDE_IRQ | 35 | #ifndef HAVE_ARCH_PCI_GET_LEGACY_IDE_IRQ |
diff --git a/include/asm-parisc/pci.h b/include/asm-parisc/pci.h index ee741c150176..98d79a3d54fa 100644 --- a/include/asm-parisc/pci.h +++ b/include/asm-parisc/pci.h | |||
@@ -253,6 +253,10 @@ extern void | |||
253 | pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region, | 253 | pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region, |
254 | struct resource *res); | 254 | struct resource *res); |
255 | 255 | ||
256 | extern void | ||
257 | pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res, | ||
258 | struct pci_bus_region *region); | ||
259 | |||
256 | static inline void pcibios_add_platform_entries(struct pci_dev *dev) | 260 | static inline void pcibios_add_platform_entries(struct pci_dev *dev) |
257 | { | 261 | { |
258 | } | 262 | } |
diff --git a/include/asm-ppc/pci.h b/include/asm-ppc/pci.h index a13d55870e62..a811e440c978 100644 --- a/include/asm-ppc/pci.h +++ b/include/asm-ppc/pci.h | |||
@@ -105,6 +105,10 @@ extern void | |||
105 | pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region, | 105 | pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region, |
106 | struct resource *res); | 106 | struct resource *res); |
107 | 107 | ||
108 | extern void | ||
109 | pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res, | ||
110 | struct pci_bus_region *region); | ||
111 | |||
108 | extern void pcibios_add_platform_entries(struct pci_dev *dev); | 112 | extern void pcibios_add_platform_entries(struct pci_dev *dev); |
109 | 113 | ||
110 | struct file; | 114 | struct file; |
diff --git a/include/asm-ppc64/pci.h b/include/asm-ppc64/pci.h index faa772223075..4d057452f59b 100644 --- a/include/asm-ppc64/pci.h +++ b/include/asm-ppc64/pci.h | |||
@@ -134,6 +134,10 @@ extern void | |||
134 | pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region, | 134 | pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region, |
135 | struct resource *res); | 135 | struct resource *res); |
136 | 136 | ||
137 | extern void | ||
138 | pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res, | ||
139 | struct pci_bus_region *region); | ||
140 | |||
137 | extern int | 141 | extern int |
138 | unmap_bus_range(struct pci_bus *bus); | 142 | unmap_bus_range(struct pci_bus *bus); |
139 | 143 | ||