Commit 700a9cf0 authored by Zihao Tang's avatar Zihao Tang Committed by Will Deacon

drivers/perf: convert sysfs snprintf family to sysfs_emit

Fix the following coccicheck warning:

./drivers/perf/hisilicon/hisi_uncore_pmu.c:128:8-16: WARNING: use scnprintf or sprintf.
./drivers/perf/fsl_imx8_ddr_perf.c:173:8-16: WARNING: use scnprintf or sprintf.
./drivers/perf/arm_spe_pmu.c:129:8-16: WARNING: use scnprintf or sprintf.
./drivers/perf/arm_smmu_pmu.c:563:8-16: WARNING: use scnprintf or sprintf.
./drivers/perf/arm_dsu_pmu.c:149:8-16: WARNING: use scnprintf or sprintf.
./drivers/perf/arm_dsu_pmu.c:139:8-16: WARNING: use scnprintf or sprintf.
./drivers/perf/arm-cmn.c:563:8-16: WARNING: use scnprintf or sprintf.
./drivers/perf/arm-cmn.c:351:8-16: WARNING: use scnprintf or sprintf.
./drivers/perf/arm-ccn.c:224:8-16: WARNING: use scnprintf or sprintf.
./drivers/perf/arm-cci.c:708:8-16: WARNING: use scnprintf or sprintf.
./drivers/perf/arm-cci.c:699:8-16: WARNING: use scnprintf or sprintf.
./drivers/perf/arm-cci.c:528:8-16: WARNING: use scnprintf or sprintf.
./drivers/perf/arm-cci.c:309:8-16: WARNING: use scnprintf or sprintf.
Signed-off-by: default avatarZihao Tang <tangzihao1@hisilicon.com>
Signed-off-by: default avatarQi Liu <liuqi115@huawei.com>
Link: https://lore.kernel.org/r/1616148273-16374-2-git-send-email-liuqi115@huawei.comSigned-off-by: default avatarWill Deacon <will@kernel.org>
parent 1e28eed1
...@@ -306,7 +306,7 @@ static ssize_t cci400_pmu_cycle_event_show(struct device *dev, ...@@ -306,7 +306,7 @@ static ssize_t cci400_pmu_cycle_event_show(struct device *dev,
{ {
struct dev_ext_attribute *eattr = container_of(attr, struct dev_ext_attribute *eattr = container_of(attr,
struct dev_ext_attribute, attr); struct dev_ext_attribute, attr);
return snprintf(buf, PAGE_SIZE, "config=0x%lx\n", (unsigned long)eattr->var); return sysfs_emit(buf, "config=0x%lx\n", (unsigned long)eattr->var);
} }
static int cci400_get_event_idx(struct cci_pmu *cci_pmu, static int cci400_get_event_idx(struct cci_pmu *cci_pmu,
...@@ -525,8 +525,8 @@ static ssize_t cci5xx_pmu_global_event_show(struct device *dev, ...@@ -525,8 +525,8 @@ static ssize_t cci5xx_pmu_global_event_show(struct device *dev,
struct dev_ext_attribute *eattr = container_of(attr, struct dev_ext_attribute *eattr = container_of(attr,
struct dev_ext_attribute, attr); struct dev_ext_attribute, attr);
/* Global events have single fixed source code */ /* Global events have single fixed source code */
return snprintf(buf, PAGE_SIZE, "event=0x%lx,source=0x%x\n", return sysfs_emit(buf, "event=0x%lx,source=0x%x\n",
(unsigned long)eattr->var, CCI5xx_PORT_GLOBAL); (unsigned long)eattr->var, CCI5xx_PORT_GLOBAL);
} }
/* /*
...@@ -696,7 +696,7 @@ static ssize_t cci_pmu_format_show(struct device *dev, ...@@ -696,7 +696,7 @@ static ssize_t cci_pmu_format_show(struct device *dev,
{ {
struct dev_ext_attribute *eattr = container_of(attr, struct dev_ext_attribute *eattr = container_of(attr,
struct dev_ext_attribute, attr); struct dev_ext_attribute, attr);
return snprintf(buf, PAGE_SIZE, "%s\n", (char *)eattr->var); return sysfs_emit(buf, "%s\n", (char *)eattr->var);
} }
static ssize_t cci_pmu_event_show(struct device *dev, static ssize_t cci_pmu_event_show(struct device *dev,
...@@ -705,8 +705,8 @@ static ssize_t cci_pmu_event_show(struct device *dev, ...@@ -705,8 +705,8 @@ static ssize_t cci_pmu_event_show(struct device *dev,
struct dev_ext_attribute *eattr = container_of(attr, struct dev_ext_attribute *eattr = container_of(attr,
struct dev_ext_attribute, attr); struct dev_ext_attribute, attr);
/* source parameter is mandatory for normal PMU events */ /* source parameter is mandatory for normal PMU events */
return snprintf(buf, PAGE_SIZE, "source=?,event=0x%lx\n", return sysfs_emit(buf, "source=?,event=0x%lx\n",
(unsigned long)eattr->var); (unsigned long)eattr->var);
} }
static int pmu_is_valid_counter(struct cci_pmu *cci_pmu, int idx) static int pmu_is_valid_counter(struct cci_pmu *cci_pmu, int idx)
......
...@@ -221,7 +221,7 @@ static ssize_t arm_ccn_pmu_format_show(struct device *dev, ...@@ -221,7 +221,7 @@ static ssize_t arm_ccn_pmu_format_show(struct device *dev,
struct dev_ext_attribute *ea = container_of(attr, struct dev_ext_attribute *ea = container_of(attr,
struct dev_ext_attribute, attr); struct dev_ext_attribute, attr);
return snprintf(buf, PAGE_SIZE, "%s\n", (char *)ea->var); return sysfs_emit(buf, "%s\n", (char *)ea->var);
} }
#define CCN_FORMAT_ATTR(_name, _config) \ #define CCN_FORMAT_ATTR(_name, _config) \
...@@ -476,7 +476,7 @@ static ssize_t arm_ccn_pmu_cmp_mask_show(struct device *dev, ...@@ -476,7 +476,7 @@ static ssize_t arm_ccn_pmu_cmp_mask_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));
u64 *mask = arm_ccn_pmu_get_cmp_mask(ccn, attr->attr.name); u64 *mask = arm_ccn_pmu_get_cmp_mask(ccn, attr->attr.name);
return mask ? snprintf(buf, PAGE_SIZE, "0x%016llx\n", *mask) : -EINVAL; return mask ? sysfs_emit(buf, "0x%016llx\n", *mask) : -EINVAL;
} }
static ssize_t arm_ccn_pmu_cmp_mask_store(struct device *dev, static ssize_t arm_ccn_pmu_cmp_mask_store(struct device *dev,
......
...@@ -348,19 +348,19 @@ static ssize_t arm_cmn_event_show(struct device *dev, ...@@ -348,19 +348,19 @@ static ssize_t arm_cmn_event_show(struct device *dev,
eattr = container_of(attr, typeof(*eattr), attr); eattr = container_of(attr, typeof(*eattr), attr);
if (eattr->type == CMN_TYPE_DTC) if (eattr->type == CMN_TYPE_DTC)
return snprintf(buf, PAGE_SIZE, "type=0x%x\n", eattr->type); return sysfs_emit(buf, "type=0x%x\n", eattr->type);
if (eattr->type == CMN_TYPE_WP) if (eattr->type == CMN_TYPE_WP)
return snprintf(buf, PAGE_SIZE, return sysfs_emit(buf,
"type=0x%x,eventid=0x%x,wp_dev_sel=?,wp_chn_sel=?,wp_grp=?,wp_val=?,wp_mask=?\n", "type=0x%x,eventid=0x%x,wp_dev_sel=?,wp_chn_sel=?,wp_grp=?,wp_val=?,wp_mask=?\n",
eattr->type, eattr->eventid); eattr->type, eattr->eventid);
if (arm_cmn_is_occup_event(eattr->type, eattr->eventid)) if (arm_cmn_is_occup_event(eattr->type, eattr->eventid))
return snprintf(buf, PAGE_SIZE, "type=0x%x,eventid=0x%x,occupid=0x%x\n", return sysfs_emit(buf, "type=0x%x,eventid=0x%x,occupid=0x%x\n",
eattr->type, eattr->eventid, eattr->occupid); eattr->type, eattr->eventid, eattr->occupid);
return snprintf(buf, PAGE_SIZE, "type=0x%x,eventid=0x%x\n", return sysfs_emit(buf, "type=0x%x,eventid=0x%x\n", eattr->type,
eattr->type, eattr->eventid); eattr->eventid);
} }
static umode_t arm_cmn_event_attr_is_visible(struct kobject *kobj, static umode_t arm_cmn_event_attr_is_visible(struct kobject *kobj,
...@@ -560,12 +560,12 @@ static ssize_t arm_cmn_format_show(struct device *dev, ...@@ -560,12 +560,12 @@ static ssize_t arm_cmn_format_show(struct device *dev,
int lo = __ffs(fmt->field), hi = __fls(fmt->field); int lo = __ffs(fmt->field), hi = __fls(fmt->field);
if (lo == hi) if (lo == hi)
return snprintf(buf, PAGE_SIZE, "config:%d\n", lo); return sysfs_emit(buf, "config:%d\n", lo);
if (!fmt->config) if (!fmt->config)
return snprintf(buf, PAGE_SIZE, "config:%d-%d\n", lo, hi); return sysfs_emit(buf, "config:%d-%d\n", lo, hi);
return snprintf(buf, PAGE_SIZE, "config%d:%d-%d\n", fmt->config, lo, hi); return sysfs_emit(buf, "config%d:%d-%d\n", fmt->config, lo, hi);
} }
#define _CMN_FORMAT_ATTR(_name, _cfg, _fld) \ #define _CMN_FORMAT_ATTR(_name, _cfg, _fld) \
......
...@@ -136,8 +136,7 @@ static ssize_t dsu_pmu_sysfs_event_show(struct device *dev, ...@@ -136,8 +136,7 @@ static ssize_t dsu_pmu_sysfs_event_show(struct device *dev,
{ {
struct dev_ext_attribute *eattr = container_of(attr, struct dev_ext_attribute *eattr = container_of(attr,
struct dev_ext_attribute, attr); struct dev_ext_attribute, attr);
return snprintf(buf, PAGE_SIZE, "event=0x%lx\n", return sysfs_emit(buf, "event=0x%lx\n", (unsigned long)eattr->var);
(unsigned long)eattr->var);
} }
static ssize_t dsu_pmu_sysfs_format_show(struct device *dev, static ssize_t dsu_pmu_sysfs_format_show(struct device *dev,
...@@ -146,7 +145,7 @@ static ssize_t dsu_pmu_sysfs_format_show(struct device *dev, ...@@ -146,7 +145,7 @@ static ssize_t dsu_pmu_sysfs_format_show(struct device *dev,
{ {
struct dev_ext_attribute *eattr = container_of(attr, struct dev_ext_attribute *eattr = container_of(attr,
struct dev_ext_attribute, attr); struct dev_ext_attribute, attr);
return snprintf(buf, PAGE_SIZE, "%s\n", (char *)eattr->var); return sysfs_emit(buf, "%s\n", (char *)eattr->var);
} }
static ssize_t dsu_pmu_cpumask_show(struct device *dev, static ssize_t dsu_pmu_cpumask_show(struct device *dev,
......
...@@ -560,7 +560,7 @@ static ssize_t smmu_pmu_identifier_attr_show(struct device *dev, ...@@ -560,7 +560,7 @@ static ssize_t smmu_pmu_identifier_attr_show(struct device *dev,
{ {
struct smmu_pmu *smmu_pmu = to_smmu_pmu(dev_get_drvdata(dev)); struct smmu_pmu *smmu_pmu = to_smmu_pmu(dev_get_drvdata(dev));
return snprintf(page, PAGE_SIZE, "0x%08x\n", smmu_pmu->iidr); return sysfs_emit(page, "0x%08x\n", smmu_pmu->iidr);
} }
static umode_t smmu_pmu_identifier_attr_visible(struct kobject *kobj, static umode_t smmu_pmu_identifier_attr_visible(struct kobject *kobj,
......
...@@ -126,8 +126,7 @@ static ssize_t arm_spe_pmu_cap_show(struct device *dev, ...@@ -126,8 +126,7 @@ static ssize_t arm_spe_pmu_cap_show(struct device *dev,
container_of(attr, struct dev_ext_attribute, attr); container_of(attr, struct dev_ext_attribute, attr);
int cap = (long)ea->var; int cap = (long)ea->var;
return snprintf(buf, PAGE_SIZE, "%u\n", return sysfs_emit(buf, "%u\n", arm_spe_pmu_cap_get(spe_pmu, cap));
arm_spe_pmu_cap_get(spe_pmu, cap));
} }
#define SPE_EXT_ATTR_ENTRY(_name, _func, _var) \ #define SPE_EXT_ATTR_ENTRY(_name, _func, _var) \
......
...@@ -170,8 +170,7 @@ static ssize_t ddr_perf_filter_cap_show(struct device *dev, ...@@ -170,8 +170,7 @@ static ssize_t ddr_perf_filter_cap_show(struct device *dev,
container_of(attr, struct dev_ext_attribute, attr); container_of(attr, struct dev_ext_attribute, attr);
int cap = (long)ea->var; int cap = (long)ea->var;
return snprintf(buf, PAGE_SIZE, "%u\n", return sysfs_emit(buf, "%u\n", ddr_perf_filter_cap_get(pmu, cap));
ddr_perf_filter_cap_get(pmu, cap));
} }
#define PERF_EXT_ATTR_ENTRY(_name, _func, _var) \ #define PERF_EXT_ATTR_ENTRY(_name, _func, _var) \
......
...@@ -125,7 +125,7 @@ ssize_t hisi_uncore_pmu_identifier_attr_show(struct device *dev, ...@@ -125,7 +125,7 @@ ssize_t hisi_uncore_pmu_identifier_attr_show(struct device *dev,
{ {
struct hisi_pmu *hisi_pmu = to_hisi_pmu(dev_get_drvdata(dev)); struct hisi_pmu *hisi_pmu = to_hisi_pmu(dev_get_drvdata(dev));
return snprintf(page, PAGE_SIZE, "0x%08x\n", hisi_pmu->identifier); return sysfs_emit(page, "0x%08x\n", hisi_pmu->identifier);
} }
EXPORT_SYMBOL_GPL(hisi_uncore_pmu_identifier_attr_show); EXPORT_SYMBOL_GPL(hisi_uncore_pmu_identifier_attr_show);
......
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