lkml.org 
[lkml]   [2021]   [Mar]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH 2/3] drivers/perf: convert sysfs scnprintf family to sysfs_emit_at
From
Date
On Wed, 2021-03-17 at 17:41 +0800, Qi Liu wrote:
> Use the generic sysfs_emit_at() function take place of scnprintf()
[]
> diff --git a/drivers/perf/arm-ccn.c b/drivers/perf/arm-ccn.c
[]
> @@ -328,41 +328,37 @@ static ssize_t arm_ccn_pmu_event_show(struct device *dev,
>   struct arm_ccn_pmu_event, attr);
>   ssize_t res;
>  
>
> - res = scnprintf(buf, PAGE_SIZE, "type=0x%x", event->type);
> + res = sysfs_emit(buf, "type=0x%x", event->type);
>   if (event->event)
> - res += scnprintf(buf + res, PAGE_SIZE - res, ",event=0x%x",
> + res += sysfs_emit_at(buf + res, res, ",event=0x%x",
>   event->event);

sysfs_emit_at should always use buf, not buf + offset.
res should be int and is the offset from buf for the output

so the form should be similar to

int len;

len = sysfs_emit(buf, "type=0x%x", event->type);
if (event->event) {
len += sysfs_emit_at(buf, len, ",event=0x%x", event->event);

etc...


\
 
 \ /
  Last update: 2021-03-17 17:27    [W:0.099 / U:0.440 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site