From: Maxwell Doose <m32285159@gmail.com>
To: alexandre.belloni@bootlin.com
Cc: Frank.Li@nxp.com, linux-i3c@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: [PATCH] i3c: master: replace sprintf() with sysfs_emit() and sysfs_emit_at()
Date: Mon, 20 Apr 2026 20:10:49 -0500 [thread overview]
Message-ID: <20260421011049.63899-1-m32285159@gmail.com> (raw)
This patch replaces sprintf() function calls with sysfs_emit() and
sysfs_emit_at() function calls where appropriate. While the current code
is functional, this patch will help harden the driver and help modernize
it. While at it, this patch also adds missing newlines at the end of
some sysfs_emit() (formerly sprintf()) calls.
Signed-off-by: Maxwell Doose <m32285159@gmail.com>
---
drivers/i3c/master.c | 26 +++++++++++++-------------
1 file changed, 13 insertions(+), 13 deletions(-)
diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c
index 9e6be49bebb2..c0d19eae06b9 100644
--- a/drivers/i3c/master.c
+++ b/drivers/i3c/master.c
@@ -174,7 +174,7 @@ static ssize_t bcr_show(struct device *dev,
i3c_bus_normaluse_lock(bus);
desc = dev_to_i3cdesc(dev);
- ret = sprintf(buf, "0x%02x\n", desc->info.bcr);
+ ret = sysfs_emit(buf, "0x%02x\n", desc->info.bcr);
i3c_bus_normaluse_unlock(bus);
return ret;
@@ -191,7 +191,7 @@ static ssize_t dcr_show(struct device *dev,
i3c_bus_normaluse_lock(bus);
desc = dev_to_i3cdesc(dev);
- ret = sprintf(buf, "0x%02x\n", desc->info.dcr);
+ ret = sysfs_emit(buf, "0x%02x\n", desc->info.dcr);
i3c_bus_normaluse_unlock(bus);
return ret;
@@ -208,7 +208,7 @@ static ssize_t pid_show(struct device *dev,
i3c_bus_normaluse_lock(bus);
desc = dev_to_i3cdesc(dev);
- ret = sprintf(buf, "%llx\n", desc->info.pid);
+ ret = sysfs_emit(buf, "%llx\n", desc->info.pid);
i3c_bus_normaluse_unlock(bus);
return ret;
@@ -225,7 +225,7 @@ static ssize_t dynamic_address_show(struct device *dev,
i3c_bus_normaluse_lock(bus);
desc = dev_to_i3cdesc(dev);
- ret = sprintf(buf, "%02x\n", desc->info.dyn_addr);
+ ret = sysfs_emit(buf, "%02x\n", desc->info.dyn_addr);
i3c_bus_normaluse_unlock(bus);
return ret;
@@ -256,7 +256,7 @@ static ssize_t hdrcap_show(struct device *dev,
if (!hdrcap_strings[mode])
continue;
- ret = sprintf(buf + offset, offset ? " %s" : "%s",
+ ret = sysfs_emit_at(buf, offset, offset ? " %s" : "%s",
hdrcap_strings[mode]);
if (ret < 0)
goto out;
@@ -264,7 +264,7 @@ static ssize_t hdrcap_show(struct device *dev,
offset += ret;
}
- ret = sprintf(buf + offset, "\n");
+ ret = sysfs_emit_at(buf, offset, "\n");
if (ret < 0)
goto out;
@@ -290,10 +290,10 @@ static ssize_t modalias_show(struct device *dev,
ext = I3C_PID_EXTRA_INFO(devinfo.pid);
if (I3C_PID_RND_LOWER_32BITS(devinfo.pid))
- return sprintf(buf, "i3c:dcr%02Xmanuf%04X", devinfo.dcr,
+ return sysfs_emit(buf, "i3c:dcr%02Xmanuf%04X\n", devinfo.dcr,
manuf);
- return sprintf(buf, "i3c:dcr%02Xmanuf%04Xpart%04Xext%04X",
+ return sysfs_emit(buf, "i3c:dcr%02Xmanuf%04Xpart%04Xext%04X\n",
devinfo.dcr, manuf, part, ext);
}
static DEVICE_ATTR_RO(modalias);
@@ -578,9 +578,9 @@ static ssize_t mode_show(struct device *dev,
if (i3cbus->mode < 0 ||
i3cbus->mode >= ARRAY_SIZE(i3c_bus_mode_strings) ||
!i3c_bus_mode_strings[i3cbus->mode])
- ret = sprintf(buf, "unknown\n");
+ ret = sysfs_emit(buf, "unknown\n");
else
- ret = sprintf(buf, "%s\n", i3c_bus_mode_strings[i3cbus->mode]);
+ ret = sysfs_emit(buf, "%s\n", i3c_bus_mode_strings[i3cbus->mode]);
i3c_bus_normaluse_unlock(i3cbus);
return ret;
@@ -595,7 +595,7 @@ static ssize_t current_master_show(struct device *dev,
ssize_t ret;
i3c_bus_normaluse_lock(i3cbus);
- ret = sprintf(buf, "%d-%llx\n", i3cbus->id,
+ ret = sysfs_emit(buf, "%d-%llx\n", i3cbus->id,
i3cbus->cur_master->info.pid);
i3c_bus_normaluse_unlock(i3cbus);
@@ -611,7 +611,7 @@ static ssize_t i3c_scl_frequency_show(struct device *dev,
ssize_t ret;
i3c_bus_normaluse_lock(i3cbus);
- ret = sprintf(buf, "%ld\n", i3cbus->scl_rate.i3c);
+ ret = sysfs_emit(buf, "%ld\n", i3cbus->scl_rate.i3c);
i3c_bus_normaluse_unlock(i3cbus);
return ret;
@@ -626,7 +626,7 @@ static ssize_t i2c_scl_frequency_show(struct device *dev,
ssize_t ret;
i3c_bus_normaluse_lock(i3cbus);
- ret = sprintf(buf, "%ld\n", i3cbus->scl_rate.i2c);
+ ret = sysfs_emit(buf, "%ld\n", i3cbus->scl_rate.i2c);
i3c_bus_normaluse_unlock(i3cbus);
return ret;
--
2.53.0
--
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c
next reply other threads:[~2026-04-21 1:10 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-21 1:10 Maxwell Doose [this message]
2026-04-21 2:48 ` [PATCH] i3c: master: replace sprintf() with sysfs_emit() and sysfs_emit_at() Frank Li
2026-04-21 3:47 ` Maxwell Doose
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=20260421011049.63899-1-m32285159@gmail.com \
--to=m32285159@gmail.com \
--cc=Frank.Li@nxp.com \
--cc=alexandre.belloni@bootlin.com \
--cc=linux-i3c@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox