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

Configure Feed

Select the types of activity you want to include in your feed.

iio: st_lsm6dsx: Replace scnprintf() with sysfs_emit()

Update the sysfs interface for sampling frequency and scale attributes.
Replace `scnprintf()` with `sysfs_emit_at()` which is PAGE_SIZE-aware
and recommended for use in sysfs.

Signed-off-by: Akshay Bansod <akbansd@gmail.com>
Reviewed-by: Andy Shevchenko <andy@kernel.org>
Link: https://patch.msgid.link/20250811165641.1214347-1-akbansd@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Akshay Bansod and committed by
Jonathan Cameron
f1c67514 12c9b09e

+7 -7
+7 -7
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
··· 2035 2035 2036 2036 odr_table = &sensor->hw->settings->odr_table[sensor->id]; 2037 2037 for (i = 0; i < odr_table->odr_len; i++) 2038 - len += scnprintf(buf + len, PAGE_SIZE - len, "%d.%03d ", 2039 - odr_table->odr_avl[i].milli_hz / 1000, 2040 - odr_table->odr_avl[i].milli_hz % 1000); 2041 - buf[len - 1] = '\n'; 2038 + len += sysfs_emit_at(buf, len, "%d.%03d%c", 2039 + odr_table->odr_avl[i].milli_hz / 1000, 2040 + odr_table->odr_avl[i].milli_hz % 1000, 2041 + (i == odr_table->odr_len - 1) ? '\n' : ' '); 2042 2042 2043 2043 return len; 2044 2044 } ··· 2054 2054 2055 2055 fs_table = &hw->settings->fs_table[sensor->id]; 2056 2056 for (i = 0; i < fs_table->fs_len; i++) 2057 - len += scnprintf(buf + len, PAGE_SIZE - len, "0.%09u ", 2058 - fs_table->fs_avl[i].gain); 2059 - buf[len - 1] = '\n'; 2057 + len += sysfs_emit_at(buf, len, "0.%09u%c", 2058 + fs_table->fs_avl[i].gain, 2059 + (i == fs_table->fs_len - 1) ? '\n' : ' '); 2060 2060 2061 2061 return len; 2062 2062 }