Re: [PATCH 5/6] platform/chrome: cros_ec_lpc: Correct ACPI name for Framework Laptop

From: Tzung-Bi Shih
Date: Mon May 20 2024 - 05:47:41 EST


On Wed, May 15, 2024 at 06:56:30AM +0100, Ben Walsh wrote:
> Framework Laptops' ACPI exposes the EC as name "PNP0C09". Use this to
> find the device. This makes it easy to find the AML mutex via the
> ACPI_COMPANION device.
>
> The name "PNP0C09" is part of the ACPI standard, not Chrome-specific,
> so only recognise the device if the DMI data is recognised too.

I don't quite understand the statement. Why it needs DMI data?

> diff --git a/drivers/platform/chrome/cros_ec_lpc.c b/drivers/platform/chrome/cros_ec_lpc.c
[...]
> -/* True if ACPI device is present */
> -static bool cros_ec_lpc_acpi_device_found;
> +/*
> + * Index into cros_ec_lpc_acpi_device_ids of ACPI device,
> + * negative for ACPI device not found.
> + */
> +static int cros_ec_lpc_acpi_device_found;

Rename it to `cros_ec_lpc_acpi_device_index` for clarity?

> static int __init cros_ec_lpc_init(void)
> {
> int ret;
> - acpi_status status;
> const struct dmi_system_id *dmi_match;
>
> - status = acpi_get_devices(ACPI_DRV_NAME, cros_ec_lpc_parse_device,
> - &cros_ec_lpc_acpi_device_found, NULL);
> - if (ACPI_FAILURE(status))
> - pr_warn(DRV_NAME ": Looking for %s failed\n", ACPI_DRV_NAME);
> + cros_ec_lpc_acpi_device_found = cros_ec_lpc_find_acpi_dev(
> + cros_ec_lpc_driver.driver.acpi_match_table);

Or just use `cros_ec_lpc_acpi_device_ids`.

> - } else if (!cros_ec_lpc_acpi_device_found) {
> + } else if (cros_ec_lpc_acpi_device_found <= 0) {
> + /* Standard EC "PNP0C09" not supported without DMI data */

Asked the same question above, why PNP0C09 needs DMI data? Also the way is
a bit confusing as "PNP0C09" must be at index 0 in the acpi_device_id.