drivers/base: move memory_block_add_nid() into the caller

Now the node id only needs to be set for early memory, so move
memory_block_add_nid() into the caller and rename it into
memory_block_add_nid_early().  This allows us to further simplify the code
by dropping the 'context' argument to
do_register_memory_block_under_node().

Link: https://lkml.kernel.org/r/20250729064637.51662-4-hare@kernel.org
Suggested-by: David Hildenbrand <david@redhat.com>
Signed-off-by: Hannes Reinecke <hare@kernel.org>
Acked-by: David Hildenbrand <david@redhat.com>
Acked-by: Oscar Salvador <osalvador@suse.de>
Reviewed-by: Donet Tom <donettom@linux.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
Hannes Reinecke
2025-07-29 08:46:36 +02:00
committed by Andrew Morton
parent b8179af120
commit 0a947c14e4
3 changed files with 23 additions and 26 deletions

View File

@@ -781,13 +781,10 @@ int unregister_cpu_under_node(unsigned int cpu, unsigned int nid)
#ifdef CONFIG_MEMORY_HOTPLUG
static void do_register_memory_block_under_node(int nid,
struct memory_block *mem_blk,
enum meminit_context context)
struct memory_block *mem_blk)
{
int ret;
memory_block_add_nid(mem_blk, nid, context);
ret = sysfs_create_link_nowarn(&node_devices[nid]->dev.kobj,
&mem_blk->dev.kobj,
kobject_name(&mem_blk->dev.kobj));
@@ -815,7 +812,7 @@ static int register_mem_block_under_node_hotplug(struct memory_block *mem_blk,
{
int nid = *(int *)arg;
do_register_memory_block_under_node(nid, mem_blk, MEMINIT_HOTPLUG);
do_register_memory_block_under_node(nid, mem_blk);
return 0;
}
@@ -855,7 +852,8 @@ static void register_memory_blocks_under_nodes(void)
if (!mem)
continue;
do_register_memory_block_under_node(nid, mem, MEMINIT_EARLY);
memory_block_add_nid_early(mem, nid);
do_register_memory_block_under_node(nid, mem);
put_device(&mem->dev);
}