ASoC: omap: Replace sprintf() with sysfs_emit()
authorTakashi Iwai <tiwai@suse.de>
Mon, 1 Aug 2022 17:01:08 +0000 (19:01 +0200)
committerMark Brown <broonie@kernel.org>
Mon, 15 Aug 2022 00:19:51 +0000 (01:19 +0100)
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>
sound/soc/ti/omap-mcbsp-st.c
sound/soc/ti/omap-mcbsp.c

index 7e8179c..8163f45 100644 (file)
@@ -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;
index c4ac1f3..0b377bb 100644 (file)
@@ -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;
 }