summaryrefslogtreecommitdiff
path: root/drivers/hwmon/ltc4261.c
diff options
context:
space:
mode:
authorGuenter Roeck <linux@roeck-us.net>2021-03-22 06:49:10 +0300
committerGuenter Roeck <linux@roeck-us.net>2021-04-20 16:50:14 +0300
commit1f4d4af4d7a1c794a4f003f75fcfd38fafb5dff3 (patch)
tree694363ce77aef2c1e572a2962d30ba72f8f6648a /drivers/hwmon/ltc4261.c
parentf807e8be46991a5a58774a4d6344359b01c949e8 (diff)
downloadlinux-1f4d4af4d7a1c794a4f003f75fcfd38fafb5dff3.tar.xz
hwmon: replace snprintf in show functions with sysfs_emit
coccicheck complains about the use of snprintf() in sysfs show functions. drivers/hwmon/ina3221.c:701:8-16: WARNING: use scnprintf or sprintf This results in a large number of patch submissions. Fix it all in one go using the following coccinelle rules. Use sysfs_emit instead of scnprintf or sprintf since that makes more sense. @depends on patch@ identifier show, dev, attr, buf; @@ ssize_t show(struct device *dev, struct device_attribute *attr, char *buf) { <... return - snprintf(buf, \( PAGE_SIZE \| PAGE_SIZE - 1 \), + sysfs_emit(buf, ...); ...> } @depends on patch@ identifier show, dev, attr, buf, rc; @@ ssize_t show(struct device *dev, struct device_attribute *attr, char *buf) { <... rc = - snprintf(buf, \( PAGE_SIZE \| PAGE_SIZE - 1 \), + sysfs_emit(buf, ...); ...> } While at it, remove unnecessary braces and as well as unnecessary else after return statements to address checkpatch warnings in the resulting patch. Cc: Zihao Tang <tangzihao1@hisilicon.com> Cc: Jay Fang <f.fangjian@huawei.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers/hwmon/ltc4261.c')
-rw-r--r--drivers/hwmon/ltc4261.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/hwmon/ltc4261.c b/drivers/hwmon/ltc4261.c
index 1dab84b52df5..b81e9c3d297b 100644
--- a/drivers/hwmon/ltc4261.c
+++ b/drivers/hwmon/ltc4261.c
@@ -130,7 +130,7 @@ static ssize_t ltc4261_value_show(struct device *dev,
return PTR_ERR(data);
value = ltc4261_get_value(data, attr->index);
- return snprintf(buf, PAGE_SIZE, "%d\n", value);
+ return sysfs_emit(buf, "%d\n", value);
}
static ssize_t ltc4261_bool_show(struct device *dev,
@@ -147,7 +147,7 @@ static ssize_t ltc4261_bool_show(struct device *dev,
if (fault) /* Clear reported faults in chip register */
i2c_smbus_write_byte_data(data->client, LTC4261_FAULT, ~fault);
- return snprintf(buf, PAGE_SIZE, "%d\n", fault ? 1 : 0);
+ return sysfs_emit(buf, "%d\n", fault ? 1 : 0);
}
/*