From: Thorsten Blum <thorsten.blum@linux.dev>
To: Parthiban Veerasooran <parthiban.veerasooran@microchip.com>,
Christian Gromm <christian.gromm@microchip.com>
Cc: Thorsten Blum <thorsten.blum@linux.dev>, linux-kernel@vger.kernel.org
Subject: [PATCH RESEND] most: configfs: use sysfs_emit in sysfs show functions
Date: Mon, 4 May 2026 20:16:00 +0200 [thread overview]
Message-ID: <20260504181559.143576-3-thorsten.blum@linux.dev> (raw)
Replace snprintf() with sysfs_emit() in sysfs show functions, which is
preferred for formatting sysfs output because it provides safer bounds
checking.
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
drivers/most/configfs.c | 28 ++++++++++++----------------
1 file changed, 12 insertions(+), 16 deletions(-)
diff --git a/drivers/most/configfs.c b/drivers/most/configfs.c
index 8f5158d95bc3..f2aae6874b64 100644
--- a/drivers/most/configfs.c
+++ b/drivers/most/configfs.c
@@ -8,6 +8,7 @@
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/module.h>
#include <linux/slab.h>
+#include <linux/sysfs.h>
#include <linux/init.h>
#include <linux/configfs.h>
#include <linux/most.h>
@@ -159,7 +160,7 @@ static ssize_t mdev_link_destroy_link_store(struct config_item *item,
static ssize_t mdev_link_direction_show(struct config_item *item, char *page)
{
- return snprintf(page, PAGE_SIZE, "%s\n", to_mdev_link(item)->direction);
+ return sysfs_emit(page, "%s\n", to_mdev_link(item)->direction);
}
static ssize_t mdev_link_direction_store(struct config_item *item,
@@ -177,7 +178,7 @@ static ssize_t mdev_link_direction_store(struct config_item *item,
static ssize_t mdev_link_datatype_show(struct config_item *item, char *page)
{
- return snprintf(page, PAGE_SIZE, "%s\n", to_mdev_link(item)->datatype);
+ return sysfs_emit(page, "%s\n", to_mdev_link(item)->datatype);
}
static ssize_t mdev_link_datatype_store(struct config_item *item,
@@ -196,7 +197,7 @@ static ssize_t mdev_link_datatype_store(struct config_item *item,
static ssize_t mdev_link_device_show(struct config_item *item, char *page)
{
- return snprintf(page, PAGE_SIZE, "%s\n", to_mdev_link(item)->device);
+ return sysfs_emit(page, "%s\n", to_mdev_link(item)->device);
}
static ssize_t mdev_link_device_store(struct config_item *item,
@@ -211,7 +212,7 @@ static ssize_t mdev_link_device_store(struct config_item *item,
static ssize_t mdev_link_channel_show(struct config_item *item, char *page)
{
- return snprintf(page, PAGE_SIZE, "%s\n", to_mdev_link(item)->channel);
+ return sysfs_emit(page, "%s\n", to_mdev_link(item)->channel);
}
static ssize_t mdev_link_channel_store(struct config_item *item,
@@ -226,7 +227,7 @@ static ssize_t mdev_link_channel_store(struct config_item *item,
static ssize_t mdev_link_comp_show(struct config_item *item, char *page)
{
- return snprintf(page, PAGE_SIZE, "%s\n", to_mdev_link(item)->comp);
+ return sysfs_emit(page, "%s\n", to_mdev_link(item)->comp);
}
static ssize_t mdev_link_comp_store(struct config_item *item,
@@ -241,8 +242,7 @@ static ssize_t mdev_link_comp_store(struct config_item *item,
static ssize_t mdev_link_comp_params_show(struct config_item *item, char *page)
{
- return snprintf(page, PAGE_SIZE, "%s\n",
- to_mdev_link(item)->comp_params);
+ return sysfs_emit(page, "%s\n", to_mdev_link(item)->comp_params);
}
static ssize_t mdev_link_comp_params_store(struct config_item *item,
@@ -257,8 +257,7 @@ static ssize_t mdev_link_comp_params_store(struct config_item *item,
static ssize_t mdev_link_num_buffers_show(struct config_item *item, char *page)
{
- return snprintf(page, PAGE_SIZE, "%d\n",
- to_mdev_link(item)->num_buffers);
+ return sysfs_emit(page, "%d\n", to_mdev_link(item)->num_buffers);
}
static ssize_t mdev_link_num_buffers_store(struct config_item *item,
@@ -275,8 +274,7 @@ static ssize_t mdev_link_num_buffers_store(struct config_item *item,
static ssize_t mdev_link_buffer_size_show(struct config_item *item, char *page)
{
- return snprintf(page, PAGE_SIZE, "%d\n",
- to_mdev_link(item)->buffer_size);
+ return sysfs_emit(page, "%d\n", to_mdev_link(item)->buffer_size);
}
static ssize_t mdev_link_buffer_size_store(struct config_item *item,
@@ -294,8 +292,7 @@ static ssize_t mdev_link_buffer_size_store(struct config_item *item,
static ssize_t mdev_link_subbuffer_size_show(struct config_item *item,
char *page)
{
- return snprintf(page, PAGE_SIZE, "%d\n",
- to_mdev_link(item)->subbuffer_size);
+ return sysfs_emit(page, "%d\n", to_mdev_link(item)->subbuffer_size);
}
static ssize_t mdev_link_subbuffer_size_store(struct config_item *item,
@@ -313,8 +310,7 @@ static ssize_t mdev_link_subbuffer_size_store(struct config_item *item,
static ssize_t mdev_link_packets_per_xact_show(struct config_item *item,
char *page)
{
- return snprintf(page, PAGE_SIZE, "%d\n",
- to_mdev_link(item)->packets_per_xact);
+ return sysfs_emit(page, "%d\n", to_mdev_link(item)->packets_per_xact);
}
static ssize_t mdev_link_packets_per_xact_store(struct config_item *item,
@@ -331,7 +327,7 @@ static ssize_t mdev_link_packets_per_xact_store(struct config_item *item,
static ssize_t mdev_link_dbr_size_show(struct config_item *item, char *page)
{
- return snprintf(page, PAGE_SIZE, "%d\n", to_mdev_link(item)->dbr_size);
+ return sysfs_emit(page, "%d\n", to_mdev_link(item)->dbr_size);
}
static ssize_t mdev_link_dbr_size_store(struct config_item *item,
next reply other threads:[~2026-05-04 18:16 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-04 18:16 Thorsten Blum [this message]
2026-06-04 15:26 ` [PATCH RESEND] most: configfs: use sysfs_emit in sysfs show functions Thorsten Blum
-- strict thread matches above, loose matches on Subject: below --
2026-03-09 22:32 [PATCH RESEND] most: configfs: Use " Thorsten Blum
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260504181559.143576-3-thorsten.blum@linux.dev \
--to=thorsten.blum@linux.dev \
--cc=christian.gromm@microchip.com \
--cc=linux-kernel@vger.kernel.org \
--cc=parthiban.veerasooran@microchip.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.