Skip to content

Commit f32efa3

Browse files
rmurphy-armwilldeacon
authored andcommitted
perf/arm-cmn: Improve format attr printing
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 <[email protected]> Reviewed-by: Ilkka Koskinen <[email protected]> Link: https://lore.kernel.org/r/50459f2d48fc62310a566863dbf8a7c14361d363.1725474584.git.robin.murphy@arm.com Signed-off-by: Will Deacon <[email protected]>
1 parent f04b611 commit f32efa3

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

drivers/perf/arm-cmn.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1280,15 +1280,11 @@ static ssize_t arm_cmn_format_show(struct device *dev,
12801280
struct device_attribute *attr, char *buf)
12811281
{
12821282
struct arm_cmn_format_attr *fmt = container_of(attr, typeof(*fmt), attr);
1283-
int lo = __ffs(fmt->field), hi = __fls(fmt->field);
1284-
1285-
if (lo == hi)
1286-
return sysfs_emit(buf, "config:%d\n", lo);
12871283

12881284
if (!fmt->config)
1289-
return sysfs_emit(buf, "config:%d-%d\n", lo, hi);
1285+
return sysfs_emit(buf, "config:%*pbl\n", 64, &fmt->field);
12901286

1291-
return sysfs_emit(buf, "config%d:%d-%d\n", fmt->config, lo, hi);
1287+
return sysfs_emit(buf, "config%d:%*pbl\n", fmt->config, 64, &fmt->field);
12921288
}
12931289

12941290
#define _CMN_FORMAT_ATTR(_name, _cfg, _fld) \

0 commit comments

Comments
 (0)