Re: [PATCH v4 3/4] staging: iio: adc: ad7816: replace sprintf() with sysfs_emit()

From: Andy Shevchenko

Date: Tue Mar 31 2026 - 05:12:00 EST


On Tue, Mar 31, 2026 at 01:24:52PM +0600, Md. Mahmudul Hasan Mabud wrote:
> Replace sprintf() with sysfs_emit() in all show attributes.
> sysfs_emit() is the preferred way to return values in sysfs
> callbacks as it is safer and handles page boundary checks
> automatically.

...

> static ssize_t ad7816_show_available_modes(struct device *dev,
> struct device_attribute *attr,
> char *buf)
> {
> - return sprintf(buf, "full\npower-save\n");
> + return sysfs_emit(buf, "full\npower-save\n");

Missed a comment. This needs to be converted to a for-loop with use of
sysfs_emit_at().

> }

--
With Best Regards,
Andy Shevchenko