From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B3741C282D8 for ; Fri, 1 Feb 2019 11:52:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8D98B2080F for ; Fri, 1 Feb 2019 11:52:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730342AbfBALwF (ORCPT ); Fri, 1 Feb 2019 06:52:05 -0500 Received: from cloudserver094114.home.pl ([79.96.170.134]:55967 "EHLO cloudserver094114.home.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726486AbfBALwE (ORCPT ); Fri, 1 Feb 2019 06:52:04 -0500 Received: from 79.184.255.169.ipv4.supernova.orange.pl (79.184.255.169) (HELO aspire.rjw.lan) by serwer1319399.home.pl (79.96.170.134) with SMTP (IdeaSmtpServer 0.83.183) id 53cd322c3c67c8c2; Fri, 1 Feb 2019 12:52:02 +0100 From: "Rafael J. Wysocki" To: "Rafael J. Wysocki" Cc: Linux ACPI , Erik Schmauss , Zhang Rui , LKML Subject: [PATCH v3 5/5] ACPI: EC: Simplify boot EC checks in acpi_ec_add() Date: Fri, 01 Feb 2019 12:50:47 +0100 Message-ID: <2085385.krXRubZqFl@aspire.rjw.lan> In-Reply-To: <1961969.KkQjHZ1Gvm@aspire.rjw.lan> References: <2897234.rJkq6cDEjt@aspire.rjw.lan> <2804781.zocuRj5ZkX@aspire.rjw.lan> <1961969.KkQjHZ1Gvm@aspire.rjw.lan> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Rafael J. Wysocki Subject: [PATCH] ACPI: EC: Simplify boot EC checks in acpi_ec_add() Consolidate boot EC checks in acpi_ec_add(), put the acpi_is_boot_ec() checks directly into it and drop the latter. No intentional functional impact. Signed-off-by: Rafael J. Wysocki --- v2 -> v3: * Drop the is_ecdt local var from acpi_ec_add() and update boot_ec_is_ecdt directly (adding a missing boot_ec_is_ecdt update). * Add dep_update local var to acpi_ec_add() to indicate when dependent devices shouls be re-probed. --- drivers/acpi/ec.c | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) Index: linux-pm/drivers/acpi/ec.c =================================================================== --- linux-pm.orig/drivers/acpi/ec.c +++ linux-pm/drivers/acpi/ec.c @@ -1560,43 +1560,34 @@ static bool acpi_ec_ecdt_get_handle(acpi return true; } -static bool acpi_is_boot_ec(struct acpi_ec *ec) -{ - if (!boot_ec) - return false; - if (ec->command_addr == boot_ec->command_addr && - ec->data_addr == boot_ec->data_addr) - return true; - return false; -} - static int acpi_ec_add(struct acpi_device *device) { struct acpi_ec *ec = NULL; - int ret; - bool is_ecdt = false; + bool dep_update = true; acpi_status status; + int ret; strcpy(acpi_device_name(device), ACPI_EC_DEVICE_NAME); strcpy(acpi_device_class(device), ACPI_EC_CLASS); if (!strcmp(acpi_device_hid(device), ACPI_ECDT_HID)) { - is_ecdt = true; + boot_ec_is_ecdt = true; ec = boot_ec; + dep_update = false; } else { ec = acpi_ec_alloc(); if (!ec) return -ENOMEM; + status = ec_parse_device(device->handle, 0, ec, NULL); if (status != AE_CTRL_TERMINATE) { ret = -EINVAL; goto err_alloc; } - } - if (acpi_is_boot_ec(ec)) { - boot_ec_is_ecdt = is_ecdt; - if (!is_ecdt) { + if (boot_ec && ec->command_addr == boot_ec->command_addr && + ec->data_addr == boot_ec->data_addr) { + boot_ec_is_ecdt = false; /* * Trust PNP0C09 namespace location rather than * ECDT ID. But trust ECDT GPE rather than _GPE @@ -1617,7 +1608,7 @@ static int acpi_ec_add(struct acpi_devic if (ec == boot_ec) acpi_handle_info(boot_ec->handle, "Boot %s EC used to handle transactions and events\n", - is_ecdt ? "ECDT" : "DSDT"); + boot_ec_is_ecdt ? "ECDT" : "DSDT"); device->driver_data = ec; @@ -1626,7 +1617,7 @@ static int acpi_ec_add(struct acpi_devic ret = !!request_region(ec->command_addr, 1, "EC cmd"); WARN(!ret, "Could not request EC cmd io port 0x%lx", ec->command_addr); - if (!is_ecdt) { + if (dep_update) { /* Reprobe devices depending on the EC */ acpi_walk_dep_device_list(ec->handle); }