From: David Baum <davidbaum461@gmail.com>
To: alex.deucher@amd.com, christian.koenig@amd.com
Cc: lijo.lazar@amd.com, airlied@gmail.com, simona@ffwll.ch,
amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
David Baum <davidbaum461@gmail.com>
Subject: [PATCH] drm/amdgpu: switch XGMI sysfs show helpers to sysfs_emit_at()
Date: Thu, 12 Mar 2026 20:52:26 -0500 [thread overview]
Message-ID: <20260313015226.39727-1-davidbaum461@gmail.com> (raw)
The XGMI sysfs show helpers amdgpu_xgmi_show_num_hops() and
amdgpu_xgmi_show_num_links() currently populate the output buffer with
sprintf() and then call sysfs_emit(buf, "%s\n", buf) to append the final
newline.
Convert both helpers to use sysfs_emit_at() while tracking the current
offset. This keeps buffer construction in the sysfs helpers, avoids
feeding the output buffer back into the final formatted write, and
matches the style already used by
amdgpu_xgmi_show_connected_port_num().
Signed-off-by: David Baum <davidbaum461@gmail.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c
index 11e56df1d91b..13fc7247fe23 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c
@@ -469,12 +469,12 @@ static ssize_t amdgpu_xgmi_show_num_hops(struct device *dev,
struct drm_device *ddev = dev_get_drvdata(dev);
struct amdgpu_device *adev = drm_to_adev(ddev);
struct psp_xgmi_topology_info *top = &adev->psp.xgmi_context.top_info;
- int i;
+ int i, offset = 0;
for (i = 0; i < top->num_nodes; i++)
- sprintf(buf + 3 * i, "%02x ", top->nodes[i].num_hops);
+ offset += sysfs_emit_at(buf, offset, "%02x ", top->nodes[i].num_hops);
- return sysfs_emit(buf, "%s\n", buf);
+ return offset + sysfs_emit_at(buf, offset, "\n");
}
static ssize_t amdgpu_xgmi_show_num_links(struct device *dev,
@@ -484,12 +484,12 @@ static ssize_t amdgpu_xgmi_show_num_links(struct device *dev,
struct drm_device *ddev = dev_get_drvdata(dev);
struct amdgpu_device *adev = drm_to_adev(ddev);
struct psp_xgmi_topology_info *top = &adev->psp.xgmi_context.top_info;
- int i;
+ int i, offset = 0;
for (i = 0; i < top->num_nodes; i++)
- sprintf(buf + 3 * i, "%02x ", top->nodes[i].num_links);
+ offset += sysfs_emit_at(buf, offset, "%02x ", top->nodes[i].num_links);
- return sysfs_emit(buf, "%s\n", buf);
+ return offset + sysfs_emit_at(buf, offset, "\n");
}
static ssize_t amdgpu_xgmi_show_connected_port_num(struct device *dev,
--
2.50.1 (Apple Git-155)
next reply other threads:[~2026-03-13 8:25 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-13 1:52 David Baum [this message]
2026-03-13 14:04 ` [PATCH] drm/amdgpu: switch XGMI sysfs show helpers to sysfs_emit_at() Alex Deucher
2026-03-13 21:16 ` Claude review: " Claude Code Review Bot
2026-03-13 21:16 ` Claude Code Review Bot
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=20260313015226.39727-1-davidbaum461@gmail.com \
--to=davidbaum461@gmail.com \
--cc=airlied@gmail.com \
--cc=alex.deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=christian.koenig@amd.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=lijo.lazar@amd.com \
--cc=simona@ffwll.ch \
/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