iio: imu: inv_mpu6050: Replace scnprintf with sysfs_emit
Subsystems (2)
PATCH v2 1/1 iio: imu: inv_mpu6050: Replace scnprintf with sysfs_emit
Documentation/filesystems/sysfs.rst mentions that show() should only use sysfs_emit() or sysfs_emit_at() when formating the value to be returned to user space. So replace scnprintf() with sysfs_emit().
--- drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/iio/imu/inv_mpu6050/inv_mpu_core.c +2 -3
@@ -1382,7 +1382,7 @@ inv_fifo_rate_show(struct device *dev, struct device_attribute *attr, fifo_rate =INV_MPU6050_DIVIDER_TO_FIFO_RATE (st->chip_config.divider);mutex_unlock (&st->lock); -return scnprintf (buf,PAGE_SIZE ,"%u\n" , fifo_rate); +return sysfs_emit (buf,"%u\n" , fifo_rate); }/*
@@ -1409,8 +1409,7 @@ static ssize_t inv_attr_show(struct device *dev, struct device_attribute *attr,case ATTR_ACCL_MATRIX : m = st->plat_data.orientation; -return scnprintf (buf,PAGE_SIZE , -"%d, %d, %d; %d, %d, %d; %d, %d, %d\n" , +return sysfs_emit (buf,"%d, %d, %d; %d, %d, %d; %d, %d, %d\n" , m[0 ], m[1 ], m[2 ], m[3 ], m[4 ], m[5 ], m[6 ], m[7 ], m[8 ]);default :return -EINVAL ;
Signature · 1 line
2.47.1
Quoted 47 lines
________________________________________
From: Chelsy Ratnawat <[email protected]>
Sent: Tuesday, July 1, 2025 17:47
To: Jean-Baptiste Maneyrol <[email protected]>; [email protected] <[email protected]>
Cc: [email protected] <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>; Chelsy Ratnawat <[email protected]> Subject: [PATCH v2] iio: imu:inv_mpu6050: Replace scnprintf withsysfs_emit
This Message Is From an External Sender
This message came from outside your organization.Documentation/filesystems/sysfs.rstmentions thatshow()should only
usesysfs_emit()orsysfs_emit_at()when formating the value to be
returned to user space. So replacescnprintf()withsysfs_emit().Signed-off-by Chelsy Ratnawat <[email protected]>---
drivers/iio/imu/inv_mpu6050/inv_mpu_core.c| 5 ++---1 file changed, 2 insertions(+), 3 deletions(-)drivers/iio/imu/inv_mpu6050/inv_mpu_core.c +2
-3@@ -1382,7 +1382,7 @@ inv_fifo_rate_show(struct device *dev, struct device_attribute *attr, fifo_rate =INV_MPU6050_DIVIDER_TO_FIFO_RATE (st->chip_config.divider);mutex_unlock (&st->lock); -return scnprintf (buf,PAGE_SIZE ,"%u\n" , fifo_rate); +return sysfs_emit (buf,"%u\n" , fifo_rate); }/* @@ -1409,8 +1409,7 @@ static ssize_t inv_attr_show(struct device *dev, struct device_attribute *attr,case ATTR_ACCL_MATRIX : m = st->plat_data.orientation; -return scnprintf (buf,PAGE_SIZE , -"%d, %d, %d; %d, %d, %d; %d, %d, %d\n" , +return sysfs_emit (buf,"%d, %d, %d; %d, %d, %d; %d, %d, %d\n" , m[0 ], m[1 ], m[2 ], m[3 ], m[4 ], m[5 ], m[6 ], m[7 ], m[8 ]);default :return -EINVAL ;Signature · 1 line
2.47.1
Hello Chelsy,
thanks for the patch, it is all good for me.
Thanks,
JB
Quoted 3 lines · Chelsy Ratnawat
Documentation/filesystems/sysfs.rstmentions thatshow()should only usesysfs_emit()orsysfs_emit_at()when formating the value to be returned to user space. So replacescnprintf()withsysfs_emit().
...
drivers/iio/imu/inv_mpu6050/inv_mpu_core.c static ssize_t inv_attr_show(struct device *dev, struct device_attribute *attr, · line 1413
Quoted 4 lines
drivers/iio/imu/inv_mpu6050/inv_mpu_core.c +1
-2-return scnprintf (buf,PAGE_SIZE , -"%d, %d, %d; %d, %d, %d; %d, %d, %d\n" , +return sysfs_emit (buf,"%d, %d, %d; %d, %d, %d; %d, %d, %d\n" , m[0 ], m[1 ], m[2 ], m[3 ], m[4 ], m[5 ], m[6 ], m[7 ], m[8 ]);
Ideally second line should be reindented, but I won't be bothered by that right now.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 15 lines · On Tue, 1 Jul 2025 22:19:09 +0300 Andy Shevchenko…
Quoted 3 lines · Chelsy Ratnawat
Documentation/filesystems/sysfs.rstmentions thatshow()should only usesysfs_emit()orsysfs_emit_at()when formating the value to be returned to user space. So replacescnprintf()withsysfs_emit()....
drivers/iio/imu/inv_mpu6050/inv_mpu_core.c static ssize_t inv_attr_show(struct device *dev, struct device_attribute *attr, · line 1413
Quoted 4 lines
drivers/iio/imu/inv_mpu6050/inv_mpu_core.c +1
-2-return scnprintf (buf,PAGE_SIZE , -"%d, %d, %d; %d, %d, %d; %d, %d, %d\n" , +return sysfs_emit (buf,"%d, %d, %d; %d, %d, %d; %d, %d, %d\n" , m[0 ], m[1 ], m[2 ], m[3 ], m[4 ], m[5 ], m[6 ], m[7 ], m[8 ]);Ideally second line should be reindented, but I won't be bothered by that right now.
Quoted 1 line
Reviewed-by Andy Shevchenko <[email protected]>
Applied to the togreg branch of iio.git. I'll initially push that out as testing to get some early build testing from 0-day.
Thanks,
Jonathan