Skip to contentSkip to conversation

RDMA/hfi1: use sysfs_emit() to instead of scnprintf()

PATCH Applied [email protected] 2 participants 3 messages Dec 7, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 RDMA/hfi1: use sysfs_emit() to instead of scnprintf()

From: ye xingchen <[email protected]>

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.

---
 drivers/infiniband/hw/hfi1/driver.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/hfi1/driver.c +1 -1
index 8e71bef9d982..bcc6bc0540f0 100644
@@ -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)
Signature · 1 line
2.25.1
#1 lore raw
Quoted 16 lines · On Wed, Dec 07, 2022 at 04:32:18PM +0800, [email protected] wrote:

From: ye xingchen <[email protected]>

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.

---
 drivers/infiniband/hw/hfi1/driver.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/hfi1/driver.c +0 -0
index 8e71bef9d982..bcc6bc0540f0 100644

drivers/infiniband/hw/hfi1/driver.c static int hfi1_caps_get(char *buffer, const struct kernel_param *kp) · line 115

Quoted 5 lines
drivers/infiniband/hw/hfi1/driver.c +1 -1
@@ -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

Quoted 5 lines
drivers/infiniband/hw/hfi1/driver.c +0 -0
 }
 
 struct pci_dev *get_pci_dev(struct rvt_dev_info *rdi)
Signature · 1 line
2.25.1
#2 lore raw
In reply to [email protected]
Quoted 8 lines · On Wed, 7 Dec 2022 16:32:18 +0800 (CST), [email protected] wrote:

From: ye xingchen <[email protected]>

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,

Signature · 1 line
Leon Romanovsky <[email protected]>