From: Krishna Kurapati <krishna.kurapati@oss.qualcomm.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Al Viro <viro@zeniv.linux.org.uk>, Sam Day <me@samcday.com>,
Christian Brauner <brauner@kernel.org>,
Chen Ni <nichen@iscas.ac.cn>, Mateusz Guzik <mjguzik@gmail.com>,
Liang Jie <liangjie@lixiang.com>,
Ingo Rohloff <ingo.rohloff@lauterbach.com>,
Owen Gu <guhuinan@xiaomi.com>,
Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
Krishna Kurapati <krishna.kurapati@oss.qualcomm.com>
Subject: [PATCH 2/2] usb: gadget: f_sourcesink: Use sysfs_emit() in configfs show functions
Date: Sat, 31 Jan 2026 21:31:11 +0530 [thread overview]
Message-ID: <20260131160111.3161630-3-krishna.kurapati@oss.qualcomm.com> (raw)
In-Reply-To: <20260131160111.3161630-1-krishna.kurapati@oss.qualcomm.com>
Use sysfs_emit() instead of sprintf() in configfs attribute show functions.
sysfs_emit() is the recommended API for sysfs output as it provides buffer
overflow protection and proper formatting.
No functional changes.
Signed-off-by: Krishna Kurapati <krishna.kurapati@oss.qualcomm.com>
---
drivers/usb/gadget/function/f_sourcesink.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/drivers/usb/gadget/function/f_sourcesink.c b/drivers/usb/gadget/function/f_sourcesink.c
index 22104e9c6cab..e6ca80dba7c8 100644
--- a/drivers/usb/gadget/function/f_sourcesink.c
+++ b/drivers/usb/gadget/function/f_sourcesink.c
@@ -900,7 +900,7 @@ static ssize_t f_ss_opts_pattern_show(struct config_item *item, char *page)
int result;
mutex_lock(&opts->lock);
- result = sprintf(page, "%u\n", opts->pattern);
+ result = sysfs_emit(page, "%u\n", opts->pattern);
mutex_unlock(&opts->lock);
return result;
@@ -943,7 +943,7 @@ static ssize_t f_ss_opts_isoc_interval_show(struct config_item *item, char *page
int result;
mutex_lock(&opts->lock);
- result = sprintf(page, "%u\n", opts->isoc_interval);
+ result = sysfs_emit(page, "%u\n", opts->isoc_interval);
mutex_unlock(&opts->lock);
return result;
@@ -986,7 +986,7 @@ static ssize_t f_ss_opts_isoc_maxpacket_show(struct config_item *item, char *pag
int result;
mutex_lock(&opts->lock);
- result = sprintf(page, "%u\n", opts->isoc_maxpacket);
+ result = sysfs_emit(page, "%u\n", opts->isoc_maxpacket);
mutex_unlock(&opts->lock);
return result;
@@ -1029,7 +1029,7 @@ static ssize_t f_ss_opts_isoc_mult_show(struct config_item *item, char *page)
int result;
mutex_lock(&opts->lock);
- result = sprintf(page, "%u\n", opts->isoc_mult);
+ result = sysfs_emit(page, "%u\n", opts->isoc_mult);
mutex_unlock(&opts->lock);
return result;
@@ -1072,7 +1072,7 @@ static ssize_t f_ss_opts_isoc_maxburst_show(struct config_item *item, char *page
int result;
mutex_lock(&opts->lock);
- result = sprintf(page, "%u\n", opts->isoc_maxburst);
+ result = sysfs_emit(page, "%u\n", opts->isoc_maxburst);
mutex_unlock(&opts->lock);
return result;
@@ -1158,7 +1158,7 @@ static ssize_t f_ss_opts_bulk_buflen_show(struct config_item *item, char *page)
int result;
mutex_lock(&opts->lock);
- result = sprintf(page, "%u\n", opts->bulk_buflen);
+ result = sysfs_emit(page, "%u\n", opts->bulk_buflen);
mutex_unlock(&opts->lock);
return result;
@@ -1196,7 +1196,7 @@ static ssize_t f_ss_opts_bulk_qlen_show(struct config_item *item, char *page)
int result;
mutex_lock(&opts->lock);
- result = sprintf(page, "%u\n", opts->bulk_qlen);
+ result = sysfs_emit(page, "%u\n", opts->bulk_qlen);
mutex_unlock(&opts->lock);
return result;
@@ -1234,7 +1234,7 @@ static ssize_t f_ss_opts_iso_qlen_show(struct config_item *item, char *page)
int result;
mutex_lock(&opts->lock);
- result = sprintf(page, "%u\n", opts->iso_qlen);
+ result = sysfs_emit(page, "%u\n", opts->iso_qlen);
mutex_unlock(&opts->lock);
return result;
--
2.34.1
next prev parent reply other threads:[~2026-01-31 16:01 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-31 16:01 [PATCH 0/2] usb: gadget: Use sysfs_emit instead of sprintf Krishna Kurapati
2026-01-31 16:01 ` [PATCH 1/2] usb: gadget: f_fs: Use sysfs_emit() in configfs show function Krishna Kurapati
2026-01-31 16:01 ` Krishna Kurapati [this message]
2026-02-01 7:28 ` [PATCH 0/2] usb: gadget: Use sysfs_emit instead of sprintf Greg Kroah-Hartman
2026-02-01 10:31 ` Krishna Kurapati
2026-02-01 10:35 ` Greg Kroah-Hartman
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=20260131160111.3161630-3-krishna.kurapati@oss.qualcomm.com \
--to=krishna.kurapati@oss.qualcomm.com \
--cc=brauner@kernel.org \
--cc=christophe.jaillet@wanadoo.fr \
--cc=gregkh@linuxfoundation.org \
--cc=guhuinan@xiaomi.com \
--cc=ingo.rohloff@lauterbach.com \
--cc=liangjie@lixiang.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=me@samcday.com \
--cc=mjguzik@gmail.com \
--cc=nichen@iscas.ac.cn \
--cc=viro@zeniv.linux.org.uk \
/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