All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thorsten Blum <thorsten.blum@linux.dev>
To: Yoshinori Sato <ysato@users.sourceforge.jp>,
	Rich Felker <dalias@libc.org>,
	John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Cc: Thorsten Blum <thorsten.blum@linux.dev>,
	linux-sh@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 1/3] sh: dma-sysfs: use sysfs_emit{_at} in show functions
Date: Mon, 20 Apr 2026 17:09:58 +0200	[thread overview]
Message-ID: <20260420150958.17072-5-thorsten.blum@linux.dev> (raw)

Replace sprintf() with sysfs_emit() and sysfs_emit_at() in sysfs show
functions. sysfs_emit() and sysfs_emit_at() are preferred for formatting
sysfs output because they provide safer bounds checking.

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
 arch/sh/drivers/dma/dma-sysfs.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/arch/sh/drivers/dma/dma-sysfs.c b/arch/sh/drivers/dma/dma-sysfs.c
index 9f666280d80c..d4e16cfc7a12 100644
--- a/arch/sh/drivers/dma/dma-sysfs.c
+++ b/arch/sh/drivers/dma/dma-sysfs.c
@@ -13,6 +13,7 @@
 #include <linux/platform_device.h>
 #include <linux/err.h>
 #include <linux/string.h>
+#include <linux/sysfs.h>
 #include <asm/dma.h>
 
 static const struct bus_type dma_subsys = {
@@ -33,9 +34,9 @@ static ssize_t dma_show_devices(struct device *dev,
 		if (unlikely(!info) || !channel)
 			continue;
 
-		len += sprintf(buf + len, "%2d: %14s    %s\n",
-			       channel->chan, info->name,
-			       channel->dev_id);
+		len += sysfs_emit_at(buf, len, "%2d: %14s    %s\n",
+				     channel->chan, info->name,
+				     channel->dev_id);
 	}
 
 	return len;
@@ -65,7 +66,7 @@ static ssize_t dma_show_dev_id(struct device *dev,
 				struct device_attribute *attr, char *buf)
 {
 	struct dma_channel *channel = to_dma_channel(dev);
-	return sprintf(buf, "%s\n", channel->dev_id);
+	return sysfs_emit(buf, "%s\n", channel->dev_id);
 }
 
 static ssize_t dma_store_dev_id(struct device *dev,
@@ -98,7 +99,7 @@ static ssize_t dma_show_mode(struct device *dev,
 				struct device_attribute *attr, char *buf)
 {
 	struct dma_channel *channel = to_dma_channel(dev);
-	return sprintf(buf, "0x%08x\n", channel->mode);
+	return sysfs_emit(buf, "0x%08x\n", channel->mode);
 }
 
 static ssize_t dma_store_mode(struct device *dev,
@@ -117,7 +118,7 @@ static ssize_t dma_show_##field(struct device *dev,		\
 				struct device_attribute *attr, char *buf)\
 {									\
 	struct dma_channel *channel = to_dma_channel(dev);		\
-	return sprintf(buf, fmt, channel->field);			\
+	return sysfs_emit(buf, fmt, channel->field);			\
 }									\
 static DEVICE_ATTR(field, S_IRUGO, dma_show_##field, NULL);
 

             reply	other threads:[~2026-04-20 15:12 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-20 15:09 Thorsten Blum [this message]
2026-04-20 15:09 ` [PATCH 2/3] sh: dma-sysfs: use strscpy in dma_store_dev_id Thorsten Blum
2026-04-21  7:04   ` Geert Uytterhoeven
2026-04-20 15:10 ` [PATCH 3/3] sh: dma: drop redundant size argument from strscpy in request_dma Thorsten Blum
2026-04-21  7:05   ` Geert Uytterhoeven
2026-04-22  6:57 ` [PATCH 1/3] sh: dma-sysfs: use sysfs_emit{_at} in show functions Geert Uytterhoeven
  -- strict thread matches above, loose matches on Subject: below --
2026-05-18 17:10 Thorsten Blum

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=20260420150958.17072-5-thorsten.blum@linux.dev \
    --to=thorsten.blum@linux.dev \
    --cc=dalias@libc.org \
    --cc=glaubitz@physik.fu-berlin.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sh@vger.kernel.org \
    --cc=ysato@users.sourceforge.jp \
    /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.