Skip to contentSkip to conversation

powerpc/ps3: replace open-coded sysfs_emit function

PATCH Applied Paulo Miguel Almeida 4 participants 4 messages Oct 19, 2024 – Nov 17, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 powerpc/ps3: replace open-coded sysfs_emit function

sysfs_emit() helper function should be used when formatting the value to be returned to user space.

This patch replaces open-coded sysfs_emit() in sysfs .show() callbacks

---
 arch/powerpc/platforms/ps3/system-bus.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
arch/powerpc/platforms/ps3/system-bus.c +2 -3
index b9a7d9bae687..afbaabf182d0 100644
@@ -453,10 +453,9 @@ static ssize_t modalias_show(struct device *_dev, struct device_attribute *a,
 	char *buf)
 {
 	struct ps3_system_bus_device *dev = ps3_dev_to_system_bus_dev(_dev);
-	int len = snprintf(buf, PAGE_SIZE, "ps3:%d:%d\n", dev->match_id,
-			   dev->match_sub_id);
 
-	return (len >= PAGE_SIZE) ? (PAGE_SIZE - 1) : len;
+	return sysfs_emit(buf, "ps3:%d:%d\n", dev->match_id,
+			  dev->match_sub_id);
 }
 static DEVICE_ATTR_RO(modalias);
 
Signature · 1 line
2.47.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Paulo Miguel Almeida

sysfs_emit() helper function should be used when formatting the value to be returned to user space.

This patch replaces open-coded sysfs_emit() in sysfs .show() callbacks

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
maintainer Acked-by on v1 1/1
#2 lore raw
In reply to Paulo Miguel Almeida

Hi Paulo,

Quoted 17 lines · Paulo Miguel Almeida

sysfs_emit() helper function should be used when formatting the value to be returned to user space.

This patch replaces open-coded sysfs_emit() in sysfs .show() callbacks

---
 arch/powerpc/platforms/ps3/system-bus.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
arch/powerpc/platforms/ps3/system-bus.c +0 -0
index b9a7d9bae687..afbaabf182d0 100644
@@ -453,10 +453,9 @@ static ssize_t modalias_show(struct device *_dev, struct device_attribute *a,
 	char *buf)

arch/powerpc/platforms/ps3/system-bus.c static ssize_t modalias_show(struct device *_dev, struct device_attribute *a, · line 460

Quoted 10 lines
arch/powerpc/platforms/ps3/system-bus.c +2 -3
 {
 	struct ps3_system_bus_device *dev = ps3_dev_to_system_bus_dev(_dev);
-	int len = snprintf(buf, PAGE_SIZE, "ps3:%d:%d\n", dev->match_id,
-			   dev->match_sub_id);
 
-	return (len >= PAGE_SIZE) ? (PAGE_SIZE - 1) : len;
+	return sysfs_emit(buf, "ps3:%d:%d\n", dev->match_id,
+			  dev->match_sub_id);
 }
 static DEVICE_ATTR_RO(modalias);

I tested this on PS3 and it seems to work OK.
Thanks for your contribution.