Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

staging: iio: ad7816: Replace sprintf() with sysfs_emit()

As stated in Documentation/filesystems/sysfs.rst:
'New implementations of show() methods should only use sysfs_emit() or
sysfs_emit_at() when formatting the value to be returned to user space.'

Replace sprintf with sysfs_emit in the following sysfs show functions:
- ad7816_show_mode()
- ad7816_show_available_modes()
- ad7816_show_channel()
- ad7816_show_value()
- ad7816_show_oti()

Signed-off-by: Bruno Martins <ehanoc@protonmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Bruno Martins and committed by
Jonathan Cameron
cd04646c 5c3cf14b

+8 -8
+8 -8
drivers/staging/iio/adc/ad7816.c
··· 124 124 struct ad7816_chip_info *chip = iio_priv(indio_dev); 125 125 126 126 if (chip->mode) 127 - return sprintf(buf, "power-save\n"); 128 - return sprintf(buf, "full\n"); 127 + return sysfs_emit(buf, "power-save\n"); 128 + return sysfs_emit(buf, "full\n"); 129 129 } 130 130 131 131 static ssize_t ad7816_store_mode(struct device *dev, ··· 156 156 struct device_attribute *attr, 157 157 char *buf) 158 158 { 159 - return sprintf(buf, "full\npower-save\n"); 159 + return sysfs_emit(buf, "full\npower-save\n"); 160 160 } 161 161 162 162 static IIO_DEVICE_ATTR(available_modes, 0444, ad7816_show_available_modes, ··· 169 169 struct iio_dev *indio_dev = dev_to_iio_dev(dev); 170 170 struct ad7816_chip_info *chip = iio_priv(indio_dev); 171 171 172 - return sprintf(buf, "%d\n", chip->channel_id); 172 + return sysfs_emit(buf, "%d\n", chip->channel_id); 173 173 } 174 174 175 175 static ssize_t ad7816_store_channel(struct device *dev, ··· 231 231 data &= AD7816_TEMP_FLOAT_MASK; 232 232 if (value < 0) 233 233 data = BIT(AD7816_TEMP_FLOAT_OFFSET) - data; 234 - return sprintf(buf, "%d.%.2d\n", value, data * 25); 234 + return sysfs_emit(buf, "%d.%.2d\n", value, data * 25); 235 235 } 236 - return sprintf(buf, "%u\n", data); 236 + return sysfs_emit(buf, "%u\n", data); 237 237 } 238 238 239 239 static IIO_DEVICE_ATTR(value, 0444, ad7816_show_value, NULL, 0); ··· 281 281 value = AD7816_BOUND_VALUE_MIN + 282 282 (chip->oti_data[chip->channel_id] - 283 283 AD7816_BOUND_VALUE_BASE); 284 - return sprintf(buf, "%d\n", value); 284 + return sysfs_emit(buf, "%d\n", value); 285 285 } 286 - return sprintf(buf, "%u\n", chip->oti_data[chip->channel_id]); 286 + return sysfs_emit(buf, "%u\n", chip->oti_data[chip->channel_id]); 287 287 } 288 288 289 289 static inline ssize_t ad7816_set_oti(struct device *dev,