From: David Hildenbrand <david@redhat.com>
To: Shiyang Ruan <ruansy.fnst@fujitsu.com>
Cc: linux-mm@kvack.org, osalvador@suse.de, rafael@kernel.org
Subject: Re: [PATCH] drivers/base/memory: simplify outputting of valid_zones_show()
Date: Tue, 7 Jan 2025 11:33:10 +0100 [thread overview]
Message-ID: <6710b03e-7bfa-4852-9555-ad5b9b8b85cd@redhat.com> (raw)
In-Reply-To: <d5826938-4bde-4717-9dd6-7e51f00dd077@fujitsu.com>
On 07.01.25 11:28, Shiyang Ruan wrote:
>
>
> 在 2025/1/7 18:15, David Hildenbrand 写道:
>> 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@fujitsu.com>
>>> ---
>>> 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.
>
> I have thought about it but it would cause the line over long.
I think it fits even into 80 chars just fine if you split it across two
lines like I suggested.
But yeah, a single line might be fine as well.
--
Cheers,
David / dhildenb
next prev parent reply other threads:[~2025-01-07 10:33 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-07 10:09 Shiyang Ruan
2025-01-07 10:15 ` David Hildenbrand
2025-01-07 10:28 ` Shiyang Ruan
2025-01-07 10:33 ` David Hildenbrand [this message]
2025-01-07 10:39 ` [PATCH v2] " Shiyang Ruan
2025-01-07 10:52 ` David Hildenbrand
2025-01-08 1:52 ` [PATCH v3] " Shiyang Ruan
2025-01-22 10:14 ` Shiyang Ruan
2025-01-22 11:04 ` David Hildenbrand
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6710b03e-7bfa-4852-9555-ad5b9b8b85cd@redhat.com \
--to=david@redhat.com \
--cc=linux-mm@kvack.org \
--cc=osalvador@suse.de \
--cc=rafael@kernel.org \
--cc=ruansy.fnst@fujitsu.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox