diff options
author | Geert Uytterhoeven <geert@linux-m68k.org> | 2011-04-24 17:19:05 -0400 |
---|---|---|
committer | Geert Uytterhoeven <geert@linux-m68k.org> | 2011-07-30 15:21:38 -0400 |
commit | 3a17bfa4fb37e7f8e06ef31feafec559bd4c6699 (patch) | |
tree | df5d877a6da920b5acbefddd4951c5e197c16343 /arch/m68k/amiga/chipram.c | |
parent | b4f6f45302a9440e26f71dab0b95906bcc3bd13a (diff) |
m68k/amiga: Chip RAM - Always allocate from the start of memory
As of commit 5df1abdbd37af2ae317a1c5b5944173284dc55d6 ('m68k/amiga: Fix
"debug=mem"'), "debug=mem" no longer uses amiga_chip_alloc_res(), so we
can remove the hack to prefer memory at the safe end.
This allows to simplify the code and make amiga_chip_alloc() just call
amiga_chip_alloc_res() internally.
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Diffstat (limited to 'arch/m68k/amiga/chipram.c')
-rw-r--r-- | arch/m68k/amiga/chipram.c | 35 |
1 files changed, 15 insertions, 20 deletions
diff --git a/arch/m68k/amiga/chipram.c b/arch/m68k/amiga/chipram.c index 9005fa07f2e2..e5a8dbc9abaf 100644 --- a/arch/m68k/amiga/chipram.c +++ b/arch/m68k/amiga/chipram.c | |||
@@ -43,24 +43,20 @@ void __init amiga_chip_init(void) | |||
43 | void *amiga_chip_alloc(unsigned long size, const char *name) | 43 | void *amiga_chip_alloc(unsigned long size, const char *name) |
44 | { | 44 | { |
45 | struct resource *res; | 45 | struct resource *res; |
46 | void *p; | ||
46 | 47 | ||
47 | /* round up */ | ||
48 | size = PAGE_ALIGN(size); | ||
49 | |||
50 | pr_debug("amiga_chip_alloc: allocate %lu bytes\n", size); | ||
51 | res = kzalloc(sizeof(struct resource), GFP_KERNEL); | 48 | res = kzalloc(sizeof(struct resource), GFP_KERNEL); |
52 | if (!res) | 49 | if (!res) |
53 | return NULL; | 50 | return NULL; |
54 | res->name = name; | ||
55 | 51 | ||
56 | if (allocate_resource(&chipram_res, res, size, 0, UINT_MAX, PAGE_SIZE, | 52 | res->name = name; |
57 | NULL, NULL) < 0) { | 53 | p = amiga_chip_alloc_res(size, res); |
54 | if (!p) { | ||
58 | kfree(res); | 55 | kfree(res); |
59 | return NULL; | 56 | return NULL; |
60 | } | 57 | } |
61 | chipavail -= size; | 58 | |
62 | pr_debug("amiga_chip_alloc: returning %pR\n", res); | 59 | return p; |
63 | return (void *)ZTWO_VADDR(res->start); | ||
64 | } | 60 | } |
65 | EXPORT_SYMBOL(amiga_chip_alloc); | 61 | EXPORT_SYMBOL(amiga_chip_alloc); |
66 | 62 | ||
@@ -72,23 +68,22 @@ EXPORT_SYMBOL(amiga_chip_alloc); | |||
72 | * those drivers must not free that Chip RAM afterwards. | 68 | * those drivers must not free that Chip RAM afterwards. |
73 | */ | 69 | */ |
74 | 70 | ||
75 | void * __init amiga_chip_alloc_res(unsigned long size, struct resource *res) | 71 | void *amiga_chip_alloc_res(unsigned long size, struct resource *res) |
76 | { | 72 | { |
77 | unsigned long start; | 73 | int error; |
78 | 74 | ||
79 | /* round up */ | 75 | /* round up */ |
80 | size = PAGE_ALIGN(size); | 76 | size = PAGE_ALIGN(size); |
81 | /* dmesg into chipmem prefers memory at the safe end */ | ||
82 | start = CHIP_PHYSADDR + chipavail - size; | ||
83 | 77 | ||
84 | pr_debug("amiga_chip_alloc_res: allocate %lu bytes\n", size); | 78 | pr_debug("amiga_chip_alloc_res: allocate %lu bytes\n", size); |
85 | if (allocate_resource(&chipram_res, res, size, start, UINT_MAX, | 79 | error = allocate_resource(&chipram_res, res, size, 0, UINT_MAX, |
86 | PAGE_SIZE, NULL, NULL) < 0) { | 80 | PAGE_SIZE, NULL, NULL); |
87 | pr_err("amiga_chip_alloc_res: first alloc failed!\n"); | 81 | if (error < 0) { |
88 | if (allocate_resource(&chipram_res, res, size, 0, UINT_MAX, | 82 | pr_err("amiga_chip_alloc_res: allocate_resource() failed %d!\n", |
89 | PAGE_SIZE, NULL, NULL) < 0) | 83 | error); |
90 | return NULL; | 84 | return NULL; |
91 | } | 85 | } |
86 | |||
92 | chipavail -= size; | 87 | chipavail -= size; |
93 | pr_debug("amiga_chip_alloc_res: returning %pR\n", res); | 88 | pr_debug("amiga_chip_alloc_res: returning %pR\n", res); |
94 | return (void *)ZTWO_VADDR(res->start); | 89 | return (void *)ZTWO_VADDR(res->start); |