All of lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: Mark Brown <broonie@kernel.org>
Cc: alsa-devel@alsa-project.org,
	Lucas Tanure <tanureal@opensource.cirrus.com>,
	Cezary Rojewski <cezary.rojewski@intel.com>,
	Ranjani Sridharan <ranjani.sridharan@linux.intel.com>,
	Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>,
	Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Subject: [PATCH 8/8] ASoC: omap: Replace sprintf() with sysfs_emit()
Date: Mon,  1 Aug 2022 19:01:08 +0200	[thread overview]
Message-ID: <20220801170108.26340-9-tiwai@suse.de> (raw)
In-Reply-To: <20220801170108.26340-1-tiwai@suse.de>

For sysfs outputs, it's safer to use a new helper, sysfs_emit(),
instead of the raw sprintf() & co.  This patch replaces the open code
with new helpers, sysfs_emit() and sysfs_emit_at(), with the proper
string offset.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/soc/ti/omap-mcbsp-st.c | 6 +++---
 sound/soc/ti/omap-mcbsp.c    | 8 ++++----
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/sound/soc/ti/omap-mcbsp-st.c b/sound/soc/ti/omap-mcbsp-st.c
index 7e8179cae92e..8163f453bf36 100644
--- a/sound/soc/ti/omap-mcbsp-st.c
+++ b/sound/soc/ti/omap-mcbsp-st.c
@@ -244,10 +244,10 @@ static ssize_t st_taps_show(struct device *dev,
 
 	spin_lock_irq(&mcbsp->lock);
 	for (i = 0; i < st_data->nr_taps; i++)
-		status += sprintf(&buf[status], (i ? ", %d" : "%d"),
-				  st_data->taps[i]);
+		status += sysfs_emit_at(buf, status, (i ? ", %d" : "%d"),
+					st_data->taps[i]);
 	if (i)
-		status += sprintf(&buf[status], "\n");
+		status += sysfs_emit_at(buf, status, "\n");
 	spin_unlock_irq(&mcbsp->lock);
 
 	return status;
diff --git a/sound/soc/ti/omap-mcbsp.c b/sound/soc/ti/omap-mcbsp.c
index c4ac1f30b9fe..0b377bb7737f 100644
--- a/sound/soc/ti/omap-mcbsp.c
+++ b/sound/soc/ti/omap-mcbsp.c
@@ -517,7 +517,7 @@ static ssize_t prop##_show(struct device *dev,				\
 {									\
 	struct omap_mcbsp *mcbsp = dev_get_drvdata(dev);		\
 									\
-	return sprintf(buf, "%u\n", mcbsp->prop);			\
+	return sysfs_emit(buf, "%u\n", mcbsp->prop);			\
 }									\
 									\
 static ssize_t prop##_store(struct device *dev,				\
@@ -560,11 +560,11 @@ static ssize_t dma_op_mode_show(struct device *dev,
 
 	for (s = &dma_op_modes[i]; i < ARRAY_SIZE(dma_op_modes); s++, i++) {
 		if (dma_op_mode == i)
-			len += sprintf(buf + len, "[%s] ", *s);
+			len += sysfs_emit_at(buf, len, "[%s] ", *s);
 		else
-			len += sprintf(buf + len, "%s ", *s);
+			len += sysfs_emit_at(buf, len, "%s ", *s);
 	}
-	len += sprintf(buf + len, "\n");
+	len += sysfs_emit_at(buf, len, "\n");
 
 	return len;
 }
-- 
2.35.3


  parent reply	other threads:[~2022-08-01 17:04 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-01 17:01 [PATCH 0/8] ASoC: Replace sprintf() with sysfs_emit() Takashi Iwai
2022-08-01 17:01 ` [PATCH 1/8] ASoC: cs43130: Replace scnprintf() " Takashi Iwai
2022-08-01 17:01 ` [PATCH 2/8] ASoC: tlv320aic26: Replace sprintf() " Takashi Iwai
2022-08-01 17:01 ` [PATCH 3/8] ASoC: Intel: sst: " Takashi Iwai
2022-08-01 17:01 ` [PATCH 4/8] ASoC: Intel: catpt: " Takashi Iwai
2022-08-02 10:17   ` Cezary Rojewski
2022-08-01 17:01 ` [PATCH 5/8] ASoC: Intel: skylake: " Takashi Iwai
2022-08-02 10:17   ` Cezary Rojewski
2022-08-01 17:01 ` [PATCH 6/8] ASoC: core: " Takashi Iwai
2022-08-01 17:01 ` [PATCH 7/8] ASoC: DAPM: Replace sprintf() calls with sysfs_emit_at() Takashi Iwai
2022-08-01 17:01 ` Takashi Iwai [this message]
2022-08-01 18:54   ` [PATCH 8/8] ASoC: omap: Replace sprintf() with sysfs_emit() Péter Ujfalusi
2022-08-15 16:23 ` [PATCH 0/8] ASoC: " Mark Brown

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=20220801170108.26340-9-tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=cezary.rojewski@intel.com \
    --cc=peter.ujfalusi@linux.intel.com \
    --cc=pierre-louis.bossart@linux.intel.com \
    --cc=ranjani.sridharan@linux.intel.com \
    --cc=tanureal@opensource.cirrus.com \
    /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.