staging: axis-fifo: Use sysfs_emit()
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Sun, 11 Feb 2024 12:27:10 +0000 (13:27 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 17 Feb 2024 16:29:05 +0000 (17:29 +0100)
sysfs_read() is anly called from _show() functions declared by
DEVICE_ATTR_RW().

Using sysfs_emit() is the preferred style and here, it saves a useless
copy and a temporary buffer in the stack.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Link: https://lore.kernel.org/r/588327734f374b5f5cb5c4d5725d884fdc83663e.1707654406.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/axis-fifo/axis-fifo.c

index 727b956aa23172169c05581530edfb1cf3723e26..c51818c56dd21741528a428fc7b6ada44ab26bb0 100644 (file)
@@ -165,14 +165,9 @@ static ssize_t sysfs_read(struct device *dev, char *buf,
 {
        struct axis_fifo *fifo = dev_get_drvdata(dev);
        unsigned int read_val;
-       unsigned int len;
-       char tmp[32];
 
        read_val = ioread32(fifo->base_addr + addr_offset);
-       len =  snprintf(tmp, sizeof(tmp), "0x%x\n", read_val);
-       memcpy(buf, tmp, len);
-
-       return len;
+       return sysfs_emit(buf, "0x%x\n", read_val);
 }
 
 static ssize_t isr_store(struct device *dev, struct device_attribute *attr,