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 7/8] ASoC: DAPM: Replace sprintf() calls with sysfs_emit_at()
Date: Mon, 1 Aug 2022 19:01:07 +0200 [thread overview]
Message-ID: <20220801170108.26340-8-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 a new helper, sysfs_emit_at(), by passing the string offset.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
sound/soc/soc-dapm.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index b05231414c1d..73b8bd452ca7 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -2386,11 +2386,10 @@ int snd_soc_dapm_mixer_update_power(struct snd_soc_dapm_context *dapm,
EXPORT_SYMBOL_GPL(snd_soc_dapm_mixer_update_power);
static ssize_t dapm_widget_show_component(struct snd_soc_component *cmpnt,
- char *buf)
+ char *buf, int count)
{
struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(cmpnt);
struct snd_soc_dapm_widget *w;
- int count = 0;
char *state = "not set";
/* card won't be set for the dummy component, as a spot fix
@@ -2423,7 +2422,7 @@ static ssize_t dapm_widget_show_component(struct snd_soc_component *cmpnt,
case snd_soc_dapm_pinctrl:
case snd_soc_dapm_clock_supply:
if (w->name)
- count += sprintf(buf + count, "%s: %s\n",
+ count += sysfs_emit_at(buf, count, "%s: %s\n",
w->name, w->power ? "On":"Off");
break;
default:
@@ -2445,7 +2444,7 @@ static ssize_t dapm_widget_show_component(struct snd_soc_component *cmpnt,
state = "Off";
break;
}
- count += sprintf(buf + count, "PM State: %s\n", state);
+ count += sysfs_emit_at(buf, count, "PM State: %s\n", state);
return count;
}
@@ -2463,7 +2462,7 @@ static ssize_t dapm_widget_show(struct device *dev,
for_each_rtd_codec_dais(rtd, i, codec_dai) {
struct snd_soc_component *cmpnt = codec_dai->component;
- count += dapm_widget_show_component(cmpnt, buf + count);
+ count = dapm_widget_show_component(cmpnt, buf, count);
}
mutex_unlock(&rtd->card->dapm_mutex);
--
2.35.3
next prev parent reply other threads:[~2022-08-01 17:03 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 ` Takashi Iwai [this message]
2022-08-01 17:01 ` [PATCH 8/8] ASoC: omap: " Takashi Iwai
2022-08-01 18:54 ` 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-8-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox