[PATCH] powerpc: Add dt_xlate_addr() to bootwrapper

Scott Wood scottwood at freescale.com
Sat Apr 14 08:25:51 EST 2007


On Fri, Apr 13, 2007 at 01:23:43PM -0700, Mark A. Greer wrote:
> +int dt_xlate(void *node, u32 *buf, int buflen, int res, unsigned long *addr,
> +		unsigned long *size)
>  {
> -	u32 last_addr[MAX_ADDR_CELLS];
> -	u32 this_addr[MAX_ADDR_CELLS];
> -	u32 buf[MAX_ADDR_CELLS * MAX_RANGES * 3];
> +	u32 last_addr[DT_MAX_ADDR_CELLS];
> +	u32 this_addr[DT_MAX_ADDR_CELLS];
>  	void *parent;

This causes it to use the caller-provided buffer to read the ranges
property, which may not be large enough in the case of dt_xlate_addr().
Plus, buf being a pointer rather than an array will cause the sizeof(buf)
that gets passed to getprop() to be only sizeof(u32 *).

Instead, I'd declare "rangebuf" as a static array, and accept "regbuf" as
a parameter (with a comment that regbuf can alias rangebuf).  Then,
dt_xlate_reg() can use rangebuf as regbuf, dt_xlate_addr()'s caller
doesn't have to worry about its buffer being big enough to hold ranges,
and we don't have to allocate two 384-byte buffers on the stack.

-Scott



More information about the Linuxppc-dev mailing list