hwmon: Replace sprintf() with sysfs_emit()
v2 cover hwmon: Replace sprintf() with sysfs_emit()
This series replaces sprintf() with sysfs_emit() in several hwmon drivers when writing to sysfs buffers.
sysfs_emit() performs proper bounds checking and is the preferred helper for sysfs output.
No functional changes intended.
Changes in v2:
1. Use imperative mood in commit messages
2. Format subjects as "hwmon: (driver) ..."
3. Remove redundant driver name from commit descriptions
Amay Agarwal (5):
hwmon: (tc74) Replace sprintf() with sysfs_emit()
hwmon: (max31722) Replace sprintf() with sysfs_emit()
hwmon: (ads7828) Replace sprintf() with sysfs_emit()
hwmon: (max6650) Replace sprintf() with sysfs_emit()
hwmon: (emc1403) Replace sprintf() with sysfs_emit()
drivers/hwmon/ads7828.c | 2 +- drivers/hwmon/emc1403.c | 2 +- drivers/hwmon/max31722.c | 3 ++- drivers/hwmon/max6650.c | 3 ++- drivers/hwmon/tc74.c | 2 +- 5 files changed, 7 insertions(+), 5 deletions(-)
Signature · 1 line
2.53.0
PATCH v2 1/5 hwmon: (tc74) Replace sprintf() with sysfs_emit()
Replace sprintf() with sysfs_emit() when writing to sysfs buffers.
sysfs_emit() performs proper bounds checking and is the preferred helper for sysfs output.
No functional change intended
--- drivers/hwmon/tc74.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hwmon/tc74.c +1 -1
@@ -92,7 +92,7 @@ static ssize_t temp_input_show(struct device *dev,if (ret)return ret; -return sprintf (buf,"%d\n" , data->temp_input *1000 ); +return sysfs_emit (buf,"%d\n" , data->temp_input *1000 ); } static SENSOR_DEVICE_ATTR_RO(temp1_input, temp_input, 0);
Signature · 1 line
2.53.0
Re: [PATCH v2 1/5] hwmon: (tc74) Replace sprintf() with sysfs_emit()
Quoted 8 lines · Amay Agarwal
Replace
sprintf()withsysfs_emit()when writing to sysfs buffers.
sysfs_emit()performs proper bounds checking and is the preferred helper for sysfs output.No functional change intended
Signed-off-by Amay Agarwal <[email protected]>
Applied.
Thanks,
Guenter
PATCH v2 2/5 hwmon: (max31722) Replace sprintf() with sysfs_emit()
In reply to Amay AgarwalReplace sprintf() with sysfs_emit() when writing to sysfs buffers.
sysfs_emit() performs proper bounds checking and is the preferred helper for sysfs output.
No functional change intended.
--- drivers/hwmon/max31722.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/hwmon/max31722.c +2 -1
@@ -11,6 +11,7 @@#include <linux/kernel.h> #include <linux/module.h> #include <linux/spi/spi.h> +#include <linux/sysfs.h> #define MAX31722_REG_CFG 0x00#define MAX31722_REG_TEMP_LSB 0x01
@@ -56,7 +57,7 @@ static ssize_t max31722_temp_show(struct device *dev,if (ret <0 )return ret;/* Keep 12 bits and multiply by the scale of 62.5 millidegrees/bit. */ -return sprintf (buf,"%d\n" , (s16 )le16_to_cpu (ret) *125 /32 ); +return sysfs_emit (buf,"%d\n" , (s16 )le16_to_cpu (ret) *125 /32 ); } static SENSOR_DEVICE_ATTR_RO(temp1_input, max31722_temp, 0);
Signature · 1 line
2.53.0
Re: [PATCH v2 2/5] hwmon: (max31722) Replace sprintf() with sysfs_emit()
Quoted 8 lines · Amay Agarwal
Replace
sprintf()withsysfs_emit()when writing to sysfs buffers.
sysfs_emit()performs proper bounds checking and is the preferred helper for sysfs output.No functional change intended.
Signed-off-by Amay Agarwal <[email protected]>
Applied.
Thanks,
Guenter
PATCH v2 3/5 hwmon: (ads7828) Replace sprintf() with sysfs_emit()
In reply to Amay AgarwalReplace sprintf() with sysfs_emit() when writing to sysfs buffers.
sysfs_emit() performs proper bounds checking and is the preferred helper for sysfs output.
No functional change intended.
--- drivers/hwmon/ads7828.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hwmon/ads7828.c +1 -1
@@ -62,7 +62,7 @@ static ssize_t ads7828_in_show(struct device *dev,if (err <0 )return err; -return sprintf (buf,"%d\n" , +return sysfs_emit (buf,"%d\n" ,DIV_ROUND_CLOSEST (regval * data->lsb_resol,1000 )); }
Signature · 1 line
2.53.0
Re: [PATCH v2 3/5] hwmon: (ads7828) Replace sprintf() with sysfs_emit()
Quoted 8 lines · Amay Agarwal
Replace
sprintf()withsysfs_emit()when writing to sysfs buffers.
sysfs_emit()performs proper bounds checking and is the preferred helper for sysfs output.No functional change intended.
Signed-off-by Amay Agarwal <[email protected]>
Watch out for multip-line alignment issues in the future. No need to resend, I'll fix that.
Applied.
Thanks,
Guenter
Quoted 17 lines
--- drivers/hwmon/ads7828.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/hwmon/ads7828.c +1
-1@@ -62,7 +62,7 @@ static ssize_t ads7828_in_show(struct device *dev,if (err <0 )return err; -return sprintf (buf,"%d\n" , +return sysfs_emit (buf,"%d\n" ,DIV_ROUND_CLOSEST (regval * data->lsb_resol,1000 )); }
PATCH v2 4/5 hwmon: (max6650) Replace sprintf() with sysfs_emit()
In reply to Amay AgarwalReplace sprintf() with sysfs_emit() when writing to sysfs buffers.
sysfs_emit() performs proper bounds checking and is the preferred helper for sysfs output.
No functional change intended.
--- drivers/hwmon/max6650.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/hwmon/max6650.c +2 -1
@@ -27,6 +27,7 @@#include <linux/hwmon-sysfs.h> #include <linux/err.h> #include <linux/of.h> +#include <linux/sysfs.h> #include <linux/thermal.h> /*
@@ -312,7 +313,7 @@ static ssize_t alarm_show(struct device *dev,mutex_unlock (&data->update_lock); } -return sprintf (buf,"%d\n" , alarm); +return sysfs_emit (buf,"%d\n" , alarm); } static SENSOR_DEVICE_ATTR_RO(gpio1_alarm, alarm, MAX6650_ALRM_GPIO1);
Signature · 1 line
2.53.0
Re: [PATCH v2 4/5] hwmon: (max6650) Replace sprintf() with sysfs_emit()
Quoted 8 lines · Amay Agarwal
Replace
sprintf()withsysfs_emit()when writing to sysfs buffers.
sysfs_emit()performs proper bounds checking and is the preferred helper for sysfs output.No functional change intended.
Signed-off-by Amay Agarwal <[email protected]>
Applied.
Thanks,
Guenter
PATCH v2 5/5 hwmon: (emc1403) Replace sprintf() with sysfs_emit()
In reply to Amay AgarwalReplace sprintf() with sysfs_emit() when writing to sysfs buffers.
sysfs_emit() performs proper bounds checking and is the preferred helper for sysfs output.
No functional change intended.
--- drivers/hwmon/emc1403.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hwmon/emc1403.c +1 -1
@@ -40,7 +40,7 @@ static ssize_t power_state_show(struct device *dev, struct device_attribute *att retval =regmap_read (data->regmap,0x03 , &val);if (retval <0 )return retval; -return sprintf (buf,"%d\n" , !!(val &BIT (6 ))); +return sysfs_emit (buf,"%d\n" , !!(val &BIT (6 ))); } static ssize_t power_state_store(struct device *dev, struct device_attribute *attr,
Signature · 1 line
2.53.0
Re: [PATCH v2 5/5] hwmon: (emc1403) Replace sprintf() with sysfs_emit()
Quoted 8 lines · Amay Agarwal
Replace
sprintf()withsysfs_emit()when writing to sysfs buffers.
sysfs_emit()performs proper bounds checking and is the preferred helper for sysfs output.No functional change intended.
Signed-off-by Amay Agarwal <[email protected]>
Applied.
Thanks,
Guenter