Re: [PATCH] staging: media: atomisp: Replace scnprintf with sysfs_emit in bo_show
From: Andy Shevchenko
Date: Sat Jun 21 2025 - 14:25:29 EST
On Sat, Jun 21, 2025 at 9:30 AM Abdelrahman Fekry
<abdelrahmanfekry375@xxxxxxxxx> wrote:
>
> Convert buffer output to use sysfs_emit/sysfs_emit_at API for safer
> PAGE_SIZE handling and standardized sysfs output.
...
> - ssize_t ret = 0;
> + ssize_t offset = 0;
It would be good to move this...
> struct hmm_buffer_object *bo;
> unsigned long flags;
> int i;
> long total[HMM_BO_LAST] = { 0 };
> long count[HMM_BO_LAST] = { 0 };
> - int index1 = 0;
> - int index2 = 0;
...to be here.
>
> - ret = scnprintf(buf, PAGE_SIZE, "type pgnr\n");
> - if (ret <= 0)
> - return 0;
> -
> - index1 += ret;
> + offset += sysfs_emit(buf, "type pgnr\n");
This changes the behaviour in case the sysfs_emit() fails. Not that
this is a big issue, but it should be pointed out somewhere.
...
> + /* Direct return of accumlated length */
accumulated
Don't forget to run a spell-checker.
--
With Best Regards,
Andy Shevchenko