Re: [PATCH 7/7] drivers: base: refactor add_memory_section() to add_memory_block()
From: Yasuaki Ishimatsu <hidden>
Date: 2013-08-22 08:21:10
(2013/08/21 2:13), Seth Jennings wrote:
quoted hunk
Right now memory_dev_init() maintains the memory block pointer between iterations of add_memory_section(). This is nasty. This patch refactors add_memory_section() to become add_memory_block(). The refactoring pulls the section scanning out of memory_dev_init() and simplifies the signature. Signed-off-by: Seth Jennings <redacted> --- drivers/base/memory.c | 48 +++++++++++++++++++++--------------------------- 1 file changed, 21 insertions(+), 27 deletions(-)diff --git a/drivers/base/memory.c b/drivers/base/memory.c index 7d9d3bc..021283a 100644 --- a/drivers/base/memory.c +++ b/drivers/base/memory.c@@ -602,32 +602,31 @@ static int init_memory_block(struct memory_block **memory, return ret; } -static int add_memory_section(struct mem_section *section, - struct memory_block **mem_p) +static int add_memory_block(int base_section_nr) { - struct memory_block *mem = NULL; - int scn_nr = __section_nr(section); - int ret = 0; - - if (mem_p && *mem_p) { - if (scn_nr >= (*mem_p)->start_section_nr && - scn_nr <= (*mem_p)->end_section_nr) { - mem = *mem_p; - } - } + struct memory_block *mem; + int i, ret, section_count = 0, section_nr; - if (mem) - mem->section_count++; - else {
Why do you remove present_setcion_nr() check?
+ err = add_memory_block(i); if (!ret)
Thanks, Yasuaki Ishimatasu
ret = err; }