用acpi_device_hid 可以的到device的hid,如下所示:
static int acpi_processor_get_info(struct acpi_device *device)
{
//这里的#define ACPI_PROCESSOR_OBJECT_HID "LNXCPU"
if (!strcmp(acpi_device_hid(device), ACPI_PROCESSOR_OBJECT_HID)) {
/* Declared with "Processor" statement; match ProcessorID */
status = acpi_evaluate_object(pr->handle, NULL, NULL, &buffer);
if (ACPI_FAILURE(status)) {
dev_err(&device->dev,
"Failed to evaluate processor object (0x%x)\n",
status);
return -ENODEV;
}
}
}
可见acpi_device_hid 是从device->pnp.ids这个list中拿到device的hid的
const char *acpi_device_hid(struct acpi_device *device)
{
struct acpi_hardware_id *hid;
if (list_empty(&device->pnp.ids))
return dummy_hid;
hid = list_first_entry(&device->pnp.ids, struct acpi_hardware_id, list);
return hid->id;
}
而这个device->pnp.ids 是在acpi_init_device_object 中初始化
void acpi_init_device_object(struct acpi_device *device, acpi_handle handle,
int type, unsigned long long sta)
{
INIT_LIST_HEAD(&device->pnp.ids);
//通过acpi_set_pnp_ids ->acpi_add_id 将hid添加到pnp.ids
acpi_set_pnp_ids(handle, &device->pnp, type);
}
可以看到是将hid添加到id添加的pnp->ids
static void acpi_add_id(struct acpi_device_pnp *pnp, const char *dev_id)
{
struct acpi_hardware_id *id;
id = kmalloc(sizeof(*id), GFP_KERNEL);
if (!id)
return;
id->id = kstrdup_const(dev_id, GFP_KERNEL);
if (!id->id) {
kfree(id);
return;
}
list_add_tail(&id->list, &pnp->ids);
pnp->type.hardware_id = 1;
}
通过acpi_device_hid 得到device的HID
最新推荐文章于 2024-03-22 13:38:01 发布
本文详细介绍了ACPI框架中设备硬件ID(HID)的获取过程,包括acpi_device_hid函数的具体实现,以及hid如何在acpi_init_device_object初始化过程中被添加到device的pnp.ids列表中。
摘要由CSDN通过智能技术生成