Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <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>

authored by

Robin Murphy and committed by
Will Deacon
f32efa3e f04b611e

+2 -6
+2 -6
drivers/perf/arm-cmn.c
··· 1280 1280 struct device_attribute *attr, char *buf) 1281 1281 { 1282 1282 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); 1287 1283 1288 1284 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); 1290 1286 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); 1292 1288 } 1293 1289 1294 1290 #define _CMN_FORMAT_ATTR(_name, _cfg, _fld) \