linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] iio: imu: inv_mpu6050: Replace scnprintf with sysfs_emit
@ 2025-07-01 15:47 Chelsy Ratnawat
  2025-07-01 16:19 ` Jean-Baptiste Maneyrol
  2025-07-01 19:19 ` Andy Shevchenko
  0 siblings, 2 replies; 4+ messages in thread
From: Chelsy Ratnawat @ 2025-07-01 15:47 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 | 5 ++---
 1 file changed, 2 insertions(+), 3 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..39eb516acc73 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,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;
-- 
2.47.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] iio: imu: inv_mpu6050: Replace scnprintf with sysfs_emit
  2025-07-01 15:47 [PATCH v2] iio: imu: inv_mpu6050: Replace scnprintf with sysfs_emit Chelsy Ratnawat
@ 2025-07-01 16:19 ` Jean-Baptiste Maneyrol
  2025-07-01 19:19 ` Andy Shevchenko
  1 sibling, 0 replies; 4+ messages in thread
From: Jean-Baptiste Maneyrol @ 2025-07-01 16:19 UTC (permalink / raw)
  To: Chelsy Ratnawat, jic23@kernel.org
  Cc: dlechner@baylibre.com, nuno.sa@analog.com, andy@kernel.org,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org

>
>________________________________________
>From: Chelsy Ratnawat <chelsyratnawat2001@gmail.com>
>Sent: Tuesday, July 1, 2025 17:47
>To: Jean-Baptiste Maneyrol <Jean-Baptiste.Maneyrol@tdk.com>; jic23@kernel.org <jic23@kernel.org>
>Cc: dlechner@baylibre.com <dlechner@baylibre.com>; nuno.sa@analog.com <nuno.sa@analog.com>; andy@kernel.org <andy@kernel.org>; linux-iio@vger.kernel.org <linux-iio@vger.kernel.org>; linux-kernel@vger.kernel.org <linux-kernel@vger.kernel.org>; Chelsy Ratnawat <chelsyratnawat2001@gmail.com>
>Subject: [PATCH v2] iio: imu: inv_mpu6050: Replace scnprintf with sysfs_emit
> 
>This Message Is From an External Sender
>This message came from outside your organization.
> 
>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 | 5 ++---
> 1 file changed, 2 insertions(+), 3 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..39eb516acc73 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,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;
>-- 
>2.47.1
>
>

Hello Chelsy,

thanks for the patch, it is all good for me.

Acked-by: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>

Thanks,
JB

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] iio: imu: inv_mpu6050: Replace scnprintf with sysfs_emit
  2025-07-01 15:47 [PATCH v2] iio: imu: inv_mpu6050: Replace scnprintf with sysfs_emit Chelsy Ratnawat
  2025-07-01 16:19 ` Jean-Baptiste Maneyrol
@ 2025-07-01 19:19 ` Andy Shevchenko
  2025-07-06  9:57   ` Jonathan Cameron
  1 sibling, 1 reply; 4+ messages in thread
From: Andy Shevchenko @ 2025-07-01 19:19 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 08:47:20AM -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().

...

> -		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.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] iio: imu: inv_mpu6050: Replace scnprintf with sysfs_emit
  2025-07-01 19:19 ` Andy Shevchenko
@ 2025-07-06  9:57   ` Jonathan Cameron
  0 siblings, 0 replies; 4+ messages in thread
From: Jonathan Cameron @ 2025-07-06  9:57 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Chelsy Ratnawat, jean-baptiste.maneyrol, dlechner, nuno.sa, andy,
	linux-iio, linux-kernel

On Tue, 1 Jul 2025 22:19:09 +0300
Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:

> On Tue, Jul 01, 2025 at 08:47:20AM -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().  
> 
> ...
> 
> > -		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.
> 
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
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

> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-07-06  9:58 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-01 15:47 [PATCH v2] iio: imu: inv_mpu6050: Replace scnprintf with sysfs_emit Chelsy Ratnawat
2025-07-01 16:19 ` Jean-Baptiste Maneyrol
2025-07-01 19:19 ` Andy Shevchenko
2025-07-06  9:57   ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).