aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base/topology.c
diff options
context:
space:
mode:
authorSebastian Andrzej Siewior <bigeasy@linutronix.de>2016-11-03 10:50:09 -0400
committerThomas Gleixner <tglx@linutronix.de>2016-11-09 17:45:29 -0500
commit38643a0e691ec947d311eb2db011b289cf95014e (patch)
tree75da9db4a7df9888bededf782d535b254906c9c5 /drivers/base/topology.c
parent7cc277b489b4fe91f42eb596b282879c2d13152e (diff)
drivers base/topology: Convert to hotplug state machine
Install the callbacks via the state machine and let the core invoke the callbacks on the already online CPUs. No functional change Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: rt@linutronix.de Link: http://lkml.kernel.org/r/20161103145021.28528-14-bigeasy@linutronix.de Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'drivers/base/topology.c')
-rw-r--r--drivers/base/topology.c42
1 files changed, 5 insertions, 37 deletions
diff --git a/drivers/base/topology.c b/drivers/base/topology.c
index df3c97cb4c99..d6ec1c546f5b 100644
--- a/drivers/base/topology.c
+++ b/drivers/base/topology.c
@@ -118,51 +118,19 @@ static int topology_add_dev(unsigned int cpu)
118 return sysfs_create_group(&dev->kobj, &topology_attr_group); 118 return sysfs_create_group(&dev->kobj, &topology_attr_group);
119} 119}
120 120
121static void topology_remove_dev(unsigned int cpu) 121static int topology_remove_dev(unsigned int cpu)
122{ 122{
123 struct device *dev = get_cpu_device(cpu); 123 struct device *dev = get_cpu_device(cpu);
124 124
125 sysfs_remove_group(&dev->kobj, &topology_attr_group); 125 sysfs_remove_group(&dev->kobj, &topology_attr_group);
126} 126 return 0;
127
128static int topology_cpu_callback(struct notifier_block *nfb,
129 unsigned long action, void *hcpu)
130{
131 unsigned int cpu = (unsigned long)hcpu;
132 int rc = 0;
133
134 switch (action) {
135 case CPU_UP_PREPARE:
136 case CPU_UP_PREPARE_FROZEN:
137 rc = topology_add_dev(cpu);
138 break;
139 case CPU_UP_CANCELED:
140 case CPU_UP_CANCELED_FROZEN:
141 case CPU_DEAD:
142 case CPU_DEAD_FROZEN:
143 topology_remove_dev(cpu);
144 break;
145 }
146 return notifier_from_errno(rc);
147} 127}
148 128
149static int topology_sysfs_init(void) 129static int topology_sysfs_init(void)
150{ 130{
151 int cpu; 131 return cpuhp_setup_state(CPUHP_TOPOLOGY_PREPARE,
152 int rc = 0; 132 "base/topology:prepare", topology_add_dev,
153 133 topology_remove_dev);
154 cpu_notifier_register_begin();
155
156 for_each_online_cpu(cpu) {
157 rc = topology_add_dev(cpu);
158 if (rc)
159 goto out;
160 }
161 __hotcpu_notifier(topology_cpu_callback, 0);
162
163out:
164 cpu_notifier_register_done();
165 return rc;
166} 134}
167 135
168device_initcall(topology_sysfs_init); 136device_initcall(topology_sysfs_init);