[PATCH 0/2] usb: gadget: Use sysfs_emit instead of sprintf

Krishna Kurapati posted 2 patches 6 days, 16 hours ago
drivers/usb/gadget/function/f_fs.c         |  2 +-
drivers/usb/gadget/function/f_sourcesink.c | 16 ++++++++--------
2 files changed, 9 insertions(+), 9 deletions(-)
[PATCH 0/2] usb: gadget: Use sysfs_emit instead of sprintf
Posted by Krishna Kurapati 6 days, 16 hours ago
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.

Krishna Kurapati (2):
  usb: gadget: f_fs: Use sysfs_emit() in configfs show function
  usb: gadget: f_sourcesink: Use sysfs_emit() in configfs show functions

 drivers/usb/gadget/function/f_fs.c         |  2 +-
 drivers/usb/gadget/function/f_sourcesink.c | 16 ++++++++--------
 2 files changed, 9 insertions(+), 9 deletions(-)

-- 
2.34.1
Re: [PATCH 0/2] usb: gadget: Use sysfs_emit instead of sprintf
Posted by Greg Kroah-Hartman 6 days ago
On Sat, Jan 31, 2026 at 09:31:09PM +0530, Krishna Kurapati wrote:
> 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.

But this isn't sysfs, as you say, it's configfs, so why switch?  If
there is no need, the churn is not required.

thanks,

greg k-h
Re: [PATCH 0/2] usb: gadget: Use sysfs_emit instead of sprintf
Posted by Krishna Kurapati 5 days, 21 hours ago

On 2/1/2026 12:58 PM, Greg Kroah-Hartman wrote:
> On Sat, Jan 31, 2026 at 09:31:09PM +0530, Krishna Kurapati wrote:
>> 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.
> 
> But this isn't sysfs, as you say, it's configfs, so why switch?  If
> there is no need, the churn is not required.
> 

My bad. Its for configfs. I see sysfs_emit being used in configfs show 
functions in f_ncm/u_ether_configfs.h and hence tried to move to the 
same in f_fs and source sink.

Regards,
Krishna,
Re: [PATCH 0/2] usb: gadget: Use sysfs_emit instead of sprintf
Posted by Greg Kroah-Hartman 5 days, 21 hours ago
On Sun, Feb 01, 2026 at 04:01:46PM +0530, Krishna Kurapati wrote:
> 
> 
> On 2/1/2026 12:58 PM, Greg Kroah-Hartman wrote:
> > On Sat, Jan 31, 2026 at 09:31:09PM +0530, Krishna Kurapati wrote:
> > > 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.
> > 
> > But this isn't sysfs, as you say, it's configfs, so why switch?  If
> > there is no need, the churn is not required.
> > 
> 
> My bad. Its for configfs. I see sysfs_emit being used in configfs show
> functions in f_ncm/u_ether_configfs.h and hence tried to move to the same in
> f_fs and source sink.

You can use it, sure, but there's no need to convert existing code
unless there is a real reason it is required.  Just use it for new code
please.

thanks,

greg k-h