OSDN Git Service

ACPI: EC: Simplify acpi_ec_add()
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Mon, 2 Mar 2020 10:25:13 +0000 (11:25 +0100)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Mon, 2 Mar 2020 10:25:13 +0000 (11:25 +0100)
commite3cfabcd736a00c61c3a5ee322186b30c642993a
treebbda6ddb147ef09d247ba05790a1a3258ca07591
parent7247f0c24c17a46a9732a801e57b627fb6bbf294
ACPI: EC: Simplify acpi_ec_add()

First, notice that if the device ID in acpi_ec_add() is equal to
ACPI_ECDT_HID, boot_ec_is_ecdt must be set, because this means
that the device object passed to acpi_ec_add() comes from
acpi_ec_ecdt_start() which fails if boot_ec_is_ecdt is unset.
Accordingly, boot_ec_is_ecdt need not be set again in that case,
so drop that redundant update of it from the code.

Next, ec->handle must be a valid ACPI handle right before
returning 0 from acpi_ec_add(), because it either is the handle
of the device object passed to that function, or it is the boot EC
handle coming from acpi_ec_ecdt_start() which fails if it cannot
find a valid handle for the boot EC.  Moreover, the object with
that handle is regarded as a valid representation of the EC in all
cases, so there is no reason to avoid the _DEP list update walk if
that handle is the boot EC handle.  Accordingly, drop the dep_update
local variable from acpi_ec_add() and call acpi_walk_dep_device_list()
for ec->handle unconditionally before returning 0 from it.

Finally, the ec local variable in acpi_ec_add() need not be
initialized to NULL and the status local variable declaration
can be moved to the block in which it is used, so change the code
in accordance with these observations.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/acpi/ec.c