diff options
author | Dominik Brodowski <linux@dominikbrodowski.net> | 2010-01-01 11:40:49 -0500 |
---|---|---|
committer | Jesse Barnes <jbarnes@virtuousgeek.org> | 2010-02-22 19:16:56 -0500 |
commit | b26b2d494b659f988b4d75eb394dfa0ddac415c9 (patch) | |
tree | d262f333e529a21017dc072e604a626b38520515 | |
parent | 93da6202264ce1256b04db8008a43882ae62d060 (diff) |
resource/PCI: align functions now return start of resource
As suggested by Linus, align functions should return the start
of a resource, not void. An update of "res->start" is no longer
necessary.
Cc: Bjorn Helgaas <bjorn.helgaas@hp.com>
Cc: Yinghai Lu <yhlu.kernel@gmail.com>
Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
-rw-r--r-- | arch/alpha/kernel/pci.c | 4 | ||||
-rw-r--r-- | arch/arm/kernel/bios32.c | 8 | ||||
-rw-r--r-- | arch/cris/arch-v32/drivers/pci/bios.c | 14 | ||||
-rw-r--r-- | arch/frv/mb93090-mb00/pci-frv.c | 14 | ||||
-rw-r--r-- | arch/ia64/pci/pci.c | 3 | ||||
-rw-r--r-- | arch/mips/pci/pci.c | 4 | ||||
-rw-r--r-- | arch/mips/pmc-sierra/yosemite/ht.c | 10 | ||||
-rw-r--r-- | arch/mn10300/unit-asb2305/pci-asb2305.c | 16 | ||||
-rw-r--r-- | arch/parisc/kernel/pci.c | 10 | ||||
-rw-r--r-- | arch/powerpc/kernel/pci-common.c | 13 | ||||
-rw-r--r-- | arch/sh/drivers/pci/pci.c | 6 | ||||
-rw-r--r-- | arch/sparc/kernel/pci.c | 5 | ||||
-rw-r--r-- | arch/sparc/kernel/pcic.c | 5 | ||||
-rw-r--r-- | arch/x86/pci/i386.c | 12 | ||||
-rw-r--r-- | arch/xtensa/kernel/pci.c | 11 | ||||
-rw-r--r-- | drivers/pci/bus.c | 6 | ||||
-rw-r--r-- | drivers/pcmcia/rsrc_mgr.c | 12 | ||||
-rw-r--r-- | drivers/pcmcia/rsrc_nonstatic.c | 16 | ||||
-rw-r--r-- | include/linux/ioport.h | 6 | ||||
-rw-r--r-- | include/linux/pci.h | 8 | ||||
-rw-r--r-- | kernel/resource.c | 14 |
21 files changed, 102 insertions, 95 deletions
diff --git a/arch/alpha/kernel/pci.c b/arch/alpha/kernel/pci.c index a91ba28999b5..5cf111ed851c 100644 --- a/arch/alpha/kernel/pci.c +++ b/arch/alpha/kernel/pci.c | |||
@@ -126,7 +126,7 @@ DECLARE_PCI_FIXUP_FINAL(PCI_ANY_ID, PCI_ANY_ID, pcibios_fixup_final); | |||
126 | #define MB (1024*KB) | 126 | #define MB (1024*KB) |
127 | #define GB (1024*MB) | 127 | #define GB (1024*MB) |
128 | 128 | ||
129 | void | 129 | resource_size_t |
130 | pcibios_align_resource(void *data, struct resource *res, | 130 | pcibios_align_resource(void *data, struct resource *res, |
131 | resource_size_t size, resource_size_t align) | 131 | resource_size_t size, resource_size_t align) |
132 | { | 132 | { |
@@ -184,7 +184,7 @@ pcibios_align_resource(void *data, struct resource *res, | |||
184 | } | 184 | } |
185 | } | 185 | } |
186 | 186 | ||
187 | res->start = start; | 187 | return start; |
188 | } | 188 | } |
189 | #undef KB | 189 | #undef KB |
190 | #undef MB | 190 | #undef MB |
diff --git a/arch/arm/kernel/bios32.c b/arch/arm/kernel/bios32.c index 809681900ec8..a7c85f84f06c 100644 --- a/arch/arm/kernel/bios32.c +++ b/arch/arm/kernel/bios32.c | |||
@@ -616,15 +616,17 @@ char * __init pcibios_setup(char *str) | |||
616 | * but we want to try to avoid allocating at 0x2900-0x2bff | 616 | * but we want to try to avoid allocating at 0x2900-0x2bff |
617 | * which might be mirrored at 0x0100-0x03ff.. | 617 | * which might be mirrored at 0x0100-0x03ff.. |
618 | */ | 618 | */ |
619 | void pcibios_align_resource(void *data, struct resource *res, | 619 | resource_size_t pcibios_align_resource(void *data, struct resource *res, |
620 | resource_size_t size, resource_size_t align) | 620 | resource_size_t size, resource_size_t align) |
621 | { | 621 | { |
622 | resource_size_t start = res->start; | 622 | resource_size_t start = res->start; |
623 | 623 | ||
624 | if (res->flags & IORESOURCE_IO && start & 0x300) | 624 | if (res->flags & IORESOURCE_IO && start & 0x300) |
625 | start = (start + 0x3ff) & ~0x3ff; | 625 | start = (start + 0x3ff) & ~0x3ff; |
626 | 626 | ||
627 | res->start = (start + align - 1) & ~(align - 1); | 627 | start = (start + align - 1) & ~(align - 1); |
628 | |||
629 | return start; | ||
628 | } | 630 | } |
629 | 631 | ||
630 | /** | 632 | /** |
diff --git a/arch/cris/arch-v32/drivers/pci/bios.c b/arch/cris/arch-v32/drivers/pci/bios.c index 77ee319193c3..5811e2f8945c 100644 --- a/arch/cris/arch-v32/drivers/pci/bios.c +++ b/arch/cris/arch-v32/drivers/pci/bios.c | |||
@@ -41,18 +41,16 @@ int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma, | |||
41 | return 0; | 41 | return 0; |
42 | } | 42 | } |
43 | 43 | ||
44 | void | 44 | resource_size_t |
45 | pcibios_align_resource(void *data, struct resource *res, | 45 | pcibios_align_resource(void *data, struct resource *res, |
46 | resource_size_t size, resource_size_t align) | 46 | resource_size_t size, resource_size_t align) |
47 | { | 47 | { |
48 | if (res->flags & IORESOURCE_IO) { | 48 | resource_size_t start = res->start; |
49 | resource_size_t start = res->start; | ||
50 | 49 | ||
51 | if (start & 0x300) { | 50 | if ((res->flags & IORESOURCE_IO) && (start & 0x300)) |
52 | start = (start + 0x3ff) & ~0x3ff; | 51 | start = (start + 0x3ff) & ~0x3ff; |
53 | res->start = start; | 52 | |
54 | } | 53 | return start |
55 | } | ||
56 | } | 54 | } |
57 | 55 | ||
58 | int pcibios_enable_resources(struct pci_dev *dev, int mask) | 56 | int pcibios_enable_resources(struct pci_dev *dev, int mask) |
diff --git a/arch/frv/mb93090-mb00/pci-frv.c b/arch/frv/mb93090-mb00/pci-frv.c index 566bdeb499d1..c947aa43f2a9 100644 --- a/arch/frv/mb93090-mb00/pci-frv.c +++ b/arch/frv/mb93090-mb00/pci-frv.c | |||
@@ -32,18 +32,16 @@ | |||
32 | * but we want to try to avoid allocating at 0x2900-0x2bff | 32 | * but we want to try to avoid allocating at 0x2900-0x2bff |
33 | * which might have be mirrored at 0x0100-0x03ff.. | 33 | * which might have be mirrored at 0x0100-0x03ff.. |
34 | */ | 34 | */ |
35 | void | 35 | resource_size_t |
36 | pcibios_align_resource(void *data, struct resource *res, | 36 | pcibios_align_resource(void *data, struct resource *res, |
37 | resource_size_t size, resource_size_t align) | 37 | resource_size_t size, resource_size_t align) |
38 | { | 38 | { |
39 | if (res->flags & IORESOURCE_IO) { | 39 | resource_size_t start = res->start; |
40 | resource_size_t start = res->start; | ||
41 | 40 | ||
42 | if (start & 0x300) { | 41 | if ((res->flags & IORESOURCE_IO) && (start & 0x300)) |
43 | start = (start + 0x3ff) & ~0x3ff; | 42 | start = (start + 0x3ff) & ~0x3ff; |
44 | res->start = start; | 43 | |
45 | } | 44 | return start |
46 | } | ||
47 | } | 45 | } |
48 | 46 | ||
49 | 47 | ||
diff --git a/arch/ia64/pci/pci.c b/arch/ia64/pci/pci.c index df639db779f9..ef574cd311d1 100644 --- a/arch/ia64/pci/pci.c +++ b/arch/ia64/pci/pci.c | |||
@@ -547,10 +547,11 @@ pcibios_disable_device (struct pci_dev *dev) | |||
547 | acpi_pci_irq_disable(dev); | 547 | acpi_pci_irq_disable(dev); |
548 | } | 548 | } |
549 | 549 | ||
550 | void | 550 | resource_size_t |
551 | pcibios_align_resource (void *data, struct resource *res, | 551 | pcibios_align_resource (void *data, struct resource *res, |
552 | resource_size_t size, resource_size_t align) | 552 | resource_size_t size, resource_size_t align) |
553 | { | 553 | { |
554 | return res->start; | ||
554 | } | 555 | } |
555 | 556 | ||
556 | /* | 557 | /* |
diff --git a/arch/mips/pci/pci.c b/arch/mips/pci/pci.c index 9a11c2226891..9085988f7cf3 100644 --- a/arch/mips/pci/pci.c +++ b/arch/mips/pci/pci.c | |||
@@ -49,7 +49,7 @@ static int pci_initialized; | |||
49 | * but we want to try to avoid allocating at 0x2900-0x2bff | 49 | * but we want to try to avoid allocating at 0x2900-0x2bff |
50 | * which might have be mirrored at 0x0100-0x03ff.. | 50 | * which might have be mirrored at 0x0100-0x03ff.. |
51 | */ | 51 | */ |
52 | void | 52 | resource_size_t |
53 | pcibios_align_resource(void *data, struct resource *res, | 53 | pcibios_align_resource(void *data, struct resource *res, |
54 | resource_size_t size, resource_size_t align) | 54 | resource_size_t size, resource_size_t align) |
55 | { | 55 | { |
@@ -73,7 +73,7 @@ pcibios_align_resource(void *data, struct resource *res, | |||
73 | start = PCIBIOS_MIN_MEM + hose->mem_resource->start; | 73 | start = PCIBIOS_MIN_MEM + hose->mem_resource->start; |
74 | } | 74 | } |
75 | 75 | ||
76 | res->start = start; | 76 | return start; |
77 | } | 77 | } |
78 | 78 | ||
79 | static void __devinit pcibios_scanbus(struct pci_controller *hose) | 79 | static void __devinit pcibios_scanbus(struct pci_controller *hose) |
diff --git a/arch/mips/pmc-sierra/yosemite/ht.c b/arch/mips/pmc-sierra/yosemite/ht.c index 678388fd34b1..5e410087b628 100644 --- a/arch/mips/pmc-sierra/yosemite/ht.c +++ b/arch/mips/pmc-sierra/yosemite/ht.c | |||
@@ -345,14 +345,13 @@ int pcibios_enable_device(struct pci_dev *dev, int mask) | |||
345 | return pcibios_enable_resources(dev); | 345 | return pcibios_enable_resources(dev); |
346 | } | 346 | } |
347 | 347 | ||
348 | void pcibios_align_resource(void *data, struct resource *res, | 348 | resource_size_t pcibios_align_resource(void *data, struct resource *res, |
349 | resource_size_t size, resource_size_t align) | 349 | resource_size_t size, resource_size_t align) |
350 | { | 350 | { |
351 | struct pci_dev *dev = data; | 351 | struct pci_dev *dev = data; |
352 | resource_size_t start = res->start; | ||
352 | 353 | ||
353 | if (res->flags & IORESOURCE_IO) { | 354 | if (res->flags & IORESOURCE_IO) { |
354 | resource_size_t start = res->start; | ||
355 | |||
356 | /* We need to avoid collisions with `mirrored' VGA ports | 355 | /* We need to avoid collisions with `mirrored' VGA ports |
357 | and other strange ISA hardware, so we always want the | 356 | and other strange ISA hardware, so we always want the |
358 | addresses kilobyte aligned. */ | 357 | addresses kilobyte aligned. */ |
@@ -363,8 +362,9 @@ void pcibios_align_resource(void *data, struct resource *res, | |||
363 | } | 362 | } |
364 | 363 | ||
365 | start = (start + 1024 - 1) & ~(1024 - 1); | 364 | start = (start + 1024 - 1) & ~(1024 - 1); |
366 | res->start = start; | ||
367 | } | 365 | } |
366 | |||
367 | return start; | ||
368 | } | 368 | } |
369 | 369 | ||
370 | struct pci_ops titan_pci_ops = { | 370 | struct pci_ops titan_pci_ops = { |
diff --git a/arch/mn10300/unit-asb2305/pci-asb2305.c b/arch/mn10300/unit-asb2305/pci-asb2305.c index 78cd134ddf7d..b0b3758fba08 100644 --- a/arch/mn10300/unit-asb2305/pci-asb2305.c +++ b/arch/mn10300/unit-asb2305/pci-asb2305.c | |||
@@ -31,9 +31,11 @@ | |||
31 | * but we want to try to avoid allocating at 0x2900-0x2bff | 31 | * but we want to try to avoid allocating at 0x2900-0x2bff |
32 | * which might have be mirrored at 0x0100-0x03ff.. | 32 | * which might have be mirrored at 0x0100-0x03ff.. |
33 | */ | 33 | */ |
34 | void pcibios_align_resource(void *data, struct resource *res, | 34 | resource_size_t pcibios_align_resource(void *data, struct resource *res, |
35 | resource_size_t size, resource_size_t align) | 35 | resource_size_t size, resource_size_t align) |
36 | { | 36 | { |
37 | resource_size_t start = res->start; | ||
38 | |||
37 | #if 0 | 39 | #if 0 |
38 | struct pci_dev *dev = data; | 40 | struct pci_dev *dev = data; |
39 | 41 | ||
@@ -47,14 +49,10 @@ void pcibios_align_resource(void *data, struct resource *res, | |||
47 | ); | 49 | ); |
48 | #endif | 50 | #endif |
49 | 51 | ||
50 | if (res->flags & IORESOURCE_IO) { | 52 | if ((res->flags & IORESOURCE_IO) && (start & 0x300)) |
51 | unsigned long start = res->start; | 53 | start = (start + 0x3ff) & ~0x3ff; |
52 | 54 | ||
53 | if (start & 0x300) { | 55 | return start; |
54 | start = (start + 0x3ff) & ~0x3ff; | ||
55 | res->start = start; | ||
56 | } | ||
57 | } | ||
58 | } | 56 | } |
59 | 57 | ||
60 | 58 | ||
diff --git a/arch/parisc/kernel/pci.c b/arch/parisc/kernel/pci.c index f7064abc3bb6..4463a31973ba 100644 --- a/arch/parisc/kernel/pci.c +++ b/arch/parisc/kernel/pci.c | |||
@@ -254,10 +254,10 @@ EXPORT_SYMBOL(pcibios_bus_to_resource); | |||
254 | * Since we are just checking candidates, don't use any fields other | 254 | * Since we are just checking candidates, don't use any fields other |
255 | * than res->start. | 255 | * than res->start. |
256 | */ | 256 | */ |
257 | void pcibios_align_resource(void *data, struct resource *res, | 257 | resource_size_t pcibios_align_resource(void *data, struct resource *res, |
258 | resource_size_t size, resource_size_t alignment) | 258 | resource_size_t size, resource_size_t alignment) |
259 | { | 259 | { |
260 | resource_size_t mask, align; | 260 | resource_size_t mask, align, start = res->start; |
261 | 261 | ||
262 | DBG_RES("pcibios_align_resource(%s, (%p) [%lx,%lx]/%x, 0x%lx, 0x%lx)\n", | 262 | DBG_RES("pcibios_align_resource(%s, (%p) [%lx,%lx]/%x, 0x%lx, 0x%lx)\n", |
263 | pci_name(((struct pci_dev *) data)), | 263 | pci_name(((struct pci_dev *) data)), |
@@ -269,10 +269,10 @@ void pcibios_align_resource(void *data, struct resource *res, | |||
269 | 269 | ||
270 | /* Align to largest of MIN or input size */ | 270 | /* Align to largest of MIN or input size */ |
271 | mask = max(alignment, align) - 1; | 271 | mask = max(alignment, align) - 1; |
272 | res->start += mask; | 272 | start += mask; |
273 | res->start &= ~mask; | 273 | start &= ~mask; |
274 | 274 | ||
275 | /* The caller updates the end field, we don't. */ | 275 | return start; |
276 | } | 276 | } |
277 | 277 | ||
278 | 278 | ||
diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c index cadbed679fbb..d7eebbaf01f1 100644 --- a/arch/powerpc/kernel/pci-common.c +++ b/arch/powerpc/kernel/pci-common.c | |||
@@ -1181,21 +1181,20 @@ static int skip_isa_ioresource_align(struct pci_dev *dev) | |||
1181 | * but we want to try to avoid allocating at 0x2900-0x2bff | 1181 | * but we want to try to avoid allocating at 0x2900-0x2bff |
1182 | * which might have be mirrored at 0x0100-0x03ff.. | 1182 | * which might have be mirrored at 0x0100-0x03ff.. |
1183 | */ | 1183 | */ |
1184 | void pcibios_align_resource(void *data, struct resource *res, | 1184 | resource_size_t pcibios_align_resource(void *data, struct resource *res, |
1185 | resource_size_t size, resource_size_t align) | 1185 | resource_size_t size, resource_size_t align) |
1186 | { | 1186 | { |
1187 | struct pci_dev *dev = data; | 1187 | struct pci_dev *dev = data; |
1188 | resource_size_t start = res->start; | ||
1188 | 1189 | ||
1189 | if (res->flags & IORESOURCE_IO) { | 1190 | if (res->flags & IORESOURCE_IO) { |
1190 | resource_size_t start = res->start; | ||
1191 | |||
1192 | if (skip_isa_ioresource_align(dev)) | 1191 | if (skip_isa_ioresource_align(dev)) |
1193 | return; | 1192 | return start; |
1194 | if (start & 0x300) { | 1193 | if (start & 0x300) |
1195 | start = (start + 0x3ff) & ~0x3ff; | 1194 | start = (start + 0x3ff) & ~0x3ff; |
1196 | res->start = start; | ||
1197 | } | ||
1198 | } | 1195 | } |
1196 | |||
1197 | return start; | ||
1199 | } | 1198 | } |
1200 | EXPORT_SYMBOL(pcibios_align_resource); | 1199 | EXPORT_SYMBOL(pcibios_align_resource); |
1201 | 1200 | ||
diff --git a/arch/sh/drivers/pci/pci.c b/arch/sh/drivers/pci/pci.c index c481df639022..b36ca825b3d3 100644 --- a/arch/sh/drivers/pci/pci.c +++ b/arch/sh/drivers/pci/pci.c | |||
@@ -148,8 +148,8 @@ void __devinit pcibios_fixup_bus(struct pci_bus *bus) | |||
148 | * addresses to be allocated in the 0x000-0x0ff region | 148 | * addresses to be allocated in the 0x000-0x0ff region |
149 | * modulo 0x400. | 149 | * modulo 0x400. |
150 | */ | 150 | */ |
151 | void pcibios_align_resource(void *data, struct resource *res, | 151 | resource_size_t pcibios_align_resource(void *data, struct resource *res, |
152 | resource_size_t size, resource_size_t align) | 152 | resource_size_t size, resource_size_t align) |
153 | { | 153 | { |
154 | struct pci_dev *dev = data; | 154 | struct pci_dev *dev = data; |
155 | struct pci_channel *chan = dev->sysdata; | 155 | struct pci_channel *chan = dev->sysdata; |
@@ -171,7 +171,7 @@ void pcibios_align_resource(void *data, struct resource *res, | |||
171 | start = PCIBIOS_MIN_MEM + chan->mem_resource->start; | 171 | start = PCIBIOS_MIN_MEM + chan->mem_resource->start; |
172 | } | 172 | } |
173 | 173 | ||
174 | res->start = start; | 174 | return start; |
175 | } | 175 | } |
176 | 176 | ||
177 | void pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region, | 177 | void pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region, |
diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c index 592b03d85167..d56c1f34689e 100644 --- a/arch/sparc/kernel/pci.c +++ b/arch/sparc/kernel/pci.c | |||
@@ -722,9 +722,10 @@ void pcibios_update_irq(struct pci_dev *pdev, int irq) | |||
722 | { | 722 | { |
723 | } | 723 | } |
724 | 724 | ||
725 | void pcibios_align_resource(void *data, struct resource *res, | 725 | resource_size_t pcibios_align_resource(void *data, struct resource *res, |
726 | resource_size_t size, resource_size_t align) | 726 | resource_size_t size, resource_size_t align) |
727 | { | 727 | { |
728 | return res->start; | ||
728 | } | 729 | } |
729 | 730 | ||
730 | int pcibios_enable_device(struct pci_dev *dev, int mask) | 731 | int pcibios_enable_device(struct pci_dev *dev, int mask) |
diff --git a/arch/sparc/kernel/pcic.c b/arch/sparc/kernel/pcic.c index 4e2724ec2bb6..46fda64ff163 100644 --- a/arch/sparc/kernel/pcic.c +++ b/arch/sparc/kernel/pcic.c | |||
@@ -768,9 +768,10 @@ char * __devinit pcibios_setup(char *str) | |||
768 | return str; | 768 | return str; |
769 | } | 769 | } |
770 | 770 | ||
771 | void pcibios_align_resource(void *data, struct resource *res, | 771 | resource_size_t pcibios_align_resource(void *data, struct resource *res, |
772 | resource_size_t size, resource_size_t align) | 772 | resource_size_t size, resource_size_t align) |
773 | { | 773 | { |
774 | return res->start; | ||
774 | } | 775 | } |
775 | 776 | ||
776 | int pcibios_enable_device(struct pci_dev *pdev, int mask) | 777 | int pcibios_enable_device(struct pci_dev *pdev, int mask) |
diff --git a/arch/x86/pci/i386.c b/arch/x86/pci/i386.c index 5dc9e8c63fcd..924e40c916d3 100644 --- a/arch/x86/pci/i386.c +++ b/arch/x86/pci/i386.c | |||
@@ -60,22 +60,20 @@ skip_isa_ioresource_align(struct pci_dev *dev) { | |||
60 | * but we want to try to avoid allocating at 0x2900-0x2bff | 60 | * but we want to try to avoid allocating at 0x2900-0x2bff |
61 | * which might have be mirrored at 0x0100-0x03ff.. | 61 | * which might have be mirrored at 0x0100-0x03ff.. |
62 | */ | 62 | */ |
63 | void | 63 | resource_size_t |
64 | pcibios_align_resource(void *data, struct resource *res, | 64 | pcibios_align_resource(void *data, struct resource *res, |
65 | resource_size_t size, resource_size_t align) | 65 | resource_size_t size, resource_size_t align) |
66 | { | 66 | { |
67 | struct pci_dev *dev = data; | 67 | struct pci_dev *dev = data; |
68 | resource_size_t start = res->start; | ||
68 | 69 | ||
69 | if (res->flags & IORESOURCE_IO) { | 70 | if (res->flags & IORESOURCE_IO) { |
70 | resource_size_t start = res->start; | ||
71 | |||
72 | if (skip_isa_ioresource_align(dev)) | 71 | if (skip_isa_ioresource_align(dev)) |
73 | return; | 72 | return start; |
74 | if (start & 0x300) { | 73 | if (start & 0x300) |
75 | start = (start + 0x3ff) & ~0x3ff; | 74 | start = (start + 0x3ff) & ~0x3ff; |
76 | res->start = start; | ||
77 | } | ||
78 | } | 75 | } |
76 | return start; | ||
79 | } | 77 | } |
80 | EXPORT_SYMBOL(pcibios_align_resource); | 78 | EXPORT_SYMBOL(pcibios_align_resource); |
81 | 79 | ||
diff --git a/arch/xtensa/kernel/pci.c b/arch/xtensa/kernel/pci.c index b7c073484e01..d7efab03164e 100644 --- a/arch/xtensa/kernel/pci.c +++ b/arch/xtensa/kernel/pci.c | |||
@@ -69,26 +69,25 @@ static int pci_bus_count; | |||
69 | * but we want to try to avoid allocating at 0x2900-0x2bff | 69 | * but we want to try to avoid allocating at 0x2900-0x2bff |
70 | * which might have be mirrored at 0x0100-0x03ff.. | 70 | * which might have be mirrored at 0x0100-0x03ff.. |
71 | */ | 71 | */ |
72 | void | 72 | resource_size_t |
73 | pcibios_align_resource(void *data, struct resource *res, resource_size_t size, | 73 | pcibios_align_resource(void *data, struct resource *res, resource_size_t size, |
74 | resource_size_t align) | 74 | resource_size_t align) |
75 | { | 75 | { |
76 | struct pci_dev *dev = data; | 76 | struct pci_dev *dev = data; |
77 | resource_size_t start = res->start; | ||
77 | 78 | ||
78 | if (res->flags & IORESOURCE_IO) { | 79 | if (res->flags & IORESOURCE_IO) { |
79 | resource_size_t start = res->start; | ||
80 | |||
81 | if (size > 0x100) { | 80 | if (size > 0x100) { |
82 | printk(KERN_ERR "PCI: I/O Region %s/%d too large" | 81 | printk(KERN_ERR "PCI: I/O Region %s/%d too large" |
83 | " (%ld bytes)\n", pci_name(dev), | 82 | " (%ld bytes)\n", pci_name(dev), |
84 | dev->resource - res, size); | 83 | dev->resource - res, size); |
85 | } | 84 | } |
86 | 85 | ||
87 | if (start & 0x300) { | 86 | if (start & 0x300) |
88 | start = (start + 0x3ff) & ~0x3ff; | 87 | start = (start + 0x3ff) & ~0x3ff; |
89 | res->start = start; | ||
90 | } | ||
91 | } | 88 | } |
89 | |||
90 | return start; | ||
92 | } | 91 | } |
93 | 92 | ||
94 | int | 93 | int |
diff --git a/drivers/pci/bus.c b/drivers/pci/bus.c index cef28a79103f..d29d69a37940 100644 --- a/drivers/pci/bus.c +++ b/drivers/pci/bus.c | |||
@@ -36,8 +36,10 @@ int | |||
36 | pci_bus_alloc_resource(struct pci_bus *bus, struct resource *res, | 36 | pci_bus_alloc_resource(struct pci_bus *bus, struct resource *res, |
37 | resource_size_t size, resource_size_t align, | 37 | resource_size_t size, resource_size_t align, |
38 | resource_size_t min, unsigned int type_mask, | 38 | resource_size_t min, unsigned int type_mask, |
39 | void (*alignf)(void *, struct resource *, resource_size_t, | 39 | resource_size_t (*alignf)(void *, |
40 | resource_size_t), | 40 | struct resource *, |
41 | resource_size_t, | ||
42 | resource_size_t), | ||
41 | void *alignf_data) | 43 | void *alignf_data) |
42 | { | 44 | { |
43 | int i, ret = -ENOMEM; | 45 | int i, ret = -ENOMEM; |
diff --git a/drivers/pcmcia/rsrc_mgr.c b/drivers/pcmcia/rsrc_mgr.c index 52db17263d8b..f92a2dac13a2 100644 --- a/drivers/pcmcia/rsrc_mgr.c +++ b/drivers/pcmcia/rsrc_mgr.c | |||
@@ -114,22 +114,20 @@ struct pcmcia_align_data { | |||
114 | unsigned long offset; | 114 | unsigned long offset; |
115 | }; | 115 | }; |
116 | 116 | ||
117 | static void pcmcia_align(void *align_data, struct resource *res, | 117 | static resource_size_t pcmcia_align(void *align_data, struct resource *res, |
118 | unsigned long size, unsigned long align) | 118 | resource_size_t size, resource_size_t align) |
119 | { | 119 | { |
120 | struct pcmcia_align_data *data = align_data; | 120 | struct pcmcia_align_data *data = align_data; |
121 | unsigned long start; | 121 | resource_size_t start; |
122 | 122 | ||
123 | start = (res->start & ~data->mask) + data->offset; | 123 | start = (res->start & ~data->mask) + data->offset; |
124 | if (start < res->start) | 124 | if (start < res->start) |
125 | start += data->mask + 1; | 125 | start += data->mask + 1; |
126 | res->start = start; | ||
127 | 126 | ||
128 | #ifdef CONFIG_X86 | 127 | #ifdef CONFIG_X86 |
129 | if (res->flags & IORESOURCE_IO) { | 128 | if (res->flags & IORESOURCE_IO) { |
130 | if (start & 0x300) { | 129 | if (start & 0x300) { |
131 | start = (start + 0x3ff) & ~0x3ff; | 130 | start = (start + 0x3ff) & ~0x3ff; |
132 | res->start = start; | ||
133 | } | 131 | } |
134 | } | 132 | } |
135 | #endif | 133 | #endif |
@@ -137,9 +135,11 @@ static void pcmcia_align(void *align_data, struct resource *res, | |||
137 | #ifdef CONFIG_M68K | 135 | #ifdef CONFIG_M68K |
138 | if (res->flags & IORESOURCE_IO) { | 136 | if (res->flags & IORESOURCE_IO) { |
139 | if ((res->start + size - 1) >= 1024) | 137 | if ((res->start + size - 1) >= 1024) |
140 | res->start = res->end; | 138 | start = res->end; |
141 | } | 139 | } |
142 | #endif | 140 | #endif |
141 | |||
142 | return start; | ||
143 | } | 143 | } |
144 | 144 | ||
145 | 145 | ||
diff --git a/drivers/pcmcia/rsrc_nonstatic.c b/drivers/pcmcia/rsrc_nonstatic.c index 9b0dc433a8c3..b65902870e44 100644 --- a/drivers/pcmcia/rsrc_nonstatic.c +++ b/drivers/pcmcia/rsrc_nonstatic.c | |||
@@ -533,7 +533,7 @@ struct pcmcia_align_data { | |||
533 | struct resource_map *map; | 533 | struct resource_map *map; |
534 | }; | 534 | }; |
535 | 535 | ||
536 | static void | 536 | static resource_size_t |
537 | pcmcia_common_align(void *align_data, struct resource *res, | 537 | pcmcia_common_align(void *align_data, struct resource *res, |
538 | resource_size_t size, resource_size_t align) | 538 | resource_size_t size, resource_size_t align) |
539 | { | 539 | { |
@@ -545,17 +545,18 @@ pcmcia_common_align(void *align_data, struct resource *res, | |||
545 | start = (res->start & ~data->mask) + data->offset; | 545 | start = (res->start & ~data->mask) + data->offset; |
546 | if (start < res->start) | 546 | if (start < res->start) |
547 | start += data->mask + 1; | 547 | start += data->mask + 1; |
548 | res->start = start; | 548 | return start; |
549 | } | 549 | } |
550 | 550 | ||
551 | static void | 551 | static resource_size_t |
552 | pcmcia_align(void *align_data, struct resource *res, resource_size_t size, | 552 | pcmcia_align(void *align_data, struct resource *res, resource_size_t size, |
553 | resource_size_t align) | 553 | resource_size_t align) |
554 | { | 554 | { |
555 | struct pcmcia_align_data *data = align_data; | 555 | struct pcmcia_align_data *data = align_data; |
556 | struct resource_map *m; | 556 | struct resource_map *m; |
557 | resource_size_t start; | ||
557 | 558 | ||
558 | pcmcia_common_align(data, res, size, align); | 559 | start = pcmcia_common_align(data, res, size, align); |
559 | 560 | ||
560 | for (m = data->map->next; m != data->map; m = m->next) { | 561 | for (m = data->map->next; m != data->map; m = m->next) { |
561 | unsigned long start = m->base; | 562 | unsigned long start = m->base; |
@@ -567,8 +568,7 @@ pcmcia_align(void *align_data, struct resource *res, resource_size_t size, | |||
567 | * fit here. | 568 | * fit here. |
568 | */ | 569 | */ |
569 | if (res->start < start) { | 570 | if (res->start < start) { |
570 | res->start = start; | 571 | start = pcmcia_common_align(data, res, size, align); |
571 | pcmcia_common_align(data, res, size, align); | ||
572 | } | 572 | } |
573 | 573 | ||
574 | /* | 574 | /* |
@@ -586,7 +586,9 @@ pcmcia_align(void *align_data, struct resource *res, resource_size_t size, | |||
586 | * If we failed to find something suitable, ensure we fail. | 586 | * If we failed to find something suitable, ensure we fail. |
587 | */ | 587 | */ |
588 | if (m == data->map) | 588 | if (m == data->map) |
589 | res->start = res->end; | 589 | start = res->end; |
590 | |||
591 | return start; | ||
590 | } | 592 | } |
591 | 593 | ||
592 | /* | 594 | /* |
diff --git a/include/linux/ioport.h b/include/linux/ioport.h index 7129504e053d..f4195de4eb9d 100644 --- a/include/linux/ioport.h +++ b/include/linux/ioport.h | |||
@@ -120,8 +120,10 @@ extern void insert_resource_expand_to_fit(struct resource *root, struct resource | |||
120 | extern int allocate_resource(struct resource *root, struct resource *new, | 120 | extern int allocate_resource(struct resource *root, struct resource *new, |
121 | resource_size_t size, resource_size_t min, | 121 | resource_size_t size, resource_size_t min, |
122 | resource_size_t max, resource_size_t align, | 122 | resource_size_t max, resource_size_t align, |
123 | void (*alignf)(void *, struct resource *, | 123 | resource_size_t (*alignf)(void *, |
124 | resource_size_t, resource_size_t), | 124 | struct resource *, |
125 | resource_size_t, | ||
126 | resource_size_t), | ||
125 | void *alignf_data); | 127 | void *alignf_data); |
126 | int adjust_resource(struct resource *res, resource_size_t start, | 128 | int adjust_resource(struct resource *res, resource_size_t start, |
127 | resource_size_t size); | 129 | resource_size_t size); |
diff --git a/include/linux/pci.h b/include/linux/pci.h index 16f48e7506ed..1bd9f52b24b8 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h | |||
@@ -592,7 +592,8 @@ int __must_check pcibios_enable_device(struct pci_dev *, int mask); | |||
592 | char *pcibios_setup(char *str); | 592 | char *pcibios_setup(char *str); |
593 | 593 | ||
594 | /* Used only when drivers/pci/setup.c is used */ | 594 | /* Used only when drivers/pci/setup.c is used */ |
595 | void pcibios_align_resource(void *, struct resource *, resource_size_t, | 595 | resource_size_t pcibios_align_resource(void *, struct resource *, |
596 | resource_size_t, | ||
596 | resource_size_t); | 597 | resource_size_t); |
597 | void pcibios_update_irq(struct pci_dev *, int irq); | 598 | void pcibios_update_irq(struct pci_dev *, int irq); |
598 | 599 | ||
@@ -827,8 +828,9 @@ int __must_check pci_bus_alloc_resource(struct pci_bus *bus, | |||
827 | struct resource *res, resource_size_t size, | 828 | struct resource *res, resource_size_t size, |
828 | resource_size_t align, resource_size_t min, | 829 | resource_size_t align, resource_size_t min, |
829 | unsigned int type_mask, | 830 | unsigned int type_mask, |
830 | void (*alignf)(void *, struct resource *, | 831 | resource_size_t (*alignf)(void *, struct resource *, |
831 | resource_size_t, resource_size_t), | 832 | resource_size_t, |
833 | resource_size_t), | ||
832 | void *alignf_data); | 834 | void *alignf_data); |
833 | void pci_enable_bridges(struct pci_bus *bus); | 835 | void pci_enable_bridges(struct pci_bus *bus); |
834 | 836 | ||
diff --git a/kernel/resource.c b/kernel/resource.c index af96c1e4b54b..e697f20e2288 100644 --- a/kernel/resource.c +++ b/kernel/resource.c | |||
@@ -303,8 +303,10 @@ int walk_system_ram_range(unsigned long start_pfn, unsigned long nr_pages, | |||
303 | static int find_resource(struct resource *root, struct resource *new, | 303 | static int find_resource(struct resource *root, struct resource *new, |
304 | resource_size_t size, resource_size_t min, | 304 | resource_size_t size, resource_size_t min, |
305 | resource_size_t max, resource_size_t align, | 305 | resource_size_t max, resource_size_t align, |
306 | void (*alignf)(void *, struct resource *, | 306 | resource_size_t (*alignf)(void *, |
307 | resource_size_t, resource_size_t), | 307 | struct resource *, |
308 | resource_size_t, | ||
309 | resource_size_t), | ||
308 | void *alignf_data) | 310 | void *alignf_data) |
309 | { | 311 | { |
310 | struct resource *this = root->child; | 312 | struct resource *this = root->child; |
@@ -330,7 +332,7 @@ static int find_resource(struct resource *root, struct resource *new, | |||
330 | tmp.end = max; | 332 | tmp.end = max; |
331 | tmp.start = ALIGN(tmp.start, align); | 333 | tmp.start = ALIGN(tmp.start, align); |
332 | if (alignf) | 334 | if (alignf) |
333 | alignf(alignf_data, &tmp, size, align); | 335 | tmp.start = alignf(alignf_data, &tmp, size, align); |
334 | if (tmp.start < tmp.end && tmp.end - tmp.start >= size - 1) { | 336 | if (tmp.start < tmp.end && tmp.end - tmp.start >= size - 1) { |
335 | new->start = tmp.start; | 337 | new->start = tmp.start; |
336 | new->end = tmp.start + size - 1; | 338 | new->end = tmp.start + size - 1; |
@@ -358,8 +360,10 @@ static int find_resource(struct resource *root, struct resource *new, | |||
358 | int allocate_resource(struct resource *root, struct resource *new, | 360 | int allocate_resource(struct resource *root, struct resource *new, |
359 | resource_size_t size, resource_size_t min, | 361 | resource_size_t size, resource_size_t min, |
360 | resource_size_t max, resource_size_t align, | 362 | resource_size_t max, resource_size_t align, |
361 | void (*alignf)(void *, struct resource *, | 363 | resource_size_t (*alignf)(void *, |
362 | resource_size_t, resource_size_t), | 364 | struct resource *, |
365 | resource_size_t, | ||
366 | resource_size_t), | ||
363 | void *alignf_data) | 367 | void *alignf_data) |
364 | { | 368 | { |
365 | int err; | 369 | int err; |