[U-Boot-Users] [PATCH 2/4] Add lmb_free

Jean-Christophe PLAGNIOL-VILLARD plagnioj at jcrosoft.com
Tue May 20 23:11:04 CEST 2008


On 15:24 Tue 20 May     , Andy Fleming wrote:
> lmb_free allows us to unreserve some memory so we can use lmb_alloc_base or
> lmb_reserve to temporarily reserve some memory.
> 
> Signed-off-by: Andy Fleming <afleming at freescale.com>
> ---
>  lib_generic/lmb.c |   49 +++++++++++++++++++++++++++++++++++++++++++++++++
>  1 files changed, 49 insertions(+), 0 deletions(-)
> 
> diff --git a/lib_generic/lmb.c b/lib_generic/lmb.c
> index 3b8c805..a34e2d3 100644
> --- a/lib_generic/lmb.c
> +++ b/lib_generic/lmb.c
> @@ -180,6 +180,55 @@ long lmb_add(struct lmb *lmb, ulong base, ulong size)
>  	return lmb_add_region(_rgn, base, size);
>  }
>  
> +long lmb_free(struct lmb *lmb, u64 base, u64 size)
> +{
> +	struct lmb_region *rgn = &(lmb->reserved);
> +	u64 rgnbegin, rgnend;
> +	u64 end = base + size;
> +	int i;
> +
> +	rgnbegin = rgnend = 0; /* supress gcc warnings */
> +
> +	/* Find the region where (base, size) belongs to */
> +	for (i=0; i < rgn->cnt; i++) {
please i = 0
> +		rgnbegin = rgn->region[i].base;
> +		rgnend = rgnbegin + rgn->region[i].size;
> +
> +		if ((rgnbegin <= base) && (end <= rgnend))
> +			break;
Best Regards,
J.




More information about the U-Boot mailing list