Re: [PATCH] powerpc: Add dt_xlate_addr() to bootwrapper
From: Mark A. Greer <hidden>
Date: 2007-04-13 22:36:54
On Fri, Apr 13, 2007 at 05:25:51PM -0500, Scott Wood wrote:
On Fri, Apr 13, 2007 at 01:23:43PM -0700, Mark A. Greer wrote:quoted
+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.
Okay, I'll look closer this time. Thanks for checking. Mark