Commit a111ae4d authored by Takashi Iwai's avatar Takashi Iwai Committed by Mark Brown

ASoC: omap: Replace sprintf() with sysfs_emit()

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: default avatarTakashi Iwai <tiwai@suse.de>
Acked-by: default avatarPeter Ujfalusi <peter.ujfalusi@gmail.com>
Link: https://lore.kernel.org/r/20220801170108.26340-9-tiwai@suse.deSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 69f7cbfb
......@@ -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;
......
......@@ -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;
}
......
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