Re: [PATCH 7/7] drivers: base: refactor add_memory_section() to add_memory_block()

2 messages, 1 author, 2013-08-22 · open the first message on its own page

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 {

47 more quoted lines

Why do you remove present_setcion_nr() check?
+		err = add_memory_block(i);
  		if (!ret)
Thanks,
Yasuaki Ishimatasu
  			ret = err;
  	}

Re: [PATCH 7/7] drivers: base: refactor add_memory_section() to add_memory_block()

From: Yasuaki Ishimatsu <hidden>
Date: 2013-08-22 08:31:43

(2013/08/22 17:20), Yasuaki Ishimatsu wrote:
(2013/08/21 2:13), Seth Jennings wrote:
quoted
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++;

50 more quoted lines

Sorry for the noise. I understood.
The check was moved into add_memory_section(). So it was removed.

Thanks,
Yasuaki Ishimatsu
quoted
+		err = add_memory_block(i);
   		if (!ret)
Thanks,
Yasuaki Ishimatasu
quoted
   			ret = err;
   	}

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help