Commit 9ec9f9cf authored by Qi Liu's avatar Qi Liu Committed by Will Deacon

drivers/perf: convert sysfs scnprintf family to sysfs_emit_at() and sysfs_emit()

Use the generic sysfs_emit_at() and sysfs_emit() function to take place
of scnprintf()
Signed-off-by: default avatarQi Liu <liuqi115@huawei.com>
Link: https://lore.kernel.org/r/1616148273-16374-3-git-send-email-liuqi115@huawei.comSigned-off-by: default avatarWill Deacon <will@kernel.org>
parent 700a9cf0
...@@ -326,43 +326,38 @@ static ssize_t arm_ccn_pmu_event_show(struct device *dev, ...@@ -326,43 +326,38 @@ static ssize_t arm_ccn_pmu_event_show(struct device *dev,
struct arm_ccn *ccn = pmu_to_arm_ccn(dev_get_drvdata(dev)); struct arm_ccn *ccn = pmu_to_arm_ccn(dev_get_drvdata(dev));
struct arm_ccn_pmu_event *event = container_of(attr, struct arm_ccn_pmu_event *event = container_of(attr,
struct arm_ccn_pmu_event, attr); struct arm_ccn_pmu_event, attr);
ssize_t res; int res;
res = scnprintf(buf, PAGE_SIZE, "type=0x%x", event->type); res = sysfs_emit(buf, "type=0x%x", event->type);
if (event->event) if (event->event)
res += scnprintf(buf + res, PAGE_SIZE - res, ",event=0x%x", res += sysfs_emit_at(buf, res, ",event=0x%x", event->event);
event->event);
if (event->def) if (event->def)
res += scnprintf(buf + res, PAGE_SIZE - res, ",%s", res += sysfs_emit_at(buf, res, ",%s", event->def);
event->def);
if (event->mask) if (event->mask)
res += scnprintf(buf + res, PAGE_SIZE - res, ",mask=0x%x", res += sysfs_emit_at(buf, res, ",mask=0x%x", event->mask);
event->mask);
/* Arguments required by an event */ /* Arguments required by an event */
switch (event->type) { switch (event->type) {
case CCN_TYPE_CYCLES: case CCN_TYPE_CYCLES:
break; break;
case CCN_TYPE_XP: case CCN_TYPE_XP:
res += scnprintf(buf + res, PAGE_SIZE - res, res += sysfs_emit_at(buf, res, ",xp=?,vc=?");
",xp=?,vc=?");
if (event->event == CCN_EVENT_WATCHPOINT) if (event->event == CCN_EVENT_WATCHPOINT)
res += scnprintf(buf + res, PAGE_SIZE - res, res += sysfs_emit_at(buf, res,
",port=?,dir=?,cmp_l=?,cmp_h=?,mask=?"); ",port=?,dir=?,cmp_l=?,cmp_h=?,mask=?");
else else
res += scnprintf(buf + res, PAGE_SIZE - res, res += sysfs_emit_at(buf, res, ",bus=?");
",bus=?");
break; break;
case CCN_TYPE_MN: case CCN_TYPE_MN:
res += scnprintf(buf + res, PAGE_SIZE - res, ",node=%d", ccn->mn_id); res += sysfs_emit_at(buf, res, ",node=%d", ccn->mn_id);
break; break;
default: default:
res += scnprintf(buf + res, PAGE_SIZE - res, ",node=?"); res += sysfs_emit_at(buf, res, ",node=?");
break; break;
} }
res += scnprintf(buf + res, PAGE_SIZE - res, "\n"); res += sysfs_emit_at(buf, res, "\n");
return res; return res;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment