Linux-NVME Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] nvmet: replace sysfs_emit() with sprintf() in configfs show attrs
@ 2026-06-22  2:59 Guixin Liu
  2026-06-26  7:01 ` Christoph Hellwig
  0 siblings, 1 reply; 4+ messages in thread
From: Guixin Liu @ 2026-06-22  2:59 UTC (permalink / raw)
  To: Christoph Hellwig, Sagi Grimberg, Chaitanya Kulkarni; +Cc: linux-nvme

sysfs_emit() is designed for sysfs attributes and internally checks that
the buffer is page-aligned. Although configfs currently happens to use a
page-aligned buffer allocated via kzalloc(PAGE_SIZE), using sysfs_emit()
in configfs show callbacks is a semantic misuse of the API. Replace with
sprintf() to match the convention used by all other configfs show
functions in these files.

Signed-off-by: Guixin Liu <kanie@linux.alibaba.com>
---
 drivers/nvme/target/configfs.c | 6 +++---
 drivers/nvme/target/pci-epf.c  | 6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/nvme/target/configfs.c b/drivers/nvme/target/configfs.c
index b88f897f06e2..f4c77dd1f160 100644
--- a/drivers/nvme/target/configfs.c
+++ b/drivers/nvme/target/configfs.c
@@ -798,7 +798,7 @@ CONFIGFS_ATTR_WO(nvmet_ns_, revalidate_size);
 
 static ssize_t nvmet_ns_resv_enable_show(struct config_item *item, char *page)
 {
-	return sysfs_emit(page, "%d\n", to_nvmet_ns(item)->pr.enable);
+	return sprintf(page, "%d\n", to_nvmet_ns(item)->pr.enable);
 }
 
 static ssize_t nvmet_ns_resv_enable_store(struct config_item *item,
@@ -1534,7 +1534,7 @@ static ssize_t nvmet_subsys_attr_ieee_oui_show(struct config_item *item,
 {
 	struct nvmet_subsys *subsys = to_subsys(item);
 
-	return sysfs_emit(page, "0x%06x\n", subsys->ieee_oui);
+	return sprintf(page, "0x%06x\n", subsys->ieee_oui);
 }
 
 static ssize_t nvmet_subsys_attr_ieee_oui_store_locked(struct nvmet_subsys *subsys,
@@ -1582,7 +1582,7 @@ static ssize_t nvmet_subsys_attr_firmware_show(struct config_item *item,
 {
 	struct nvmet_subsys *subsys = to_subsys(item);
 
-	return sysfs_emit(page, "%s\n", subsys->firmware_rev);
+	return sprintf(page, "%s\n", subsys->firmware_rev);
 }
 
 static ssize_t nvmet_subsys_attr_firmware_store_locked(struct nvmet_subsys *subsys,
diff --git a/drivers/nvme/target/pci-epf.c b/drivers/nvme/target/pci-epf.c
index 4e9db96ebfec..547eeb0cae85 100644
--- a/drivers/nvme/target/pci-epf.c
+++ b/drivers/nvme/target/pci-epf.c
@@ -2482,7 +2482,7 @@ static ssize_t nvmet_pci_epf_portid_show(struct config_item *item, char *page)
 	struct config_group *group = to_config_group(item);
 	struct nvmet_pci_epf *nvme_epf = to_nvme_epf(group);
 
-	return sysfs_emit(page, "%u\n", le16_to_cpu(nvme_epf->portid));
+	return sprintf(page, "%u\n", le16_to_cpu(nvme_epf->portid));
 }
 
 static ssize_t nvmet_pci_epf_portid_store(struct config_item *item,
@@ -2515,7 +2515,7 @@ static ssize_t nvmet_pci_epf_subsysnqn_show(struct config_item *item,
 	struct config_group *group = to_config_group(item);
 	struct nvmet_pci_epf *nvme_epf = to_nvme_epf(group);
 
-	return sysfs_emit(page, "%s\n", nvme_epf->subsysnqn);
+	return sprintf(page, "%s\n", nvme_epf->subsysnqn);
 }
 
 static ssize_t nvmet_pci_epf_subsysnqn_store(struct config_item *item,
@@ -2543,7 +2543,7 @@ static ssize_t nvmet_pci_epf_mdts_kb_show(struct config_item *item, char *page)
 	struct config_group *group = to_config_group(item);
 	struct nvmet_pci_epf *nvme_epf = to_nvme_epf(group);
 
-	return sysfs_emit(page, "%u\n", nvme_epf->mdts_kb);
+	return sprintf(page, "%u\n", nvme_epf->mdts_kb);
 }
 
 static ssize_t nvmet_pci_epf_mdts_kb_store(struct config_item *item,
-- 
2.43.7



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

end of thread, other threads:[~2026-06-26  9:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-22  2:59 [PATCH] nvmet: replace sysfs_emit() with sprintf() in configfs show attrs Guixin Liu
2026-06-26  7:01 ` Christoph Hellwig
2026-06-26  7:53   ` Greg Kroah-Hartman
2026-06-26  9:31     ` Guixin Liu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox