mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] platform/mellanox: mlxreg-io: use sysfs_emit() instead of sprintf()
@ 2025-01-16  8:11 Ai Chao
  2025-01-16  9:03 ` Vadim Pasternak
  2025-01-17 17:01 ` Ilpo Järvinen
  0 siblings, 2 replies; 3+ messages in thread
From: Ai Chao @ 2025-01-16  8:11 UTC (permalink / raw)
  To: hdegoede, ilpo.jarvinen, vadimp, platform-driver-x86, linux-kernel
  Cc: Ai Chao

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

Signed-off-by: Ai Chao <aichao@kylinos.cn>
---
 drivers/platform/mellanox/mlxreg-io.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/platform/mellanox/mlxreg-io.c b/drivers/platform/mellanox/mlxreg-io.c
index 595276206baf..97fefe6c38d1 100644
--- a/drivers/platform/mellanox/mlxreg-io.c
+++ b/drivers/platform/mellanox/mlxreg-io.c
@@ -126,7 +126,7 @@ mlxreg_io_attr_show(struct device *dev, struct device_attribute *attr,
 
 	mutex_unlock(&priv->io_lock);
 
-	return sprintf(buf, "%u\n", regval);
+	return sysfs_emit(buf, "%u\n", regval);
 
 access_error:
 	mutex_unlock(&priv->io_lock);
-- 
2.47.1


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

* RE: [PATCH] platform/mellanox: mlxreg-io: use sysfs_emit() instead of sprintf()
  2025-01-16  8:11 [PATCH] platform/mellanox: mlxreg-io: use sysfs_emit() instead of sprintf() Ai Chao
@ 2025-01-16  9:03 ` Vadim Pasternak
  2025-01-17 17:01 ` Ilpo Järvinen
  1 sibling, 0 replies; 3+ messages in thread
From: Vadim Pasternak @ 2025-01-16  9:03 UTC (permalink / raw)
  To: Ai Chao, hdegoede, ilpo.jarvinen, platform-driver-x86, linux-kernel



> -----Original Message-----
> From: Ai Chao <aichao@kylinos.cn>
> Sent: Thursday, 16 January 2025 10:11
> To: hdegoede@redhat.com; ilpo.jarvinen@linux.intel.com; Vadim Pasternak
> <vadimp@nvidia.com>; platform-driver-x86@vger.kernel.org; linux-
> kernel@vger.kernel.org
> Cc: Ai Chao <aichao@kylinos.cn>
> Subject: [PATCH] platform/mellanox: mlxreg-io: use sysfs_emit() instead of
> sprintf()
> 
> Follow the advice in Documentation/filesystems/sysfs.rst:
> show() should only use sysfs_emit() or sysfs_emit_at() when formatting the
> value to be returned to user space.
> 
> Signed-off-by: Ai Chao <aichao@kylinos.cn>

Acked-by: Vadim Pasternak <vadimp@nvidia.com>

> ---
>  drivers/platform/mellanox/mlxreg-io.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/platform/mellanox/mlxreg-io.c
> b/drivers/platform/mellanox/mlxreg-io.c
> index 595276206baf..97fefe6c38d1 100644
> --- a/drivers/platform/mellanox/mlxreg-io.c
> +++ b/drivers/platform/mellanox/mlxreg-io.c
> @@ -126,7 +126,7 @@ mlxreg_io_attr_show(struct device *dev, struct
> device_attribute *attr,
> 
>  	mutex_unlock(&priv->io_lock);
> 
> -	return sprintf(buf, "%u\n", regval);
> +	return sysfs_emit(buf, "%u\n", regval);
> 
>  access_error:
>  	mutex_unlock(&priv->io_lock);
> --
> 2.47.1


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

* Re: [PATCH] platform/mellanox: mlxreg-io: use sysfs_emit() instead of sprintf()
  2025-01-16  8:11 [PATCH] platform/mellanox: mlxreg-io: use sysfs_emit() instead of sprintf() Ai Chao
  2025-01-16  9:03 ` Vadim Pasternak
@ 2025-01-17 17:01 ` Ilpo Järvinen
  1 sibling, 0 replies; 3+ messages in thread
From: Ilpo Järvinen @ 2025-01-17 17:01 UTC (permalink / raw)
  To: Ai Chao; +Cc: Hans de Goede, vadimp, platform-driver-x86, LKML

On Thu, 16 Jan 2025, Ai Chao wrote:

> Follow the advice in Documentation/filesystems/sysfs.rst:
> show() should only use sysfs_emit() or sysfs_emit_at() when formatting
> the value to be returned to user space.
> 
> Signed-off-by: Ai Chao <aichao@kylinos.cn>

Hi,

I've now applied these 3 into the review-ilpo-next branch. Next time, 
however, please make a patch series out of cleanups of same kind so it'll 
be easier for me to handle them as a single set of patches. Thank you.

-- 
 i.

> ---
>  drivers/platform/mellanox/mlxreg-io.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/platform/mellanox/mlxreg-io.c b/drivers/platform/mellanox/mlxreg-io.c
> index 595276206baf..97fefe6c38d1 100644
> --- a/drivers/platform/mellanox/mlxreg-io.c
> +++ b/drivers/platform/mellanox/mlxreg-io.c
> @@ -126,7 +126,7 @@ mlxreg_io_attr_show(struct device *dev, struct device_attribute *attr,
>  
>  	mutex_unlock(&priv->io_lock);
>  
> -	return sprintf(buf, "%u\n", regval);
> +	return sysfs_emit(buf, "%u\n", regval);
>  
>  access_error:
>  	mutex_unlock(&priv->io_lock);
> 

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

end of thread, other threads:[~2025-01-17 17:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-01-16  8:11 [PATCH] platform/mellanox: mlxreg-io: use sysfs_emit() instead of sprintf() Ai Chao
2025-01-16  9:03 ` Vadim Pasternak
2025-01-17 17:01 ` Ilpo Järvinen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®