先匹配DSDT 表格中的HID,如果不匹配,再匹配CID ,这样可以解决兼容性问题

设备的信息都是通过ACPI的DSDT表传递给kernel的
int __init acpi_ec_dsdt_probe(void)
{
    acpi_status status;
    struct acpi_ec *ec;
    int ret;

    /*
     * If a platform has ECDT, there is no need to proceed as the
     * following probe is not a part of the ACPI device enumeration,
     * executing _STA is not safe, and thus this probe may risk of
     * picking up an invalid EC device.
     */
    if (boot_ec)
        return -ENODEV;

    ec = acpi_ec_alloc();
    if (!ec)
        return -ENOMEM;

这里调用acpi_get_devices 来得到device信息
    status = acpi_get_devices(ec_device_ids[0].id,
                  ec_parse_device, ec, NULL);
    if (ACPI_FAILURE(status) || !ec->handle) {
        ret = -ENODEV;
        goto error;
    }
}

acpi_status
acpi_get_devices(const char *HID,
         acpi_walk_callback user_function,
         void *context, void **return_value)
{
    acpi_status status;
    struct acpi_get_devices_info info;

    ACPI_FUNCTION_TRACE(acpi_get_devices);

    /* Parameter validation */

    if (!user_function) {
        return_ACPI_STATUS(AE_BAD_PARAMETER);
    }

    /*
     * We're going to call their callback from OUR callback, so we need
     * to know what it is, and their context parameter.
     */
    info.hid = HID;
    info.context = context;
    info.user_function = user_function;

    
当找到device时调用acpi_ns_get_device_callback
    status = acpi_ns_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
                    ACPI_UINT32_MAX, ACPI_NS_WALK_UNLOCK,
                    acpi_ns_get_device_callback, NULL,
                    &info, return_value);
}

static acpi_status
acpi_ns_get_device_callback(acpi_handle obj_handle,
                u32 nesting_level,
                void *context, void **return_value)
{
核心代码如下:先匹配dsdt表格中的HID信息,如果HID不匹配的话,在匹配CID信息
    if (info->hid != NULL) {
        status = acpi_ut_execute_HID(node, &hid);
        if (status == AE_NOT_FOUND) {
            return (AE_OK);
        } else if (ACPI_FAILURE(status)) {
            return (AE_CTRL_DEPTH);
        }

        no_match = strcmp(hid->string, info->hid);
        ACPI_FREE(hid);

        if (no_match) {
            /*
             * HID does not match, attempt match within the
             * list of Compatible IDs (CIDs)
             */
            status = acpi_ut_execute_CID(node, &cid);
            if (status == AE_NOT_FOUND) {
                return (AE_OK);
            } else if (ACPI_FAILURE(status)) {
                return (AE_CTRL_DEPTH);
            }

            /* Walk the CID list */

            found = FALSE;
            for (i = 0; i < cid->count; i++) {
                if (strcmp(cid->ids[i].string, info->hid) == 0) {

                    /* Found a matching CID */

                    found = TRUE;
                    break;
                }
            }

            ACPI_FREE(cid);
            if (!found) {
                return (AE_OK);
            }
        }
    }

    
}


  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值