On 07.01.25 11:09, Shiyang Ruan wrote:
No need to specific position at the first writing to the buf because the @len is always 0 at this time. Use sysfs_emit() instead to simplify it. Signed-off-by: Shiyang Ruan <ruansy.fnst@xxxxxxxxxxx> --- drivers/base/memory.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/base/memory.c b/drivers/base/memory.c index 67858eeb92ed..d77a83c9af39 100644 --- a/drivers/base/memory.c +++ b/drivers/base/memory.c @@ -469,19 +469,17 @@ static ssize_t valid_zones_show(struct device *dev, 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", default_zone->name);
We can go one step further and do: return sysfs_emit(buf, "%s\n", mem->zone ? mem->zone->name : "none"); Avoiding setting/checking default_zone. -- Cheers, David / dhildenb