Skip to content

Commit

Permalink
topology/sysfs: Add format parameter to macro defining "show" functio…
Browse files Browse the repository at this point in the history
…ns 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]
  • Loading branch information
aegl authored and suryasaimadhu committed Feb 1, 2022
1 parent 822ccfa commit 182ecfa
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions drivers/base/topology.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
#include <linux/hardirq.h>
#include <linux/topology.h>

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

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

define_id_show_func(physical_package_id);
define_id_show_func(physical_package_id, "%d");
static DEVICE_ATTR_RO(physical_package_id);

#ifdef TOPOLOGY_DIE_SYSFS
define_id_show_func(die_id);
define_id_show_func(die_id, "%d");
static DEVICE_ATTR_RO(die_id);
#endif

#ifdef TOPOLOGY_CLUSTER_SYSFS
define_id_show_func(cluster_id);
define_id_show_func(cluster_id, "%d");
static DEVICE_ATTR_RO(cluster_id);
#endif

define_id_show_func(core_id);
define_id_show_func(core_id, "%d");
static DEVICE_ATTR_RO(core_id);

define_siblings_read_func(thread_siblings, sibling_cpumask);
Expand Down Expand Up @@ -87,15 +87,15 @@ static BIN_ATTR_RO(package_cpus, 0);
static BIN_ATTR_RO(package_cpus_list, 0);

#ifdef TOPOLOGY_BOOK_SYSFS
define_id_show_func(book_id);
define_id_show_func(book_id, "%d");
static DEVICE_ATTR_RO(book_id);
define_siblings_read_func(book_siblings, book_cpumask);
static BIN_ATTR_RO(book_siblings, 0);
static BIN_ATTR_RO(book_siblings_list, 0);
#endif

#ifdef TOPOLOGY_DRAWER_SYSFS
define_id_show_func(drawer_id);
define_id_show_func(drawer_id, "%d");
static DEVICE_ATTR_RO(drawer_id);
define_siblings_read_func(drawer_siblings, drawer_cpumask);
static BIN_ATTR_RO(drawer_siblings, 0);
Expand Down

0 comments on commit 182ecfa

Please sign in to comment.