drivers: firmware: stratix10-rsu: Fix max_retry counter value

Message ID 88b79f4cfe1c28e31b902d2f12b81e431b09e125.1691112823.git.kah.jing.lee@intel.com
State New
Headers
Series drivers: firmware: stratix10-rsu: Fix max_retry counter value |

Commit Message

Lee, Kah Jing Aug. 4, 2023, 1:35 a.m. UTC
  From: Kah Jing Lee <kah.jing.lee@intel.com>

Fix the max_retry value because the value is truncated at scnprintf format
specifier, with added hex symbol and newline.

Signed-off-by: Kah Jing Lee <kah.jing.lee@intel.com>
---
 drivers/firmware/stratix10-rsu.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)


base-commit: c1a515d3c0270628df8ae5f5118ba859b85464a2
  

Comments

Dinh Nguyen Aug. 6, 2023, 5:51 p.m. UTC | #1
On 8/3/23 20:35, kah.jing.lee@intel.com wrote:
> From: Kah Jing Lee <kah.jing.lee@intel.com>
> 
> Fix the max_retry value because the value is truncated at scnprintf format
> specifier, with added hex symbol and newline.
> 
> Signed-off-by: Kah Jing Lee <kah.jing.lee@intel.com>
> ---
>   drivers/firmware/stratix10-rsu.c | 3 +--
>   1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/firmware/stratix10-rsu.c b/drivers/firmware/stratix10-rsu.c
> index e51c95f8d445..98ec39f6dae8 100644
> --- a/drivers/firmware/stratix10-rsu.c
> +++ b/drivers/firmware/stratix10-rsu.c
> @@ -405,8 +405,7 @@ static ssize_t max_retry_show(struct device *dev,
>   	if (!priv)
>   		return -ENODEV;
>   
> -	return scnprintf(buf, sizeof(priv->max_retry),
> -			 "0x%08x\n", priv->max_retry);
> +	return scnprintf(buf, PAGE_SIZE, "0x%08x\n", priv->max_retry);
>   }
>   

This would be a good time to switch over to use sysfs_emit()

Dinh
  

Patch

diff --git a/drivers/firmware/stratix10-rsu.c b/drivers/firmware/stratix10-rsu.c
index e51c95f8d445..98ec39f6dae8 100644
--- a/drivers/firmware/stratix10-rsu.c
+++ b/drivers/firmware/stratix10-rsu.c
@@ -405,8 +405,7 @@  static ssize_t max_retry_show(struct device *dev,
 	if (!priv)
 		return -ENODEV;
 
-	return scnprintf(buf, sizeof(priv->max_retry),
-			 "0x%08x\n", priv->max_retry);
+	return scnprintf(buf, PAGE_SIZE, "0x%08x\n", priv->max_retry);
 }
 
 static ssize_t dcmf0_show(struct device *dev,