您的位置:首页 > 运维架构 > Linux

Linux Kernel设备驱动模型之CPU接口注册

2017-03-25 13:49 423 查看
 /*
 * register_cpu - Setup a sysfs device for a CPU.
 * @cpu - cpu->hotpluggable field set to 1 will generate a control file in
 *   sysfs for this CPU.
 * @num - CPU number to use when creating the device.
 *
 * Initialize and register the CPU device.
 */
int register_cpu(struct cpu *cpu, int num)
{
 int error;

 cpu->node_id = cpu_to_node(num);
 memset(&cpu->dev, 0x00, sizeof(struct device));
 cpu->dev.id = num;
 cpu->dev.bus = &cpu_subsys;
 cpu->dev.release = cpu_device_release;
 cpu->dev.offline_disabled = !cpu->hotpluggable;
 cpu->dev.offline = !cpu_online(num);
 cpu->dev.of_node = of_get_cpu_node(num, NULL);
#ifdef CONFIG_GENERIC_CPU_AUTOPROBE
 cpu->dev.bus->uevent = cpu_uevent;
#endif
 cpu->dev.groups = common_cpu_attr_groups;
 if (cpu->hotpluggable)
  cpu->dev.groups = hotplugable_cpu_attr_groups;
 error = device_register(&cpu->dev);
 if (error)
  return error;
 per_cpu(cpu_sys_devices, num) = &cpu->dev;
 register_cpu_under_node(num, cpu_to_node(num));
 return 0;
}

 

 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: