mirror of
https://github.com/torvalds/linux.git
synced 2026-04-18 14:53:58 -04:00
drivers/base/memory: simplify outputting of valid_zones_show()
No need to specify position at the first writing to the buf because the @len is always 0 at this time. Use sysfs_emit() instead to simplify it. Also avoid setting/checking default_zone with a conditional operator. Link: https://lkml.kernel.org/r/20250108015223.1522887-1-ruansy.fnst@fujitsu.com Signed-off-by: Shiyang Ruan <ruansy.fnst@fujitsu.com> Acked-by: David Hildenbrand <david@redhat.com> Cc: Oscar Salvador <osalvador@suse.de> Cc: "Rafael J. Wysocki" <rafael@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
committed by
Andrew Morton
parent
ad4c9bb541
commit
100bc3b877
@@ -455,7 +455,7 @@ static ssize_t valid_zones_show(struct device *dev,
|
||||
struct memory_group *group = mem->group;
|
||||
struct zone *default_zone;
|
||||
int nid = mem->nid;
|
||||
int len = 0;
|
||||
int len;
|
||||
|
||||
/*
|
||||
* Check the existing zone. Make sure that we do that only on the
|
||||
@@ -466,22 +466,18 @@ static ssize_t valid_zones_show(struct device *dev,
|
||||
* If !mem->zone, the memory block spans multiple zones and
|
||||
* cannot get offlined.
|
||||
*/
|
||||
default_zone = mem->zone;
|
||||
if (!default_zone)
|
||||
return sysfs_emit(buf, "%s\n", "none");
|
||||
len += sysfs_emit_at(buf, len, "%s", default_zone->name);
|
||||
goto out;
|
||||
return sysfs_emit(buf, "%s\n",
|
||||
mem->zone ? mem->zone->name : "none");
|
||||
}
|
||||
|
||||
default_zone = zone_for_pfn_range(MMOP_ONLINE, nid, group,
|
||||
start_pfn, nr_pages);
|
||||
|
||||
len += sysfs_emit_at(buf, len, "%s", default_zone->name);
|
||||
len = sysfs_emit(buf, "%s", default_zone->name);
|
||||
len += print_allowed_zone(buf, len, nid, group, start_pfn, nr_pages,
|
||||
MMOP_ONLINE_KERNEL, default_zone);
|
||||
len += print_allowed_zone(buf, len, nid, group, start_pfn, nr_pages,
|
||||
MMOP_ONLINE_MOVABLE, default_zone);
|
||||
out:
|
||||
len += sysfs_emit_at(buf, len, "\n");
|
||||
return len;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user