diff options
author | Timur Tabi <timur@freescale.com> | 2007-05-08 15:46:36 -0400 |
---|---|---|
committer | Kumar Gala <galak@kernel.crashing.org> | 2007-05-10 00:01:43 -0400 |
commit | 4c35630ccda56ed494f6102d2e147fefe14b78d2 (patch) | |
tree | 4f04754fb0ec6978923b3c1e0318997e420f6551 /arch/ppc/syslib | |
parent | 742226c579c573c24386aaf41969a01ee058b97e (diff) |
[POWERPC] Change rheap functions to use ulongs instead of pointers
The rheap allocation functions return a pointer, but the actual value is based
on how the heap was initialized, and so it can be anything, e.g. an offset
into a buffer. A ulong is a better representation of the value returned by
the allocation functions.
This patch changes all of the relevant rheap functions to use a unsigned long
integers instead of a pointer. In case of an error, the value returned is
a negative error code that has been cast to an unsigned long. The caller can
use the IS_ERR_VALUE() macro to check for this.
All code which calls the rheap functions is updated accordingly. Macros
IS_MURAM_ERR() and IS_DPERR(), have been deleted in favor of IS_ERR_VALUE().
Also added error checking to rh_attach_region().
Signed-off-by: Timur Tabi <timur@freescale.com>
Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
Diffstat (limited to 'arch/ppc/syslib')
-rw-r--r-- | arch/ppc/syslib/cpm2_common.c | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/arch/ppc/syslib/cpm2_common.c b/arch/ppc/syslib/cpm2_common.c index cbac44b1620c..6cd859d7721f 100644 --- a/arch/ppc/syslib/cpm2_common.c +++ b/arch/ppc/syslib/cpm2_common.c | |||
@@ -136,15 +136,14 @@ static void cpm2_dpinit(void) | |||
136 | * varies with the processor and the microcode patches activated. | 136 | * varies with the processor and the microcode patches activated. |
137 | * But the following should be at least safe. | 137 | * But the following should be at least safe. |
138 | */ | 138 | */ |
139 | rh_attach_region(&cpm_dpmem_info, (void *)CPM_DATAONLY_BASE, | 139 | rh_attach_region(&cpm_dpmem_info, CPM_DATAONLY_BASE, CPM_DATAONLY_SIZE); |
140 | CPM_DATAONLY_SIZE); | ||
141 | } | 140 | } |
142 | 141 | ||
143 | /* This function returns an index into the DPRAM area. | 142 | /* This function returns an index into the DPRAM area. |
144 | */ | 143 | */ |
145 | uint cpm_dpalloc(uint size, uint align) | 144 | unsigned long cpm_dpalloc(uint size, uint align) |
146 | { | 145 | { |
147 | void *start; | 146 | unsigned long start; |
148 | unsigned long flags; | 147 | unsigned long flags; |
149 | 148 | ||
150 | spin_lock_irqsave(&cpm_dpmem_lock, flags); | 149 | spin_lock_irqsave(&cpm_dpmem_lock, flags); |
@@ -152,17 +151,17 @@ uint cpm_dpalloc(uint size, uint align) | |||
152 | start = rh_alloc(&cpm_dpmem_info, size, "commproc"); | 151 | start = rh_alloc(&cpm_dpmem_info, size, "commproc"); |
153 | spin_unlock_irqrestore(&cpm_dpmem_lock, flags); | 152 | spin_unlock_irqrestore(&cpm_dpmem_lock, flags); |
154 | 153 | ||
155 | return (uint)start; | 154 | return start; |
156 | } | 155 | } |
157 | EXPORT_SYMBOL(cpm_dpalloc); | 156 | EXPORT_SYMBOL(cpm_dpalloc); |
158 | 157 | ||
159 | int cpm_dpfree(uint offset) | 158 | int cpm_dpfree(unsigned long offset) |
160 | { | 159 | { |
161 | int ret; | 160 | int ret; |
162 | unsigned long flags; | 161 | unsigned long flags; |
163 | 162 | ||
164 | spin_lock_irqsave(&cpm_dpmem_lock, flags); | 163 | spin_lock_irqsave(&cpm_dpmem_lock, flags); |
165 | ret = rh_free(&cpm_dpmem_info, (void *)offset); | 164 | ret = rh_free(&cpm_dpmem_info, offset); |
166 | spin_unlock_irqrestore(&cpm_dpmem_lock, flags); | 165 | spin_unlock_irqrestore(&cpm_dpmem_lock, flags); |
167 | 166 | ||
168 | return ret; | 167 | return ret; |
@@ -170,17 +169,17 @@ int cpm_dpfree(uint offset) | |||
170 | EXPORT_SYMBOL(cpm_dpfree); | 169 | EXPORT_SYMBOL(cpm_dpfree); |
171 | 170 | ||
172 | /* not sure if this is ever needed */ | 171 | /* not sure if this is ever needed */ |
173 | uint cpm_dpalloc_fixed(uint offset, uint size, uint align) | 172 | unsigned long cpm_dpalloc_fixed(unsigned long offset, uint size, uint align) |
174 | { | 173 | { |
175 | void *start; | 174 | unsigned long start; |
176 | unsigned long flags; | 175 | unsigned long flags; |
177 | 176 | ||
178 | spin_lock_irqsave(&cpm_dpmem_lock, flags); | 177 | spin_lock_irqsave(&cpm_dpmem_lock, flags); |
179 | cpm_dpmem_info.alignment = align; | 178 | cpm_dpmem_info.alignment = align; |
180 | start = rh_alloc_fixed(&cpm_dpmem_info, (void *)offset, size, "commproc"); | 179 | start = rh_alloc_fixed(&cpm_dpmem_info, offset, size, "commproc"); |
181 | spin_unlock_irqrestore(&cpm_dpmem_lock, flags); | 180 | spin_unlock_irqrestore(&cpm_dpmem_lock, flags); |
182 | 181 | ||
183 | return (uint)start; | 182 | return start; |
184 | } | 183 | } |
185 | EXPORT_SYMBOL(cpm_dpalloc_fixed); | 184 | EXPORT_SYMBOL(cpm_dpalloc_fixed); |
186 | 185 | ||
@@ -190,7 +189,7 @@ void cpm_dpdump(void) | |||
190 | } | 189 | } |
191 | EXPORT_SYMBOL(cpm_dpdump); | 190 | EXPORT_SYMBOL(cpm_dpdump); |
192 | 191 | ||
193 | void *cpm_dpram_addr(uint offset) | 192 | void *cpm_dpram_addr(unsigned long offset) |
194 | { | 193 | { |
195 | return (void *)&cpm2_immr->im_dprambase[offset]; | 194 | return (void *)&cpm2_immr->im_dprambase[offset]; |
196 | } | 195 | } |