mirror of
https://github.com/torvalds/linux.git
synced 2026-09-22 12:44:03 +02:00
iio: light: tsl2583: migrate to sysfs_emit() and sysfs_emit_at()
Replace sprintf() with sysfs_emit() for single-value sysfs show functions, and use sysfs_emit_at() for lux_table_show() which concatenates multiple values. This ensures buffer safety and follows the modern kernel sysfs API. Signed-off-by: Chengrui Liu <OrangeBlack0765@outlook.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com> Signed-off-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
This commit is contained in:
parent
23f66b58b1
commit
0777fb25ed
|
|
@ -475,7 +475,7 @@ static ssize_t in_illuminance_input_target_show(struct device *dev,
|
|||
int ret;
|
||||
|
||||
mutex_lock(&chip->als_mutex);
|
||||
ret = sprintf(buf, "%d\n", chip->als_settings.als_cal_target);
|
||||
ret = sysfs_emit(buf, "%d\n", chip->als_settings.als_cal_target);
|
||||
mutex_unlock(&chip->als_mutex);
|
||||
|
||||
return ret;
|
||||
|
|
@ -533,10 +533,10 @@ static ssize_t in_illuminance_lux_table_show(struct device *dev,
|
|||
int offset = 0;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(chip->als_settings.als_device_lux); i++) {
|
||||
offset += sprintf(buf + offset, "%u,%u,%u,",
|
||||
chip->als_settings.als_device_lux[i].ratio,
|
||||
chip->als_settings.als_device_lux[i].ch0,
|
||||
chip->als_settings.als_device_lux[i].ch1);
|
||||
offset += sysfs_emit_at(buf, offset, "%u,%u,%u,",
|
||||
chip->als_settings.als_device_lux[i].ratio,
|
||||
chip->als_settings.als_device_lux[i].ch0,
|
||||
chip->als_settings.als_device_lux[i].ch1);
|
||||
if (chip->als_settings.als_device_lux[i].ratio == 0) {
|
||||
/*
|
||||
* We just printed the first "0" entry.
|
||||
|
|
@ -547,7 +547,7 @@ static ssize_t in_illuminance_lux_table_show(struct device *dev,
|
|||
}
|
||||
}
|
||||
|
||||
offset += sprintf(buf + offset, "\n");
|
||||
offset += sysfs_emit_at(buf, offset, "\n");
|
||||
|
||||
return offset;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user