linux-rdma.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] RDMA/hfi1: use sysfs_emit() to instead of scnprintf()
@ 2022-12-07  8:32 ye.xingchen
  2022-12-07  9:08 ` Leon Romanovsky
  2022-12-07  9:08 ` Leon Romanovsky
  0 siblings, 2 replies; 3+ messages in thread
From: ye.xingchen @ 2022-12-07  8:32 UTC (permalink / raw)
  To: leon; +Cc: dennis.dalessandro, jgg, linux-rdma, linux-kernel

From: ye xingchen <ye.xingchen@zte.com.cn>

Follow the advice of the Documentation/filesystems/sysfs.rst and show()
should only use sysfs_emit() or sysfs_emit_at() when formatting the
value to be returned to user space.

Signed-off-by: ye xingchen <ye.xingchen@zte.com.cn>
---
 drivers/infiniband/hw/hfi1/driver.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/infiniband/hw/hfi1/driver.c b/drivers/infiniband/hw/hfi1/driver.c
index 8e71bef9d982..bcc6bc0540f0 100644
--- a/drivers/infiniband/hw/hfi1/driver.c
+++ b/drivers/infiniband/hw/hfi1/driver.c
@@ -112,7 +112,7 @@ static int hfi1_caps_get(char *buffer, const struct kernel_param *kp)
 	cap_mask &= ~HFI1_CAP_LOCKED_SMASK;
 	cap_mask |= ((cap_mask & HFI1_CAP_K2U) << HFI1_CAP_USER_SHIFT);

-	return scnprintf(buffer, PAGE_SIZE, "0x%lx", cap_mask);
+	return sysfs_emit(buffer, "0x%lx\n", cap_mask);
 }

 struct pci_dev *get_pci_dev(struct rvt_dev_info *rdi)
-- 
2.25.1

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

* Re: [PATCH] RDMA/hfi1: use sysfs_emit() to instead of scnprintf()
  2022-12-07  8:32 [PATCH] RDMA/hfi1: use sysfs_emit() to instead of scnprintf() ye.xingchen
@ 2022-12-07  9:08 ` Leon Romanovsky
  2022-12-07  9:08 ` Leon Romanovsky
  1 sibling, 0 replies; 3+ messages in thread
From: Leon Romanovsky @ 2022-12-07  9:08 UTC (permalink / raw)
  To: ye.xingchen, dennis.dalessandro; +Cc: jgg, linux-rdma, linux-kernel

On Wed, Dec 07, 2022 at 04:32:18PM +0800, ye.xingchen@zte.com.cn wrote:
> From: ye xingchen <ye.xingchen@zte.com.cn>
> 
> Follow the advice of the Documentation/filesystems/sysfs.rst and show()
> should only use sysfs_emit() or sysfs_emit_at() when formatting the
> value to be returned to user space.
> 
> Signed-off-by: ye xingchen <ye.xingchen@zte.com.cn>
> ---
>  drivers/infiniband/hw/hfi1/driver.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/infiniband/hw/hfi1/driver.c b/drivers/infiniband/hw/hfi1/driver.c
> index 8e71bef9d982..bcc6bc0540f0 100644
> --- a/drivers/infiniband/hw/hfi1/driver.c
> +++ b/drivers/infiniband/hw/hfi1/driver.c
> @@ -112,7 +112,7 @@ static int hfi1_caps_get(char *buffer, const struct kernel_param *kp)
>  	cap_mask &= ~HFI1_CAP_LOCKED_SMASK;
>  	cap_mask |= ((cap_mask & HFI1_CAP_K2U) << HFI1_CAP_USER_SHIFT);
> 
> -	return scnprintf(buffer, PAGE_SIZE, "0x%lx", cap_mask);
> +	return sysfs_emit(buffer, "0x%lx\n", cap_mask);

Dennis,

Please pay attention what "\n" doesn't exist in original line.
I applied the patch as I think it is the same, but if you see that it
is not, please say so, so we will drop/adapt it before merge window.

Thanks

>  }
> 
>  struct pci_dev *get_pci_dev(struct rvt_dev_info *rdi)
> -- 
> 2.25.1

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

* Re: [PATCH] RDMA/hfi1: use sysfs_emit() to instead of scnprintf()
  2022-12-07  8:32 [PATCH] RDMA/hfi1: use sysfs_emit() to instead of scnprintf() ye.xingchen
  2022-12-07  9:08 ` Leon Romanovsky
@ 2022-12-07  9:08 ` Leon Romanovsky
  1 sibling, 0 replies; 3+ messages in thread
From: Leon Romanovsky @ 2022-12-07  9:08 UTC (permalink / raw)
  To: ye.xingchen; +Cc: linux-kernel, linux-rdma, jgg, dennis.dalessandro

On Wed, 7 Dec 2022 16:32:18 +0800 (CST), ye.xingchen@zte.com.cn wrote:
> From: ye xingchen <ye.xingchen@zte.com.cn>
> 
> Follow the advice of the Documentation/filesystems/sysfs.rst and show()
> should only use sysfs_emit() or sysfs_emit_at() when formatting the
> value to be returned to user space.
> 
> 
> [...]

Applied, thanks!

[1/1] RDMA/hfi1: use sysfs_emit() to instead of scnprintf()
      https://git.kernel.org/rdma/rdma/c/d074f0aebde564

Best regards,
-- 
Leon Romanovsky <leon@kernel.org>

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

end of thread, other threads:[~2022-12-07  9:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-07  8:32 [PATCH] RDMA/hfi1: use sysfs_emit() to instead of scnprintf() ye.xingchen
2022-12-07  9:08 ` Leon Romanovsky
2022-12-07  9:08 ` Leon Romanovsky

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).