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

Andy Shevchenko
2026-03-31T07:50:16Z

On Tue, Mar 31, 2026 at 12:17:09AM +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");

This should be replaced with a for-loop, printing all from that array.

> }

--
With Best Regards,
Andy Shevchenko