All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] drivers/base/memory: init_memory_block() first parameter is not necessary
@ 2020-06-23  2:57 Wei Yang
  2020-06-23  2:57 ` [PATCH 2/2] drivers/base/memory: rename base_memory_block_id to memory_block_id Wei Yang
  0 siblings, 1 reply; 2+ messages in thread
From: Wei Yang @ 2020-06-23  2:57 UTC (permalink / raw)
  To: gregkh, rafael; +Cc: linux-kernel, Wei Yang

The first parameter of init_memory_block() is intended to retrieve the
memory_block initiated. But now, we never use it.

Drop it for now.

Signed-off-by: Wei Yang <richard.weiyang@linux.alibaba.com>
---
 drivers/base/memory.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/base/memory.c b/drivers/base/memory.c
index 2b09b68b9f78..35f9a1aa0a2e 100644
--- a/drivers/base/memory.c
+++ b/drivers/base/memory.c
@@ -570,8 +570,7 @@ int register_memory(struct memory_block *memory)
 	return ret;
 }
 
-static int init_memory_block(struct memory_block **memory,
-			     unsigned long block_id, unsigned long state)
+static int init_memory_block(unsigned long block_id, unsigned long state)
 {
 	struct memory_block *mem;
 	unsigned long start_pfn;
@@ -594,14 +593,12 @@ static int init_memory_block(struct memory_block **memory,
 
 	ret = register_memory(mem);
 
-	*memory = mem;
 	return ret;
 }
 
 static int add_memory_block(unsigned long base_section_nr)
 {
 	int section_count = 0;
-	struct memory_block *mem;
 	unsigned long nr;
 
 	for (nr = base_section_nr; nr < base_section_nr + sections_per_block;
@@ -611,7 +608,7 @@ static int add_memory_block(unsigned long base_section_nr)
 
 	if (section_count == 0)
 		return 0;
-	return init_memory_block(&mem, base_memory_block_id(base_section_nr),
+	return init_memory_block(base_memory_block_id(base_section_nr),
 				 MEM_ONLINE);
 }
 
@@ -647,7 +644,7 @@ int create_memory_block_devices(unsigned long start, unsigned long size)
 		return -EINVAL;
 
 	for (block_id = start_block_id; block_id != end_block_id; block_id++) {
-		ret = init_memory_block(&mem, block_id, MEM_OFFLINE);
+		ret = init_memory_block(block_id, MEM_OFFLINE);
 		if (ret)
 			break;
 	}
-- 
2.20.1 (Apple Git-117)


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [PATCH 2/2] drivers/base/memory: rename base_memory_block_id to memory_block_id
  2020-06-23  2:57 [PATCH 1/2] drivers/base/memory: init_memory_block() first parameter is not necessary Wei Yang
@ 2020-06-23  2:57 ` Wei Yang
  0 siblings, 0 replies; 2+ messages in thread
From: Wei Yang @ 2020-06-23  2:57 UTC (permalink / raw)
  To: gregkh, rafael; +Cc: linux-kernel, Wei Yang

memory_block may have a larger granularity than section, this is why we
have base_section_nr. But base_memory_block_id seems a little
misleading, since there is no larger granularity concept which groups
several memory_block.

What we need here is the exact memory_block_id to a section_nr. Let's
rename it to make it more precise.

Signed-off-by: Wei Yang <richard.weiyang@linux.alibaba.com>
---
 drivers/base/memory.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/base/memory.c b/drivers/base/memory.c
index 35f9a1aa0a2e..4db3c660de83 100644
--- a/drivers/base/memory.c
+++ b/drivers/base/memory.c
@@ -50,14 +50,14 @@ int memhp_online_type_from_str(const char *str)
 
 static int sections_per_block;
 
-static inline unsigned long base_memory_block_id(unsigned long section_nr)
+static inline unsigned long memory_block_id(unsigned long section_nr)
 {
 	return section_nr / sections_per_block;
 }
 
 static inline unsigned long pfn_to_block_id(unsigned long pfn)
 {
-	return base_memory_block_id(pfn_to_section_nr(pfn));
+	return memory_block_id(pfn_to_section_nr(pfn));
 }
 
 static inline unsigned long phys_to_block_id(unsigned long phys)
@@ -517,7 +517,7 @@ static struct memory_block *find_memory_block_by_id(unsigned long block_id)
  */
 struct memory_block *find_memory_block(struct mem_section *section)
 {
-	unsigned long block_id = base_memory_block_id(__section_nr(section));
+	unsigned long block_id = memory_block_id(__section_nr(section));
 
 	return find_memory_block_by_id(block_id);
 }
@@ -608,7 +608,7 @@ static int add_memory_block(unsigned long base_section_nr)
 
 	if (section_count == 0)
 		return 0;
-	return init_memory_block(base_memory_block_id(base_section_nr),
+	return init_memory_block(memory_block_id(base_section_nr),
 				 MEM_ONLINE);
 }
 
-- 
2.20.1 (Apple Git-117)


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-06-23  2:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-23  2:57 [PATCH 1/2] drivers/base/memory: init_memory_block() first parameter is not necessary Wei Yang
2020-06-23  2:57 ` [PATCH 2/2] drivers/base/memory: rename base_memory_block_id to memory_block_id Wei Yang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.