Skip to contentSkip to conversation

wifi: mt76: mt792x: use sysfs_emit() in thermal temp show callbacks

PATCH New JB Tsai 1 participant 1 message Dec 1

Subsystems (2)
lore
Share & tools
lore

JB Tsai

author
#0 lore raw

PATCH 1/1 wifi: mt76: mt792x: use sysfs_emit() in thermal temp show callbacks

From: Jared Huang <[email protected]>

mt7921_thermal_temp_show() and mt7925_thermal_temp_show() write the temperature into the sysfs buffer with sprintf(), which does not know the size of the buffer. sysfs_emit() is the helper meant for sysfs show() callbacks and bounds the output to PAGE_SIZE.

Replace sprintf() with sysfs_emit(). The output is at most 11 bytes, so the behaviour does not change.

---
 drivers/net/wireless/mediatek/mt76/mt7921/init.c | 2 +-
 drivers/net/wireless/mediatek/mt76/mt7925/init.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7921/init.c +1 -1
index a87ebcff547b..63fdc45e21cb 100644
@@ -28,7 +28,7 @@ static ssize_t mt7921_thermal_temp_show(struct device *dev,
 		if (temperature < 0)
 			return temperature;
 		/* display in millidegree Celsius */
-		return sprintf(buf, "%u\n", temperature * 1000);
+		return sysfs_emit(buf, "%u\n", temperature * 1000);
 	}
 	default:
 		return -EINVAL;
drivers/net/wireless/mediatek/mt76/mt7925/init.c +1 -1
index ad51f71babd7..710fb39b5100 100644
@@ -28,7 +28,7 @@ static ssize_t mt7925_thermal_temp_show(struct device *dev,
 		if (temperature < 0)
 			return temperature;
 		/* display in millidegree Celsius */
-		return sprintf(buf, "%u\n", temperature * 1000);
+		return sysfs_emit(buf, "%u\n", temperature * 1000);
 	}
 	default:
 		return -EINVAL;
Signature · 1 line
2.45.2