From: Gerhard Engleder <gerhard@engleder-embedded.com>
To: xie.ludan@zte.com.cn
Cc: edumazet@google.com, kuba@kernel.org, pabeni@redhat.com,
horms@kernel.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, xu.xin16@zte.com.cn,
yang.yang29@zte.com.cn, davem@davemloft.net
Subject: Re: [PATCH linux-next] net: atm: use sysfs_emit()/sysfs_emit_at() instead of scnprintf().
Date: Tue, 18 Mar 2025 19:58:29 +0100 [thread overview]
Message-ID: <46a0a5e2-2def-4ed1-ab54-40b6c8393239@engleder-embedded.com> (raw)
In-Reply-To: <20250317152933756kWrF1Y_e-2EKtrR_GGegq@zte.com.cn>
On 17.03.25 08:29, xie.ludan@zte.com.cn wrote:
> From: XieLudan <xie.ludan@zte.com.cn>
>
> Follow the advice in Documentation/filesystems/sysfs.rst:
> show() should only use sysfs_emit() or sysfs_emit_at() when formatting
> the value to be returned to user space.
>
> Signed-off-by: XieLudan <xie.ludan@zte.com.cn>
> ---
> net/atm/atm_sysfs.c | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/net/atm/atm_sysfs.c b/net/atm/atm_sysfs.c
> index 54e7fb1a4ee5..ae0d921157c5 100644
> --- a/net/atm/atm_sysfs.c
> +++ b/net/atm/atm_sysfs.c
> @@ -16,7 +16,7 @@ static ssize_t type_show(struct device *cdev,
> {
> struct atm_dev *adev = to_atm_dev(cdev);
>
> - return scnprintf(buf, PAGE_SIZE, "%s\n", adev->type);
> + return sysfs_emit(buf, "%s\n", adev->type);
> }
>
> static ssize_t address_show(struct device *cdev,
> @@ -24,7 +24,7 @@ static ssize_t address_show(struct device *cdev,
> {
> struct atm_dev *adev = to_atm_dev(cdev);
>
> - return scnprintf(buf, PAGE_SIZE, "%pM\n", adev->esi);
> + return sysfs_emit(buf, "%pM\n", adev->esi);
> }
>
> static ssize_t atmaddress_show(struct device *cdev,
> @@ -37,7 +37,7 @@ static ssize_t atmaddress_show(struct device *cdev,
>
> spin_lock_irqsave(&adev->lock, flags);
> list_for_each_entry(aaddr, &adev->local, entry) {
> - count += scnprintf(buf + count, PAGE_SIZE - count,
> + count += sysfs_emit_at(buf, count,
> "%1phN.%2phN.%10phN.%6phN.%1phN\n",
> &aaddr->addr.sas_addr.prv[0],
> &aaddr->addr.sas_addr.prv[1],
Does the alignment of the following argument lines needs to be adapted?
> @@ -55,7 +55,7 @@ static ssize_t atmindex_show(struct device *cdev,
> {
> struct atm_dev *adev = to_atm_dev(cdev);
>
> - return scnprintf(buf, PAGE_SIZE, "%d\n", adev->number);
> + return sysfs_emit(buf, "%d\n", adev->number);
> }
>
> static ssize_t carrier_show(struct device *cdev,
> @@ -63,7 +63,7 @@ static ssize_t carrier_show(struct device *cdev,
> {
> struct atm_dev *adev = to_atm_dev(cdev);
>
> - return scnprintf(buf, PAGE_SIZE, "%d\n",
> + return sysfs_emit(buf, "%d\n",
> adev->signal == ATM_PHY_SIG_LOST ? 0 : 1);
Adapt alignment of following line?
Gerhard
next prev parent reply other threads:[~2025-03-18 19:23 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-17 7:29 xie.ludan
2025-03-18 18:58 ` Gerhard Engleder [this message]
2025-03-20 11:44 ` Simon Horman
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=46a0a5e2-2def-4ed1-ab54-40b6c8393239@engleder-embedded.com \
--to=gerhard@engleder-embedded.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=xie.ludan@zte.com.cn \
--cc=xu.xin16@zte.com.cn \
--cc=yang.yang29@zte.com.cn \
/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
all inboxes | Powered by JetHome®