linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] scsi: hisi_sas: use sysfs_emit() in v3 hw show() functions
@ 2025-07-12 14:28 Khaled Elnaggar
  2025-07-12 14:43 ` Greg KH
  0 siblings, 1 reply; 5+ messages in thread
From: Khaled Elnaggar @ 2025-07-12 14:28 UTC (permalink / raw)
  To: liyihang9, James.Bottomley, martin.petersen
  Cc: Khaled Elnaggar, linux-kernel-mentees, shuah, linux-scsi,
	linux-kernel

Replace scnprintf() with sysfs_emit() in several sysfs show()
callbacks in hisi_sas_v3_hw.c. This is recommended in
Documentation/filesystems/sysfs.rst for formatting values returned to
userspace.

Signed-off-by: Khaled Elnaggar <khaledelnaggarlinux@gmail.com>
---
 drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
index bc5d5356dd00..84bc02f7da27 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
@@ -2849,7 +2849,7 @@ static void wait_cmds_complete_timeout_v3_hw(struct hisi_hba *hisi_hba,
 static ssize_t intr_conv_v3_hw_show(struct device *dev,
 				    struct device_attribute *attr, char *buf)
 {
-	return scnprintf(buf, PAGE_SIZE, "%u\n", hisi_sas_intr_conv);
+	return sysfs_emit(buf, "%u\n", hisi_sas_intr_conv);
 }
 static DEVICE_ATTR_RO(intr_conv_v3_hw);
 
@@ -2881,8 +2881,7 @@ static ssize_t intr_coal_ticks_v3_hw_show(struct device *dev,
 	struct Scsi_Host *shost = class_to_shost(dev);
 	struct hisi_hba *hisi_hba = shost_priv(shost);
 
-	return scnprintf(buf, PAGE_SIZE, "%u\n",
-			 hisi_hba->intr_coal_ticks);
+	return sysfs_emit(buf, "%u\n", hisi_hba->intr_coal_ticks);
 }
 
 static ssize_t intr_coal_ticks_v3_hw_store(struct device *dev,
@@ -2920,8 +2919,7 @@ static ssize_t intr_coal_count_v3_hw_show(struct device *dev,
 	struct Scsi_Host *shost = class_to_shost(dev);
 	struct hisi_hba *hisi_hba = shost_priv(shost);
 
-	return scnprintf(buf, PAGE_SIZE, "%u\n",
-			 hisi_hba->intr_coal_count);
+	return sysfs_emit(buf, "%u\n", hisi_hba->intr_coal_count);
 }
 
 static ssize_t intr_coal_count_v3_hw_store(struct device *dev,
@@ -2959,8 +2957,7 @@ static ssize_t iopoll_q_cnt_v3_hw_show(struct device *dev,
 	struct Scsi_Host *shost = class_to_shost(dev);
 	struct hisi_hba *hisi_hba = shost_priv(shost);
 
-	return scnprintf(buf, PAGE_SIZE, "%u\n",
-			 hisi_hba->iopoll_q_cnt);
+	return sysfs_emit(buf, "%u\n", hisi_hba->iopoll_q_cnt);
 }
 static DEVICE_ATTR_RO(iopoll_q_cnt_v3_hw);
 
-- 
2.47.2


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] scsi: hisi_sas: use sysfs_emit() in v3 hw show() functions
  2025-07-12 14:28 [PATCH] scsi: hisi_sas: use sysfs_emit() in v3 hw show() functions Khaled Elnaggar
@ 2025-07-12 14:43 ` Greg KH
  2025-07-12 15:17   ` Khaled Elnaggar
  2025-07-13 17:58   ` Bart Van Assche
  0 siblings, 2 replies; 5+ messages in thread
From: Greg KH @ 2025-07-12 14:43 UTC (permalink / raw)
  To: Khaled Elnaggar
  Cc: liyihang9, James.Bottomley, martin.petersen, linux-kernel-mentees,
	shuah, linux-scsi, linux-kernel

On Sat, Jul 12, 2025 at 05:28:03PM +0300, Khaled Elnaggar wrote:
> Replace scnprintf() with sysfs_emit() in several sysfs show()
> callbacks in hisi_sas_v3_hw.c. This is recommended in
> Documentation/filesystems/sysfs.rst for formatting values returned to
> userspace.

