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

 /*
 * 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; }

 
 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值