Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drivers/base/memory: Fix comments for phys_index_show()

According to 'admin-guide/mm/memory-hotplug.rst', the memory block ID,
instead of the section index, is shown by '/sys/devices/system/memory/
memoryX/phys_index'.

Fix the comments to match with 'admin-guide/mm/memory-hotplug.rst'.
Besides, use the existing helper memory_block_id() to convert the section
index to the memory block index.

No functional change intended.

Signed-off-by: Gavin Shan <gshan@redhat.com>
Link: https://lore.kernel.org/r/20230120055727.355483-2-gshan@redhat.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Gavin Shan and committed by
Greg Kroah-Hartman
7c09f428 f7d85515

+2 -7
+2 -7
drivers/base/memory.c
··· 115 115 } 116 116 EXPORT_SYMBOL_GPL(memory_block_size_bytes); 117 117 118 - /* 119 - * Show the first physical section index (number) of this memory block. 120 - */ 118 + /* Show the memory block ID, relative to the memory block size */ 121 119 static ssize_t phys_index_show(struct device *dev, 122 120 struct device_attribute *attr, char *buf) 123 121 { 124 122 struct memory_block *mem = to_memory_block(dev); 125 - unsigned long phys_index; 126 123 127 - phys_index = mem->start_section_nr / sections_per_block; 128 - 129 - return sysfs_emit(buf, "%08lx\n", phys_index); 124 + return sysfs_emit(buf, "%08lx\n", memory_block_id(mem->start_section_nr)); 130 125 } 131 126 132 127 /*