For new users, yes, but what's wrong with these existing calls?  They
still work properly, so why change them?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] scsi: hisi_sas: use sysfs_emit() in v3 hw show() functions
  2025-07-12 14:43 ` Greg KH
@ 2025-07-12 15:17   ` Khaled Elnaggar
  2025-07-13 17:58   ` Bart Van Assche
  1 sibling, 0 replies; 5+ messages in thread
From: Khaled Elnaggar @ 2025-07-12 15:17 UTC (permalink / raw)
  To: Greg KH
  Cc: liyihang9, James.Bottomley, martin.petersen, linux-kernel-mentees,
	shuah, linux-scsi, linux-kernel

On 12/07/2025 5:43 pm, Greg KH wrote:
> On Sat, Jul 12, 2025 at 05:28:03PM +0300, Khaled Elnaggar wrote:
>> Replace scnprintf() with sysfs_emit() in several sysfs show()
>> callbacks in hisi_sas_v3_hw.c. This is recommended in
>> Documentation/filesystems/sysfs.rst for formatting values returned to
>> userspace.
> 
> For new users, yes, but what's wrong with these existing calls?  They
> still work properly, so why change them?
> 
> thanks,
> 
> greg k-h

Oh okay, got it. I was under the impression that older scnprintf()
calls should be actively replaced  with sysfs_emit(). But no need if
they just work, unless there is a bug or something.

Thanks for the clarification.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] scsi: hisi_sas: use sysfs_emit() in v3 hw show() functions
  2025-07-12 14:43 ` Greg KH
  2025-07-12 15:17   ` Khaled Elnaggar
@ 2025-07-13 17:58   ` Bart Van Assche
  2025-07-14  5:32     ` Greg KH
  1 sibling, 1 reply; 5+ messages in thread
From: Bart Van Assche @ 2025-07-13 17:58 UTC (permalink / raw)
  To: Greg KH, Khaled Elnaggar
  Cc: liyihang9, James.Bottomley, martin.petersen, linux-kernel-mentees,
	shuah, linux-scsi, linux-kernel

On 7/12/25 7:43 AM, Greg KH wrote:
> On Sat, Jul 12, 2025 at 05:28:03PM +0300, Khaled Elnaggar wrote:
>> Replace scnprintf() with sysfs_emit() in several sysfs show()
>> callbacks in hisi_sas_v3_hw.c. This is recommended in
>> Documentation/filesystems/sysfs.rst for formatting values returned to
>> userspace.
> 
> For new users, yes, but what's wrong with these existing calls?  They
> still work properly, so why change them?

How about making this explicit in Documentation/filesystems/sysfs.rst?
I think that would help to stop the steady stream of patches for
converting existing sysfs show callbacks to sysfs_emit()/sysfs_emit_at().

Thanks,

Bart.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] scsi: hisi_sas: use sysfs_emit() in v3 hw show() functions
  2025-07-13 17:58   ` Bart Van Assche
@ 2025-07-14  5:32     ` Greg KH
  0 siblings, 0 replies; 5+ messages in thread
From: Greg KH @ 2025-07-14  5:32 UTC (permalink / raw)
  To: Bart Van Assche
  Cc: Khaled Elnaggar, liyihang9, James.Bottomley, martin.petersen,
	linux-kernel-mentees, shuah, linux-scsi, linux-kernel

On Sun, Jul 13, 2025 at 10:58:54AM -0700, Bart Van Assche wrote:
> On 7/12/25 7:43 AM, Greg KH wrote:
> > On Sat, Jul 12, 2025 at 05:28:03PM +0300, Khaled Elnaggar wrote:
> > > Replace scnprintf() with sysfs_emit() in several sysfs show()
> > > callbacks in hisi_sas_v3_hw.c. This is recommended in
> > > Documentation/filesystems/sysfs.rst for formatting values returned to
> > > userspace.
> > 
> > For new users, yes, but what's wrong with these existing calls?  They
> > still work properly, so why change them?
> 
> How about making this explicit in Documentation/filesystems/sysfs.rst?
> I think that would help to stop the steady stream of patches for
> converting existing sysfs show callbacks to sysfs_emit()/sysfs_emit_at().

Patches gladly accepted :)

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-07-14  5:32 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-12 14:28 [PATCH] scsi: hisi_sas: use sysfs_emit() in v3 hw show() functions Khaled Elnaggar
2025-07-12 14:43 ` Greg KH
2025-07-12 15:17   ` Khaled Elnaggar
2025-07-13 17:58   ` Bart Van Assche
2025-07-14  5:32     ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).