]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
perf/arm-cmn: Improve format attr printing
authorRobin Murphy <robin.murphy@arm.com>
Wed, 4 Sep 2024 18:41:55 +0000 (19:41 +0100)
committerWill Deacon <will@kernel.org>
Fri, 6 Sep 2024 11:58:06 +0000 (12:58 +0100)
Take full advantage of our formats being stored in bitfield form, and
make the printing even more robust and simple by letting printk do all
the hard work of formatting bitlists.

Signed-off-by: Robin Murphy <robin.murphy@arm.com>
Reviewed-by: Ilkka Koskinen <ilkka@os.amperecomputing.com>
Link: https://lore.kernel.org/r/50459f2d48fc62310a566863dbf8a7c14361d363.1725474584.git.robin.murphy@arm.com
Signed-off-by: Will Deacon <will@kernel.org>
drivers/perf/arm-cmn.c

index 62d4782da7e48cc916ac0a016d71f07fcfc1645e..397a46410f7cb785d645b986518cb4affb0e1b68 100644 (file)
@@ -1280,15 +1280,11 @@ static ssize_t arm_cmn_format_show(struct device *dev,
                                   struct device_attribute *attr, char *buf)
 {
        struct arm_cmn_format_attr *fmt = container_of(attr, typeof(*fmt), attr);
-       int lo = __ffs(fmt->field), hi = __fls(fmt->field);
-
-       if (lo == hi)
-               return sysfs_emit(buf, "config:%d\n", lo);
 
        if (!fmt->config)
-               return sysfs_emit(buf, "config:%d-%d\n", lo, hi);
+               return sysfs_emit(buf, "config:%*pbl\n", 64, &fmt->field);
 
-       return sysfs_emit(buf, "config%d:%d-%d\n", fmt->config, lo, hi);
+       return sysfs_emit(buf, "config%d:%*pbl\n", fmt->config, 64, &fmt->field);
 }
 
 #define _CMN_FORMAT_ATTR(_name, _cfg, _fld)                            \