[PATCH] gpu: drm: Replace scnprintf() with sysfs_emit_at()

From: Brigham Campbell
Date: Tue Jun 24 2025 - 02:27:43 EST


Replace scnprintf() with sysfs_emit_at() in drivers/gpu/drm/drm_sysfs.c.
Per kernel documentation, show() should only use sysfs_emit() or
sysfs_emit_at() when formatting the value to be returned to user space.

Signed-off-by: Brigham Campbell <me@xxxxxxxxxxxxxxxxxxx>
---

I tested this patch with a device that outputs one specific resolution,
or "mode" and with a dummy device which has no output modes. I'd
appreciate Tested-by tags from anyone who can confirm that multi-mode
graphics adapters work as expected too.

drivers/gpu/drm/drm_sysfs.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c
index 60c1f26edb6f..66d1fc804c84 100644
--- a/drivers/gpu/drm/drm_sysfs.c
+++ b/drivers/gpu/drm/drm_sysfs.c
@@ -283,8 +283,7 @@ static ssize_t modes_show(struct device *device,

mutex_lock(&connector->dev->mode_config.mutex);
list_for_each_entry(mode, &connector->modes, head) {
- written += scnprintf(buf + written, PAGE_SIZE - written, "%s\n",
- mode->name);
+ written += sysfs_emit_at(buf, written, "%s\n", mode->name);
}
mutex_unlock(&connector->dev->mode_config.mutex);

--
2.50.0