aboutsummaryrefslogtreecommitdiffstats
path: root/arch/m68k/amiga
diff options
context:
space:
mode:
authorGeert Uytterhoeven <geert@linux-m68k.org>2011-04-24 17:40:51 -0400
committerGeert Uytterhoeven <geert@linux-m68k.org>2011-07-30 15:21:38 -0400
commitcab49bc95d848a85d7108f896f6d21283f25f54c (patch)
treed3cf9c77dddce64dc238e7378cd924717a8d02db /arch/m68k/amiga
parent3a17bfa4fb37e7f8e06ef31feafec559bd4c6699 (diff)
m68k/amiga: Chip RAM - Change chipavail to an atomic_t
While the core resource handling code is safe, our global counter must still be protected against concurrent modifications. Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Diffstat (limited to 'arch/m68k/amiga')
-rw-r--r--arch/m68k/amiga/chipram.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/arch/m68k/amiga/chipram.c b/arch/m68k/amiga/chipram.c
index e5a8dbc9abaf..c3fe45125f52 100644
--- a/arch/m68k/amiga/chipram.c
+++ b/arch/m68k/amiga/chipram.c
@@ -16,6 +16,7 @@
16#include <linux/string.h> 16#include <linux/string.h>
17#include <linux/module.h> 17#include <linux/module.h>
18 18
19#include <asm/atomic.h>
19#include <asm/page.h> 20#include <asm/page.h>
20#include <asm/amigahw.h> 21#include <asm/amigahw.h>
21 22
@@ -25,7 +26,7 @@ EXPORT_SYMBOL(amiga_chip_size);
25static struct resource chipram_res = { 26static struct resource chipram_res = {
26 .name = "Chip RAM", .start = CHIP_PHYSADDR 27 .name = "Chip RAM", .start = CHIP_PHYSADDR
27}; 28};
28static unsigned long chipavail; 29static atomic_t chipavail;
29 30
30 31
31void __init amiga_chip_init(void) 32void __init amiga_chip_init(void)
@@ -36,7 +37,7 @@ void __init amiga_chip_init(void)
36 chipram_res.end = amiga_chip_size-1; 37 chipram_res.end = amiga_chip_size-1;
37 request_resource(&iomem_resource, &chipram_res); 38 request_resource(&iomem_resource, &chipram_res);
38 39
39 chipavail = amiga_chip_size; 40 atomic_set(&chipavail, amiga_chip_size);
40} 41}
41 42
42 43
@@ -84,7 +85,7 @@ void *amiga_chip_alloc_res(unsigned long size, struct resource *res)
84 return NULL; 85 return NULL;
85 } 86 }
86 87
87 chipavail -= size; 88 atomic_sub(size, &chipavail);
88 pr_debug("amiga_chip_alloc_res: returning %pR\n", res); 89 pr_debug("amiga_chip_alloc_res: returning %pR\n", res);
89 return (void *)ZTWO_VADDR(res->start); 90 return (void *)ZTWO_VADDR(res->start);
90} 91}
@@ -101,7 +102,7 @@ void amiga_chip_free(void *ptr)
101 *p = res->sibling; 102 *p = res->sibling;
102 size = res->end-start; 103 size = res->end-start;
103 pr_debug("amiga_chip_free: free %lu bytes at %p\n", size, ptr); 104 pr_debug("amiga_chip_free: free %lu bytes at %p\n", size, ptr);
104 chipavail += size; 105 atomic_add(size, &chipavail);
105 kfree(res); 106 kfree(res);
106 return; 107 return;
107 } 108 }
@@ -113,8 +114,10 @@ EXPORT_SYMBOL(amiga_chip_free);
113 114
114unsigned long amiga_chip_avail(void) 115unsigned long amiga_chip_avail(void)
115{ 116{
116 pr_debug("amiga_chip_avail : %lu bytes\n", chipavail); 117 unsigned long n = atomic_read(&chipavail);
117 return chipavail; 118
119 pr_debug("amiga_chip_avail : %lu bytes\n", n);
120 return n;
118} 121}
119EXPORT_SYMBOL(amiga_chip_avail); 122EXPORT_SYMBOL(amiga_chip_avail);
120 123