Skip to contentSkip to conversation

spi: use sysfs_emit() for printing statistics and add trailing newline

PATCH Superseded Heiner Kallweit 1 participant 1 message Feb 18, 2022 SPI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 spi: use sysfs_emit() for printing statistics and add trailing newline

Use dedicated function sysfs_emit() that does some extra checking, e.g. to ensure that no more than PAGESIZE bytes are written. In addition add a trailing newline to the output, that makes it better readable from the console.

---
 drivers/spi/spi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/spi/spi.c +1 -1
index c98c55f44..fae290a33 100644
@@ -144,7 +144,7 @@ static ssize_t spi_statistics_##name##_show(struct spi_statistics *stat, \
 	unsigned long flags;						\
 	ssize_t len;							\
 	spin_lock_irqsave(&stat->lock, flags);				\
-	len = sprintf(buf, format_string, stat->field);			\
+	len = sysfs_emit(buf, format_string "\n", stat->field);		\
 	spin_unlock_irqrestore(&stat->lock, flags);			\
 	return len;							\
 }									\
Signature · 1 line
2.35.1