Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Link: https://lore.kernel.org/r/56e1588d-d53b-73e9-fdc8-7fe30bf91f11@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Heiner Kallweit and committed by
Mark Brown
04378630 07025cea

+1 -1
+1 -1
drivers/spi/spi.c
··· 143 143 unsigned long flags; \ 144 144 ssize_t len; \ 145 145 spin_lock_irqsave(&stat->lock, flags); \ 146 - len = sprintf(buf, format_string, stat->field); \ 146 + len = sysfs_emit(buf, format_string "\n", stat->field); \ 147 147 spin_unlock_irqrestore(&stat->lock, flags); \ 148 148 return len; \ 149 149 } \