Commit 69f7cbfb authored by Takashi Iwai's avatar Takashi Iwai Committed by Mark Brown

ASoC: DAPM: Replace sprintf() calls with sysfs_emit_at()

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: default avatarTakashi Iwai <tiwai@suse.de>
Link: https://lore.kernel.org/r/20220801170108.26340-8-tiwai@suse.deSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 628d0f72
...@@ -2386,11 +2386,10 @@ int snd_soc_dapm_mixer_update_power(struct snd_soc_dapm_context *dapm, ...@@ -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); EXPORT_SYMBOL_GPL(snd_soc_dapm_mixer_update_power);
static ssize_t dapm_widget_show_component(struct snd_soc_component *cmpnt, 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_context *dapm = snd_soc_component_get_dapm(cmpnt);
struct snd_soc_dapm_widget *w; struct snd_soc_dapm_widget *w;
int count = 0;
char *state = "not set"; char *state = "not set";
/* card won't be set for the dummy component, as a spot fix /* 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, ...@@ -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_pinctrl:
case snd_soc_dapm_clock_supply: case snd_soc_dapm_clock_supply:
if (w->name) 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"); w->name, w->power ? "On":"Off");
break; break;
default: default:
...@@ -2445,7 +2444,7 @@ static ssize_t dapm_widget_show_component(struct snd_soc_component *cmpnt, ...@@ -2445,7 +2444,7 @@ static ssize_t dapm_widget_show_component(struct snd_soc_component *cmpnt,
state = "Off"; state = "Off";
break; break;
} }
count += sprintf(buf + count, "PM State: %s\n", state); count += sysfs_emit_at(buf, count, "PM State: %s\n", state);
return count; return count;
} }
...@@ -2463,7 +2462,7 @@ static ssize_t dapm_widget_show(struct device *dev, ...@@ -2463,7 +2462,7 @@ static ssize_t dapm_widget_show(struct device *dev,
for_each_rtd_codec_dais(rtd, i, codec_dai) { for_each_rtd_codec_dais(rtd, i, codec_dai) {
struct snd_soc_component *cmpnt = codec_dai->component; 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); mutex_unlock(&rtd->card->dapm_mutex);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment