Skip to contentSkip to conversation

gpu: drm: Replace scnprintf() with sysfs_emit_at()

PATCH New Brigham Campbell 1 participant 1 message Jun 24, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gpu: drm: Replace scnprintf() with sysfs_emit_at()

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.

---

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(-)
drivers/gpu/drm/drm_sysfs.c +1 -2
index 60c1f26edb6f..66d1fc804c84 100644
@@ -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);
 
Signature · 1 line
2.50.0