Skip to content

Commit 182ecfa

Browse files
aeglsuryasaimadhu
authored andcommitted
topology/sysfs: Add format parameter to macro defining "show" functions for proc
All the simple (non-mask and non-list files in /sys/devices/system/cpu/cpu0/topology/ are currently printed as decimal integers. Refactor the macro that generates the "show" functions to take a format parameter to allow future files to display in other formats. No functional change. Signed-off-by: Tony Luck <[email protected]> Signed-off-by: Borislav Petkov <[email protected]> Acked-by: Greg Kroah-Hartman <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 822ccfa commit 182ecfa

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

drivers/base/topology.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414
#include <linux/hardirq.h>
1515
#include <linux/topology.h>
1616

17-
#define define_id_show_func(name) \
17+
#define define_id_show_func(name, fmt) \
1818
static ssize_t name##_show(struct device *dev, \
1919
struct device_attribute *attr, char *buf) \
2020
{ \
21-
return sysfs_emit(buf, "%d\n", topology_##name(dev->id)); \
21+
return sysfs_emit(buf, fmt "\n", topology_##name(dev->id)); \
2222
}
2323

2424
#define define_siblings_read_func(name, mask) \
@@ -42,20 +42,20 @@ static ssize_t name##_list_read(struct file *file, struct kobject *kobj, \
4242
off, count); \
4343
}
4444

45-
define_id_show_func(physical_package_id);
45+
define_id_show_func(physical_package_id, "%d");
4646
static DEVICE_ATTR_RO(physical_package_id);
4747

4848
#ifdef TOPOLOGY_DIE_SYSFS
49-
define_id_show_func(die_id);
49+
define_id_show_func(die_id, "%d");
5050
static DEVICE_ATTR_RO(die_id);
5151
#endif
5252

5353
#ifdef TOPOLOGY_CLUSTER_SYSFS
54-
define_id_show_func(cluster_id);
54+
define_id_show_func(cluster_id, "%d");
5555
static DEVICE_ATTR_RO(cluster_id);
5656
#endif
5757

58-
define_id_show_func(core_id);
58+
define_id_show_func(core_id, "%d");
5959
static DEVICE_ATTR_RO(core_id);
6060

6161
define_siblings_read_func(thread_siblings, sibling_cpumask);
@@ -87,15 +87,15 @@ static BIN_ATTR_RO(package_cpus, 0);
8787
static BIN_ATTR_RO(package_cpus_list, 0);
8888

8989
#ifdef TOPOLOGY_BOOK_SYSFS
90-
define_id_show_func(book_id);
90+
define_id_show_func(book_id, "%d");
9191
static DEVICE_ATTR_RO(book_id);
9292
define_siblings_read_func(book_siblings, book_cpumask);
9393
static BIN_ATTR_RO(book_siblings, 0);
9494
static BIN_ATTR_RO(book_siblings_list, 0);
9595
#endif
9696

9797
#ifdef TOPOLOGY_DRAWER_SYSFS
98-
define_id_show_func(drawer_id);
98+
define_id_show_func(drawer_id, "%d");
9999
static DEVICE_ATTR_RO(drawer_id);
100100
define_siblings_read_func(drawer_siblings, drawer_cpumask);
101101
static BIN_ATTR_RO(drawer_siblings, 0);

0 commit comments

Comments
 (0)