diff options
author | Michael Ellerman <michael@ellerman.id.au> | 2010-01-12 16:25:24 -0500 |
---|---|---|
committer | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2010-02-03 01:39:50 -0500 |
commit | 24551f64d47af9539a7f324343bffeea09d9dcfa (patch) | |
tree | 4a6e8660f0cd71a3e8ad97b221ac2ae2da1da322 /lib | |
parent | 859aefc5afc6c00dae630680e5470f7a2c27c4a0 (diff) |
lmb: Add lmb_free()
We can free memory allocated with lmb_alloc() by removing it from the
list of reserved LMBs. Rework lmb_remove() to allow that possibility
and add lmb_free() which exploits it.
BenH: Removed some useless parenthesis
Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/lmb.c | 13 |
1 files changed, 11 insertions, 2 deletions
@@ -205,9 +205,8 @@ long lmb_add(u64 base, u64 size) | |||
205 | 205 | ||
206 | } | 206 | } |
207 | 207 | ||
208 | long lmb_remove(u64 base, u64 size) | 208 | static long __lmb_remove(struct lmb_region *rgn, u64 base, u64 size) |
209 | { | 209 | { |
210 | struct lmb_region *rgn = &(lmb.memory); | ||
211 | u64 rgnbegin, rgnend; | 210 | u64 rgnbegin, rgnend; |
212 | u64 end = base + size; | 211 | u64 end = base + size; |
213 | int i; | 212 | int i; |
@@ -254,6 +253,16 @@ long lmb_remove(u64 base, u64 size) | |||
254 | return lmb_add_region(rgn, end, rgnend - end); | 253 | return lmb_add_region(rgn, end, rgnend - end); |
255 | } | 254 | } |
256 | 255 | ||
256 | long lmb_remove(u64 base, u64 size) | ||
257 | { | ||
258 | return __lmb_remove(&lmb.memory, base, size); | ||
259 | } | ||
260 | |||
261 | long __init lmb_free(u64 base, u64 size) | ||
262 | { | ||
263 | return __lmb_remove(&lmb.reserved, base, size); | ||
264 | } | ||
265 | |||
257 | long __init lmb_reserve(u64 base, u64 size) | 266 | long __init lmb_reserve(u64 base, u64 size) |
258 | { | 267 | { |
259 | struct lmb_region *_rgn = &lmb.reserved; | 268 | struct lmb_region *_rgn = &lmb.reserved; |