Re: [PATCH 3/3] staging: iio: ad9834: use sysfs_emit() in show functions

From: Andy Shevchenko

Date: Fri Mar 20 2026 - 04:15:22 EST


On Thu, Mar 19, 2026 at 10:57:19PM +0000, Gabriel Rondon wrote:
> Replace sprintf() with sysfs_emit() in sysfs attribute show functions.
> sysfs_emit() is the preferred API for sysfs callbacks as it is aware
> of the PAGE_SIZE buffer limit. No functional change.

...

> else
> str = "sine triangle";
>
> - return sprintf(buf, "%s\n", str);
> + return sysfs_emit(buf, "%s\n", str);

Do more, drop these unneeded 'else' and return directly,

if (st->devid == ID_AD9833 || st->devid == ID_AD9837)
return sysfs_emit(buf, "sine triangle square\n");
if (st->control & AD9834_OPBITEN)
return sysfs_emit(buf, "sine\n");
return sysfs_emit(buf, "sine triangle\n");

But again, check what is the modern ways of providing static _avail lists.

...

> - return sprintf(buf, "%s\n", str);
> + return sysfs_emit(buf, "%s\n", str);

Ditto.

--
With Best Regards,
Andy Shevchenko