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: Takashi Iwai <tiwai@suse.de> Acked-by: Peter Ujfalusi <peter.ujfalusi@gmail.com> Link: https://lore.kernel.org/r/20220801170108.26340-9-tiwai@suse.de Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
69f7cbfb08
commit
a111ae4d7f
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user