Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

sh/PCI: get rid of device resource fixups

Tell the PCI core about host bridge address translation so it can take
care of bus-to-resource conversion for us.

CC: Paul Mundt <lethal@linux-sh.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>

+12 -69
+11 -64
arch/sh/drivers/pci/pci.c
··· 37 37 static int next_busno; 38 38 static int need_domain_info; 39 39 LIST_HEAD(resources); 40 + struct resource *res; 41 + resource_size_t offset; 40 42 int i; 41 43 struct pci_bus *bus; 42 44 43 - for (i = 0; i < hose->nr_resources; i++) 44 - pci_add_resource(&resources, hose->resources + i); 45 + for (i = 0; i < hose->nr_resources; i++) { 46 + res = hose->resources + i; 47 + offset = 0; 48 + if (res->flags & IORESOURCE_IO) 49 + offset = hose->io_offset; 50 + else if (res->flags & IORESOURCE_MEM) 51 + offset = hose->mem_offset; 52 + pci_add_resource_offset(&resources, res, offset); 53 + } 45 54 46 55 bus = pci_scan_root_bus(NULL, next_busno, hose->pci_ops, hose, 47 56 &resources); ··· 152 143 } 153 144 subsys_initcall(pcibios_init); 154 145 155 - static void pcibios_fixup_device_resources(struct pci_dev *dev, 156 - struct pci_bus *bus) 157 - { 158 - /* Update device resources. */ 159 - struct pci_channel *hose = bus->sysdata; 160 - unsigned long offset = 0; 161 - int i; 162 - 163 - for (i = 0; i < PCI_NUM_RESOURCES; i++) { 164 - if (!dev->resource[i].start) 165 - continue; 166 - if (dev->resource[i].flags & IORESOURCE_IO) 167 - offset = hose->io_offset; 168 - else if (dev->resource[i].flags & IORESOURCE_MEM) 169 - offset = hose->mem_offset; 170 - 171 - dev->resource[i].start += offset; 172 - dev->resource[i].end += offset; 173 - } 174 - } 175 - 176 146 /* 177 147 * Called after each bus is probed, but before its children 178 148 * are examined. 179 149 */ 180 150 void __devinit pcibios_fixup_bus(struct pci_bus *bus) 181 151 { 182 - struct pci_dev *dev; 183 - struct list_head *ln; 184 - 185 - for (ln = bus->devices.next; ln != &bus->devices; ln = ln->next) { 186 - dev = pci_dev_b(ln); 187 - 188 - if ((dev->class >> 8) != PCI_CLASS_BRIDGE_PCI) 189 - pcibios_fixup_device_resources(dev, bus); 190 - } 191 152 } 192 153 193 154 /* ··· 185 206 } 186 207 187 208 return start; 188 - } 189 - 190 - void pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region, 191 - struct resource *res) 192 - { 193 - struct pci_channel *hose = dev->sysdata; 194 - unsigned long offset = 0; 195 - 196 - if (res->flags & IORESOURCE_IO) 197 - offset = hose->io_offset; 198 - else if (res->flags & IORESOURCE_MEM) 199 - offset = hose->mem_offset; 200 - 201 - region->start = res->start - offset; 202 - region->end = res->end - offset; 203 - } 204 - 205 - void pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res, 206 - struct pci_bus_region *region) 207 - { 208 - struct pci_channel *hose = dev->sysdata; 209 - unsigned long offset = 0; 210 - 211 - if (res->flags & IORESOURCE_IO) 212 - offset = hose->io_offset; 213 - else if (res->flags & IORESOURCE_MEM) 214 - offset = hose->mem_offset; 215 - 216 - res->start = region->start + offset; 217 - res->end = region->end + offset; 218 209 } 219 210 220 211 int pcibios_enable_device(struct pci_dev *dev, int mask) ··· 330 381 #endif /* CONFIG_GENERIC_IOMAP */ 331 382 332 383 #ifdef CONFIG_HOTPLUG 333 - EXPORT_SYMBOL(pcibios_resource_to_bus); 334 - EXPORT_SYMBOL(pcibios_bus_to_resource); 335 384 EXPORT_SYMBOL(PCIBIOS_MIN_IO); 336 385 EXPORT_SYMBOL(PCIBIOS_MIN_MEM); 337 386 #endif
+1 -5
arch/sh/include/asm/pci.h
··· 114 114 /* Board-specific fixup routines. */ 115 115 int pcibios_map_platform_irq(const struct pci_dev *dev, u8 slot, u8 pin); 116 116 117 - extern void pcibios_resource_to_bus(struct pci_dev *dev, 118 - struct pci_bus_region *region, struct resource *res); 119 - 120 - extern void pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res, 121 - struct pci_bus_region *region); 117 + #define ARCH_HAS_GENERIC_PCI_OFFSETS 122 118 123 119 #define pci_domain_nr(bus) ((struct pci_channel *)(bus)->sysdata)->index 124 120