Skip to contentSkip to conversation

firmware: stratix10-rsu: replace scnprintf() with sysfs_emit() in *_show() functions

PATCH In review Rahul Kumar 2 participants 5 messages Oct 15, 2025 – Nov 11, 2025 Intel STRATIX10 firmware drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 firmware: stratix10-rsu: replace scnprintf() with sysfs_emit() in *_show() functions

Replace scnprintf() with sysfs_emit() in sysfs *_show() functions in stratix10-rsu.c to follow the kernel's guidelines from Documentation/filesystems/sysfs.rst.

This improves consistency, safety, and makes the code easier to maintain and update in the future.

---
 drivers/firmware/stratix10-rsu.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/firmware/stratix10-rsu.c +3 -4
index 1ea39a0a76c7..53c896ceca9a 100644
@@ -454,8 +454,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 sysfs_emit(buf, "0x%08x\n", priv->max_retry);
 }
 
 static ssize_t dcmf0_show(struct device *dev,
@@ -632,7 +631,7 @@ static ssize_t spt0_address_show(struct device *dev,
 	if (priv->spt0_address == INVALID_SPT_ADDRESS)
 		return -EIO;
 
-	return scnprintf(buf, PAGE_SIZE, "0x%08lx\n", priv->spt0_address);
+	return sysfs_emit(buf, "0x%08lx\n", priv->spt0_address);
 }
 
 static ssize_t spt1_address_show(struct device *dev,
@@ -646,7 +645,7 @@ static ssize_t spt1_address_show(struct device *dev,
 	if (priv->spt1_address == INVALID_SPT_ADDRESS)
 		return -EIO;
 
-	return scnprintf(buf, PAGE_SIZE, "0x%08lx\n", priv->spt1_address);
+	return sysfs_emit(buf, "0x%08lx\n", priv->spt1_address);
 }
 
 static DEVICE_ATTR_RO(current_image);
Signature · 1 line
2.43.0
#1 lore raw
Quoted 46 lines · Rahul Kumar

Replace scnprintf() with sysfs_emit() in sysfs *_show() functions in stratix10-rsu.c to follow the kernel's guidelines from Documentation/filesystems/sysfs.rst.

This improves consistency, safety, and makes the code easier to maintain and update in the future.

---
 drivers/firmware/stratix10-rsu.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/firmware/stratix10-rsu.c +3 -5
index 1ea39a0a76c7..53c896ceca9a 100644
@@ -454,8 +454,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 sysfs_emit(buf, "0x%08x\n", priv->max_retry);
 }
 
 static ssize_t dcmf0_show(struct device *dev,
@@ -632,7 +631,7 @@ static ssize_t spt0_address_show(struct device *dev,
        if (priv->spt0_address == INVALID_SPT_ADDRESS)
                return -EIO;
 
-       return scnprintf(buf, PAGE_SIZE, "0x%08lx\n", priv->spt0_address);
+       return sysfs_emit(buf, "0x%08lx\n", priv->spt0_address);
 }
 
 static ssize_t spt1_address_show(struct device *dev,
@@ -646,7 +645,7 @@ static ssize_t spt1_address_show(struct device *dev,
        if (priv->spt1_address == INVALID_SPT_ADDRESS)
                return -EIO;
 
-       return scnprintf(buf, PAGE_SIZE, "0x%08lx\n", priv->spt1_address);
+       return sysfs_emit(buf, "0x%08lx\n", priv->spt1_address);
 }
 
 static DEVICE_ATTR_RO(current_image);
--
Quoted 2 lines

2.43.0

Hi Dinguyen,

Just following up to see if you’ve had a chance to review this patch, or if there’s anything more needed from my side.

Link to v1:
https://lore.kernel.org/all/[email protected]/

Thanks,
Rahul

maintainer
#2 lore raw
Quoted 52 lines · Rahul Kumar
Quoted 46 lines · Rahul Kumar

Replace scnprintf() with sysfs_emit() in sysfs *_show() functions in stratix10-rsu.c to follow the kernel's guidelines from Documentation/filesystems/sysfs.rst.

This improves consistency, safety, and makes the code easier to maintain and update in the future.

---
  drivers/firmware/stratix10-rsu.c | 7 +++----
  1 file changed, 3 insertions(+), 4 deletions(-)
drivers/firmware/stratix10-rsu.c +3 -5
index 1ea39a0a76c7..53c896ceca9a 100644
@@ -454,8 +454,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 sysfs_emit(buf, "0x%08x\n", priv->max_retry);
  }
 
  static ssize_t dcmf0_show(struct device *dev,
@@ -632,7 +631,7 @@ static ssize_t spt0_address_show(struct device *dev,
         if (priv->spt0_address == INVALID_SPT_ADDRESS)
                 return -EIO;
 
-       return scnprintf(buf, PAGE_SIZE, "0x%08lx\n", priv->spt0_address);
+       return sysfs_emit(buf, "0x%08lx\n", priv->spt0_address);
  }
 
  static ssize_t spt1_address_show(struct device *dev,
@@ -646,7 +645,7 @@ static ssize_t spt1_address_show(struct device *dev,
         if (priv->spt1_address == INVALID_SPT_ADDRESS)
                 return -EIO;
 
-       return scnprintf(buf, PAGE_SIZE, "0x%08lx\n", priv->spt1_address);
+       return sysfs_emit(buf, "0x%08lx\n", priv->spt1_address);
  }
 
  static DEVICE_ATTR_RO(current_image);
--
Quoted 2 lines

2.43.0

Hi Dinguyen,

Quoted 8 lines

Just following up to see if you’ve had a chance to review this patch, or if there’s anything more needed from my side.

Link to v1:
https://lore.kernel.org/all/[email protected]/

Thanks,
Rahul

Sorry about that. I've applied it.

Thanks,
Dinh

#3 lore raw
Quoted 62 lines · Dinh Nguyen
Quoted 58 lines · Rahul Kumar
Quoted 46 lines · Rahul Kumar

Replace scnprintf() with sysfs_emit() in sysfs *_show() functions in stratix10-rsu.c to follow the kernel's guidelines from Documentation/filesystems/sysfs.rst.

This improves consistency, safety, and makes the code easier to maintain and update in the future.

---
  drivers/firmware/stratix10-rsu.c | 7 +++----
  1 file changed, 3 insertions(+), 4 deletions(-)
drivers/firmware/stratix10-rsu.c +3 -5
index 1ea39a0a76c7..53c896ceca9a 100644
@@ -454,8 +454,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 sysfs_emit(buf, "0x%08x\n", priv->max_retry);
  }
 
  static ssize_t dcmf0_show(struct device *dev,
@@ -632,7 +631,7 @@ static ssize_t spt0_address_show(struct device *dev,
         if (priv->spt0_address == INVALID_SPT_ADDRESS)
                 return -EIO;
 
-       return scnprintf(buf, PAGE_SIZE, "0x%08lx\n", priv->spt0_address);
+       return sysfs_emit(buf, "0x%08lx\n", priv->spt0_address);
  }
 
  static ssize_t spt1_address_show(struct device *dev,
@@ -646,7 +645,7 @@ static ssize_t spt1_address_show(struct device *dev,
         if (priv->spt1_address == INVALID_SPT_ADDRESS)
                 return -EIO;
 
-       return scnprintf(buf, PAGE_SIZE, "0x%08lx\n", priv->spt1_address);
+       return sysfs_emit(buf, "0x%08lx\n", priv->spt1_address);
  }
 
  static DEVICE_ATTR_RO(current_image);
--
Quoted 2 lines

2.43.0

Hi Dinguyen,

Just following up to see if you’ve had a chance to review this patch, or if there’s anything more needed from my side.

Link to v1:
https://lore.kernel.org/all/[email protected]/

Quoted 8 lines
Quoted 2 lines

Thanks,
Rahul

Sorry about that. I've applied it.

Thanks,
Dinh

Hi Dinh,

Could you please share the commit ID where this patch was applied?

Thanks,
Rahul

maintainer
#4 lore raw
Quoted 68 lines · Rahul Kumar
Quoted 67 lines · Dinh Nguyen
Quoted 52 lines · Rahul Kumar
Quoted 46 lines · Rahul Kumar

Replace scnprintf() with sysfs_emit() in sysfs *_show() functions in stratix10-rsu.c to follow the kernel's guidelines from Documentation/filesystems/sysfs.rst.

This improves consistency, safety, and makes the code easier to maintain and update in the future.

---
   drivers/firmware/stratix10-rsu.c | 7 +++----
   1 file changed, 3 insertions(+), 4 deletions(-)
drivers/firmware/stratix10-rsu.c +3 -5
index 1ea39a0a76c7..53c896ceca9a 100644
@@ -454,8 +454,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 sysfs_emit(buf, "0x%08x\n", priv->max_retry);
   }
 
   static ssize_t dcmf0_show(struct device *dev,
@@ -632,7 +631,7 @@ static ssize_t spt0_address_show(struct device *dev,
          if (priv->spt0_address == INVALID_SPT_ADDRESS)
                  return -EIO;
 
-       return scnprintf(buf, PAGE_SIZE, "0x%08lx\n", priv->spt0_address);
+       return sysfs_emit(buf, "0x%08lx\n", priv->spt0_address);
   }
 
   static ssize_t spt1_address_show(struct device *dev,
@@ -646,7 +645,7 @@ static ssize_t spt1_address_show(struct device *dev,
          if (priv->spt1_address == INVALID_SPT_ADDRESS)
                  return -EIO;
 
-       return scnprintf(buf, PAGE_SIZE, "0x%08lx\n", priv->spt1_address);
+       return sysfs_emit(buf, "0x%08lx\n", priv->spt1_address);
   }
 
   static DEVICE_ATTR_RO(current_image);
--
Quoted 2 lines

2.43.0

Hi Dinguyen,

Quoted 8 lines

Just following up to see if you’ve had a chance to review this patch, or if there’s anything more needed from my side.

Link to v1:
https://lore.kernel.org/all/[email protected]/

Thanks,
Rahul

Sorry about that. I've applied it.

Quoted 8 lines
Quoted 3 lines

Thanks,
Dinh

Hi Dinh,

Could you please share the commit ID where this patch was applied?

I've applied this to my branch on kernel.org and will send a PR sometime this week.

Dinh