Skip to content

Commit 2885e25

Browse files
committed
driver core: cpu: remove kernel warning when removing a cpu
With the movement of the cpu sysdev code to be real stuct devices, now when we remove a cpu from the system, the driver core rightfully complains that there is not a release method for this device. For now, paper over this issue by quieting the driver core, but comment this in detail. This will be resolved in future kernels to be solved properly. Reported-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> Tested-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 62aa2b5 commit 2885e25

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

‎drivers/base/cpu.c‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,25 @@ static ssize_t print_cpus_offline(struct device *dev,
208208
}
209209
static DEVICE_ATTR(offline, 0444, print_cpus_offline, NULL);
210210

211+
static void cpu_device_release(struct device *dev)
212+
{
213+
/*
214+
* This is an empty function to prevent the driver core from spitting a
215+
* warning at us. Yes, I know this is directly opposite of what the
216+
* documentation for the driver core and kobjects say, and the author
217+
* of this code has already been publically ridiculed for doing
218+
* something as foolish as this. However, at this point in time, it is
219+
* the only way to handle the issue of statically allocated cpu
220+
* devices. The different architectures will have their cpu device
221+
* code reworked to properly handle this in the near future, so this
222+
* function will then be changed to correctly free up the memory held
223+
* by the cpu device.
224+
*
225+
* Never copy this way of doing things, or you too will be made fun of
226+
* on the linux-kerenl list, you have been warned.
227+
*/
228+
}
229+
211230
/*
212231
* register_cpu - Setup a sysfs device for a CPU.
213232
* @cpu - cpu->hotpluggable field set to 1 will generate a control file in
@@ -223,6 +242,7 @@ int __cpuinit register_cpu(struct cpu *cpu, int num)
223242
cpu->node_id = cpu_to_node(num);
224243
cpu->dev.id = num;
225244
cpu->dev.bus = &cpu_subsys;
245+
cpu->dev.release = cpu_device_release;
226246
error = device_register(&cpu->dev);
227247
if (!error && cpu->hotpluggable)
228248
register_cpu_control(cpu);

0 commit comments

Comments
 (0)