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>
Link: https://lore.kernel.org/r/20250116081129.2902274-1-aichao@kylinos.cn
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
This commit is contained in:
Ai Chao 2025-01-16 16:11:29 +08:00 committed by Ilpo Järvinen
parent fcf1b6f8d8
commit ff44b1ca88
No known key found for this signature in database
GPG Key ID: 59AC4F6153E5CE31

View File

@ -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);