From: Ruslan Valiyev <linuxoid@gmail.com>
To: Vaibhav Hiremath <hvaibhav.linux@gmail.com>,
Johan Hovold <johan@kernel.org>, Alex Elder <elder@kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: greybus-dev@lists.linaro.org, linux-staging@lists.linux.dev,
linux-kernel@vger.kernel.org, Ruslan Valiyev <linuxoid@gmail.com>
Subject: [PATCH] staging: greybus: arche: use sysfs_emit() instead of sprintf()
Date: Wed, 25 Feb 2026 21:29:55 +0000 [thread overview]
Message-ID: <20260225212955.57102-1-linuxoid@gmail.com> (raw)
Replace sprintf() with sysfs_emit() in state_show() sysfs attribute
callbacks in arche-platform.c and arche-apb-ctrl.c.
sysfs_emit() is preferred over sprintf() in sysfs show functions
because it is aware of the PAGE_SIZE buffer limit, preventing
potential buffer overflows. This addresses checkpatch warnings
about the use of sprintf() in sysfs show callbacks.
Signed-off-by: Ruslan Valiyev <linuxoid@gmail.com>
---
drivers/staging/greybus/arche-apb-ctrl.c | 10 +++++-----
drivers/staging/greybus/arche-platform.c | 10 +++++-----
2 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/drivers/staging/greybus/arche-apb-ctrl.c b/drivers/staging/greybus/arche-apb-ctrl.c
index 33f26a65f..19a6e59b6 100644
--- a/drivers/staging/greybus/arche-apb-ctrl.c
+++ b/drivers/staging/greybus/arche-apb-ctrl.c
@@ -300,16 +300,16 @@ static ssize_t state_show(struct device *dev,
switch (apb->state) {
case ARCHE_PLATFORM_STATE_OFF:
- return sprintf(buf, "off%s\n",
+ return sysfs_emit(buf, "off%s\n",
apb->init_disabled ? ",disabled" : "");
case ARCHE_PLATFORM_STATE_ACTIVE:
- return sprintf(buf, "active\n");
+ return sysfs_emit(buf, "active\n");
case ARCHE_PLATFORM_STATE_STANDBY:
- return sprintf(buf, "standby\n");
+ return sysfs_emit(buf, "standby\n");
case ARCHE_PLATFORM_STATE_FW_FLASHING:
- return sprintf(buf, "fw_flashing\n");
+ return sysfs_emit(buf, "fw_flashing\n");
default:
- return sprintf(buf, "unknown state\n");
+ return sysfs_emit(buf, "unknown state\n");
}
}
diff --git a/drivers/staging/greybus/arche-platform.c b/drivers/staging/greybus/arche-platform.c
index f669a7e2e..de5de59ea 100644
--- a/drivers/staging/greybus/arche-platform.c
+++ b/drivers/staging/greybus/arche-platform.c
@@ -374,15 +374,15 @@ static ssize_t state_show(struct device *dev,
switch (arche_pdata->state) {
case ARCHE_PLATFORM_STATE_OFF:
- return sprintf(buf, "off\n");
+ return sysfs_emit(buf, "off\n");
case ARCHE_PLATFORM_STATE_ACTIVE:
- return sprintf(buf, "active\n");
+ return sysfs_emit(buf, "active\n");
case ARCHE_PLATFORM_STATE_STANDBY:
- return sprintf(buf, "standby\n");
+ return sysfs_emit(buf, "standby\n");
case ARCHE_PLATFORM_STATE_FW_FLASHING:
- return sprintf(buf, "fw_flashing\n");
+ return sysfs_emit(buf, "fw_flashing\n");
default:
- return sprintf(buf, "unknown state\n");
+ return sysfs_emit(buf, "unknown state\n");
}
}
--
2.43.0
next reply other threads:[~2026-02-25 21:29 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-25 21:29 Ruslan Valiyev [this message]
2026-02-26 7:18 ` [PATCH] staging: greybus: arche: use sysfs_emit() instead of sprintf() Dan Carpenter
2026-02-26 7:48 ` [PATCH v2] " Ruslan Valiyev
2026-02-26 8:00 ` Dan Carpenter
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=20260225212955.57102-1-linuxoid@gmail.com \
--to=linuxoid@gmail.com \
--cc=elder@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=greybus-dev@lists.linaro.org \
--cc=hvaibhav.linux@gmail.com \
--cc=johan@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
/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.