2021-05-28 05:26:28

by Yue Haibing

[permalink] [raw]
Subject: [PATCH -next] perf: arm_spe: use DEVICE_ATTR_RO macro

Use DEVICE_ATTR_RO() helper instead of plain DEVICE_ATTR(),
which makes the code a bit shorter and easier to read.

Signed-off-by: YueHaibing <[email protected]>
---
drivers/perf/arm_spe_pmu.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/perf/arm_spe_pmu.c b/drivers/perf/arm_spe_pmu.c
index e3711cb4c1b5..773285dd539f 100644
--- a/drivers/perf/arm_spe_pmu.c
+++ b/drivers/perf/arm_spe_pmu.c
@@ -231,15 +231,14 @@ static const struct attribute_group arm_spe_pmu_format_group = {
.attrs = arm_spe_pmu_formats_attr,
};

-static ssize_t arm_spe_pmu_get_attr_cpumask(struct device *dev,
- struct device_attribute *attr,
- char *buf)
+static ssize_t cpumask_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
{
struct arm_spe_pmu *spe_pmu = dev_get_drvdata(dev);

return cpumap_print_to_pagebuf(true, buf, &spe_pmu->supported_cpus);
}
-static DEVICE_ATTR(cpumask, S_IRUGO, arm_spe_pmu_get_attr_cpumask, NULL);
+static DEVICE_ATTR(cpumask);

static struct attribute *arm_spe_pmu_attrs[] = {
&dev_attr_cpumask.attr,
--
2.17.1


2021-05-28 06:22:46

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH -next] perf: arm_spe: use DEVICE_ATTR_RO macro

Hi YueHaibing,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on next-20210527]

url: https://github.com/0day-ci/linux/commits/YueHaibing/perf-arm_spe-use-DEVICE_ATTR_RO-macro/20210528-094415
base: d975636c274169a218816c8e69d8215fd6a11791
config: arm64-allyesconfig (attached as .config)
compiler: aarch64-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/9fda522df9dfbcdccbe387fe3fb1d016efd33842
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review YueHaibing/perf-arm_spe-use-DEVICE_ATTR_RO-macro/20210528-094415
git checkout 9fda522df9dfbcdccbe387fe3fb1d016efd33842
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=arm64

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <[email protected]>

All errors (new ones prefixed by >>):

>> drivers/perf/arm_spe_pmu.c:241:27: error: macro "DEVICE_ATTR" requires 4 arguments, but only 1 given
241 | static DEVICE_ATTR(cpumask);
| ^
In file included from drivers/perf/arm_spe_pmu.c:20:
include/linux/device.h:125: note: macro "DEVICE_ATTR" defined here
125 | #define DEVICE_ATTR(_name, _mode, _show, _store) \
|
>> drivers/perf/arm_spe_pmu.c:241:8: error: type defaults to 'int' in declaration of 'DEVICE_ATTR' [-Werror=implicit-int]
241 | static DEVICE_ATTR(cpumask);
| ^~~~~~~~~~~
>> drivers/perf/arm_spe_pmu.c:244:3: error: 'dev_attr_cpumask' undeclared here (not in a function)
244 | &dev_attr_cpumask.attr,
| ^~~~~~~~~~~~~~~~
drivers/perf/arm_spe_pmu.c:241:8: warning: 'DEVICE_ATTR' defined but not used [-Wunused-variable]
241 | static DEVICE_ATTR(cpumask);
| ^~~~~~~~~~~
drivers/perf/arm_spe_pmu.c:234:16: warning: 'cpumask_show' defined but not used [-Wunused-function]
234 | static ssize_t cpumask_show(struct device *dev,
| ^~~~~~~~~~~~
cc1: some warnings being treated as errors


vim +/DEVICE_ATTR +241 drivers/perf/arm_spe_pmu.c

233
234 static ssize_t cpumask_show(struct device *dev,
235 struct device_attribute *attr, char *buf)
236 {
237 struct arm_spe_pmu *spe_pmu = dev_get_drvdata(dev);
238
239 return cpumap_print_to_pagebuf(true, buf, &spe_pmu->supported_cpus);
240 }
> 241 static DEVICE_ATTR(cpumask);
242
243 static struct attribute *arm_spe_pmu_attrs[] = {
> 244 &dev_attr_cpumask.attr,
245 NULL,
246 };
247

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]


Attachments:
(No filename) (2.92 kB)
.config.gz (76.14 kB)
Download all attachments