Skip to content

Commit

Permalink
iio: ms_sensors: Use sysfs_emit()
Browse files Browse the repository at this point in the history
sysfs_emit() is preferred over raw s*printf() for sysfs attributes since it
knows about the sysfs buffer specifics and has some built-in checks for
size and alignment.

Use sysfs_emit() to format the custom `battery_low` and `heater_enable`
device attributes of the ms_sensors driver shared code.

Signed-off-by: Lars-Peter Clausen <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jonathan Cameron <[email protected]>
  • Loading branch information
larsclausen authored and jic23 committed Jan 23, 2022
1 parent d42b626 commit 6ab56c4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/iio/common/ms_sensors/ms_sensors_i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ ssize_t ms_sensors_show_battery_low(struct ms_ht_dev *dev_data,
if (ret)
return ret;

return sprintf(buf, "%d\n", (config_reg & 0x40) >> 6);
return sysfs_emit(buf, "%d\n", (config_reg & 0x40) >> 6);
}
EXPORT_SYMBOL(ms_sensors_show_battery_low);

Expand All @@ -351,7 +351,7 @@ ssize_t ms_sensors_show_heater(struct ms_ht_dev *dev_data,
if (ret)
return ret;

return sprintf(buf, "%d\n", (config_reg & 0x4) >> 2);
return sysfs_emit(buf, "%d\n", (config_reg & 0x4) >> 2);
}
EXPORT_SYMBOL(ms_sensors_show_heater);

Expand Down

0 comments on commit 6ab56c4

Please sign in to comment.