From: Greg KH <gregkh@linuxfoundation.org>
To: Bhanu Seshu Kumar Valluri <bhanuseshukumar@gmail.com>
Cc: Michael Zaidman <michael.zaidman@gmail.com>,
Jiri Kosina <jikos@kernel.org>,
Benjamin Tissoires <bentiss@kernel.org>,
linux-i2c@vger.kernel.org, linux-input@vger.kernel.org,
linux-kernel@vger.kernel.org, skhan@linuxfoundation.org,
linux-kernel-mentees@lists.linux.dev
Subject: Re: [PATCH] HID: ft260: Use sysfs_emit to write formatted data to user buffer in sysfs show function.
Date: Tue, 23 Sep 2025 16:56:01 +0200 [thread overview]
Message-ID: <2025092316-pasta-parachute-737e@gregkh> (raw)
In-Reply-To: <20250923144926.307315-1-bhanuseshukumar@gmail.com>
On Tue, Sep 23, 2025 at 08:19:26PM +0530, Bhanu Seshu Kumar Valluri wrote:
> Inline with sysfs documentation, sysfs_emit is used in show function
> to write formatted data into user buffer. sysfs_emit is already PAGE_SIZE
> aware.
>
> Signed-off-by: Bhanu Seshu Kumar Valluri <bhanuseshukumar@gmail.com>
> ---
> Note: Patch is compile tested and verified with checkpatch.
>
> drivers/hid/hid-ft260.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/hid/hid-ft260.c b/drivers/hid/hid-ft260.c
> index 333341e80b0e..8677bea46bea 100644
> --- a/drivers/hid/hid-ft260.c
> +++ b/drivers/hid/hid-ft260.c
> @@ -826,7 +826,7 @@ static int ft260_byte_show(struct hid_device *hdev, int id, u8 *cfg, int len,
> if (ret < 0)
> return ret;
>
> - return scnprintf(buf, PAGE_SIZE, "%d\n", *field);
> + return sysfs_emit(buf, "%d\n", *field);
> }
>
> static int ft260_word_show(struct hid_device *hdev, int id, u8 *cfg, int len,
> @@ -838,7 +838,7 @@ static int ft260_word_show(struct hid_device *hdev, int id, u8 *cfg, int len,
> if (ret < 0)
> return ret;
>
> - return scnprintf(buf, PAGE_SIZE, "%d\n", le16_to_cpu(*field));
> + return sysfs_emit(buf, "%d\n", le16_to_cpu(*field));
There's no need to change existing users in the kernel for stuff like
this, only try to do this for new sysfs files. We've had too many bugs
where "simple" changes like this cause problems (recently in the USB
core for example.)
thanks,
greg k-h
next prev parent reply other threads:[~2025-09-23 14:56 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-23 14:49 [PATCH] HID: ft260: Use sysfs_emit to write formatted data to user buffer in sysfs show function Bhanu Seshu Kumar Valluri
2025-09-23 14:56 ` Greg KH [this message]
2025-09-23 14:58 ` bhanuseshukumar
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=2025092316-pasta-parachute-737e@gregkh \
--to=gregkh@linuxfoundation.org \
--cc=bentiss@kernel.org \
--cc=bhanuseshukumar@gmail.com \
--cc=jikos@kernel.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel-mentees@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=michael.zaidman@gmail.com \
--cc=skhan@linuxfoundation.org \
/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