diff mbox series

platform/mellanox: mlxreg-hotplug: use sysfs_emit() instead of sprintf()

Message ID 20250116081000.2900435-1-aichao@kylinos.cn (mailing list archive)
State Accepted, archived
Headers show
Series platform/mellanox: mlxreg-hotplug: use sysfs_emit() instead of sprintf() | expand

Commit Message

Ai Chao Jan. 16, 2025, 8:10 a.m. UTC
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-hotplug.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Vadim Pasternak Jan. 16, 2025, 9:03 a.m. UTC | #1
> -----Original Message-----
> From: Ai Chao <aichao@kylinos.cn>
> Sent: Thursday, 16 January 2025 10:10
> 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-hotplug: 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-hotplug.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/platform/mellanox/mlxreg-hotplug.c
> b/drivers/platform/mellanox/mlxreg-hotplug.c
> index 6aa2a4650367..b347000e4329 100644
> --- a/drivers/platform/mellanox/mlxreg-hotplug.c
> +++ b/drivers/platform/mellanox/mlxreg-hotplug.c
> @@ -232,7 +232,7 @@ static ssize_t mlxreg_hotplug_attr_show(struct device
> *dev,
>  			regval = !!(regval & data->mask);
>  	}
> 
> -	return sprintf(buf, "%u\n", regval);
> +	return sysfs_emit(buf, "%u\n", regval);
>  }
> 
>  #define PRIV_ATTR(i) priv->mlxreg_hotplug_attr[i]
> --
> 2.47.1
diff mbox series

Patch

diff --git a/drivers/platform/mellanox/mlxreg-hotplug.c b/drivers/platform/mellanox/mlxreg-hotplug.c
index 6aa2a4650367..b347000e4329 100644
--- a/drivers/platform/mellanox/mlxreg-hotplug.c
+++ b/drivers/platform/mellanox/mlxreg-hotplug.c
@@ -232,7 +232,7 @@  static ssize_t mlxreg_hotplug_attr_show(struct device *dev,
 			regval = !!(regval & data->mask);
 	}
 
-	return sprintf(buf, "%u\n", regval);
+	return sysfs_emit(buf, "%u\n", regval);
 }
 
 #define PRIV_ATTR(i) priv->mlxreg_hotplug_attr[i]