aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base/topology.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/base/topology.c')
-rw-r--r--drivers/base/topology.c57
1 files changed, 29 insertions, 28 deletions
diff --git a/drivers/base/topology.c b/drivers/base/topology.c
index fdf4044d2e74..3f6d9b0a6abe 100644
--- a/drivers/base/topology.c
+++ b/drivers/base/topology.c
@@ -40,6 +40,7 @@ static ssize_t show_##name(struct sys_device *dev, char *buf) \
40 return sprintf(buf, "%d\n", topology_##name(cpu)); \ 40 return sprintf(buf, "%d\n", topology_##name(cpu)); \
41} 41}
42 42
43#if defined(topology_thread_siblings) || defined(topology_core_siblings)
43static ssize_t show_cpumap(int type, cpumask_t *mask, char *buf) 44static ssize_t show_cpumap(int type, cpumask_t *mask, char *buf)
44{ 45{
45 ptrdiff_t len = PTR_ALIGN(buf + PAGE_SIZE - 1, PAGE_SIZE) - buf; 46 ptrdiff_t len = PTR_ALIGN(buf + PAGE_SIZE - 1, PAGE_SIZE) - buf;
@@ -54,65 +55,65 @@ static ssize_t show_cpumap(int type, cpumask_t *mask, char *buf)
54 } 55 }
55 return n; 56 return n;
56} 57}
58#endif
57 59
60#ifdef arch_provides_topology_pointers
58#define define_siblings_show_map(name) \ 61#define define_siblings_show_map(name) \
59static inline ssize_t show_##name(struct sys_device *dev, char *buf) \ 62static ssize_t show_##name(struct sys_device *dev, char *buf) \
60{ \ 63{ \
61 unsigned int cpu = dev->id; \ 64 unsigned int cpu = dev->id; \
62 return show_cpumap(0, &(topology_##name(cpu)), buf); \ 65 return show_cpumap(0, &(topology_##name(cpu)), buf); \
63} 66}
64 67
65#define define_siblings_show_list(name) \ 68#define define_siblings_show_list(name) \
66static inline ssize_t show_##name##_list(struct sys_device *dev, char *buf) \ 69static ssize_t show_##name##_list(struct sys_device *dev, char *buf) \
67{ \ 70{ \
68 unsigned int cpu = dev->id; \ 71 unsigned int cpu = dev->id; \
69 return show_cpumap(1, &(topology_##name(cpu)), buf); \ 72 return show_cpumap(1, &(topology_##name(cpu)), buf); \
70} 73}
71 74
75#else
76#define define_siblings_show_map(name) \
77static ssize_t show_##name(struct sys_device *dev, char *buf) \
78{ \
79 unsigned int cpu = dev->id; \
80 cpumask_t mask = topology_##name(cpu); \
81 return show_cpumap(0, &mask, buf); \
82}
83
84#define define_siblings_show_list(name) \
85static ssize_t show_##name##_list(struct sys_device *dev, char *buf) \
86{ \
87 unsigned int cpu = dev->id; \
88 cpumask_t mask = topology_##name(cpu); \
89 return show_cpumap(1, &mask, buf); \
90}
91#endif
92
72#define define_siblings_show_func(name) \ 93#define define_siblings_show_func(name) \
73 define_siblings_show_map(name); define_siblings_show_list(name) 94 define_siblings_show_map(name); define_siblings_show_list(name)
74 95
75#ifdef topology_physical_package_id
76define_id_show_func(physical_package_id); 96define_id_show_func(physical_package_id);
77define_one_ro(physical_package_id); 97define_one_ro(physical_package_id);
78#define ref_physical_package_id_attr &attr_physical_package_id.attr,
79#else
80#define ref_physical_package_id_attr
81#endif
82 98
83#ifdef topology_core_id
84define_id_show_func(core_id); 99define_id_show_func(core_id);
85define_one_ro(core_id); 100define_one_ro(core_id);
86#define ref_core_id_attr &attr_core_id.attr,
87#else
88#define ref_core_id_attr
89#endif
90 101
91#ifdef topology_thread_siblings
92define_siblings_show_func(thread_siblings); 102define_siblings_show_func(thread_siblings);
93define_one_ro(thread_siblings); 103define_one_ro(thread_siblings);
94define_one_ro(thread_siblings_list); 104define_one_ro(thread_siblings_list);
95#define ref_thread_siblings_attr \
96 &attr_thread_siblings.attr, &attr_thread_siblings_list.attr,
97#else
98#define ref_thread_siblings_attr
99#endif
100 105
101#ifdef topology_core_siblings
102define_siblings_show_func(core_siblings); 106define_siblings_show_func(core_siblings);
103define_one_ro(core_siblings); 107define_one_ro(core_siblings);
104define_one_ro(core_siblings_list); 108define_one_ro(core_siblings_list);
105#define ref_core_siblings_attr \
106 &attr_core_siblings.attr, &attr_core_siblings_list.attr,
107#else
108#define ref_core_siblings_attr
109#endif
110 109
111static struct attribute *default_attrs[] = { 110static struct attribute *default_attrs[] = {
112 ref_physical_package_id_attr 111 &attr_physical_package_id.attr,
113 ref_core_id_attr 112 &attr_core_id.attr,
114 ref_thread_siblings_attr 113 &attr_thread_siblings.attr,
115 ref_core_siblings_attr 114 &attr_thread_siblings_list.attr,
115 &attr_core_siblings.attr,
116 &attr_core_siblings_list.attr,
116 NULL 117 NULL
117}; 118};
118 119