* [PATCH] iio: imu: inv_mpu6050: Replace scnprintf with sysfs_emit
@ 2025-07-01 11:39 Chelsy Ratnawat
2025-07-01 13:54 ` Andy Shevchenko
0 siblings, 1 reply; 2+ messages in thread
From: Chelsy Ratnawat @ 2025-07-01 11:39 UTC (permalink / raw)
To: jean-baptiste.maneyrol, jic23
Cc: dlechner, nuno.sa, andy, linux-iio, linux-kernel, Chelsy Ratnawat
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().
Signed-off-by: Chelsy Ratnawat <chelsyratnawat2001@gmail.com>
---
drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
index b8656c02354a..53a315fd0c34 100644
--- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
+++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
@@ -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,7 +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,
+ 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:
--
2.47.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] iio: imu: inv_mpu6050: Replace scnprintf with sysfs_emit
2025-07-01 11:39 [PATCH] iio: imu: inv_mpu6050: Replace scnprintf with sysfs_emit Chelsy Ratnawat
@ 2025-07-01 13:54 ` Andy Shevchenko
0 siblings, 0 replies; 2+ messages in thread
From: Andy Shevchenko @ 2025-07-01 13:54 UTC (permalink / raw)
To: Chelsy Ratnawat
Cc: jean-baptiste.maneyrol, jic23, dlechner, nuno.sa, andy, linux-iio,
linux-kernel
On Tue, Jul 01, 2025 at 04:39:45AM -0700, Chelsy Ratnawat wrote:
> 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().
...
> case ATTR_ACCL_MATRIX:
> m = st->plat_data.orientation;
>
> - return scnprintf(buf, PAGE_SIZE,
> + return sysfs_emit(buf,
> "%d, %d, %d; %d, %d, %d; %d, %d, %d\n",
Now this fits one line
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]);
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-07-01 13:54 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-01 11:39 [PATCH] iio: imu: inv_mpu6050: Replace scnprintf with sysfs_emit Chelsy Ratnawat
2025-07-01 13:54 ` Andy Shevchenko
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.