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

iio: chemical: scd30_core: use sysfs_emit() to instead of scnprintf()

Follow the advice of the Documentation/filesystems/sysfs.rst and show()
should only use sysfs_emit() or sysfs_emit_at() when formatting the
value to be returned to user space.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20230113141117.23353-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Andy Shevchenko and committed by
Jonathan Cameron
ebda75fb bfcae956

+3 -3
+3 -3
drivers/iio/chemical/scd30_core.c
··· 354 354 ssize_t len = 0; 355 355 356 356 do { 357 - len += scnprintf(buf + len, PAGE_SIZE - len, "0.%09u ", 1000000000 / i); 357 + len += sysfs_emit_at(buf, len, "0.%09u ", 1000000000 / i); 358 358 /* 359 359 * Not all values fit PAGE_SIZE buffer hence print every 6th 360 360 * (each frequency differs by 6s in time domain from the ··· 380 380 ret = scd30_command_read(state, CMD_ASC, &val); 381 381 mutex_unlock(&state->lock); 382 382 383 - return ret ?: sprintf(buf, "%d\n", val); 383 + return ret ?: sysfs_emit(buf, "%d\n", val); 384 384 } 385 385 386 386 static ssize_t calibration_auto_enable_store(struct device *dev, struct device_attribute *attr, ··· 414 414 ret = scd30_command_read(state, CMD_FRC, &val); 415 415 mutex_unlock(&state->lock); 416 416 417 - return ret ?: sprintf(buf, "%d\n", val); 417 + return ret ?: sysfs_emit(buf, "%d\n", val); 418 418 } 419 419 420 420 static ssize_t calibration_forced_value_store(struct device *dev, struct device_attribute *attr,