Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp4381440ybf; Wed, 4 Mar 2020 02:53:44 -0800 (PST) X-Google-Smtp-Source: ADFU+vsI2c9QuCEpXcouoxbm7W48+irbEXMwr8LdarddnWdEsfkOB6cpi0dFv889J8WLDR2hwDos X-Received: by 2002:a9d:dc1:: with SMTP id 59mr1829492ots.250.1583319224536; Wed, 04 Mar 2020 02:53:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583319224; cv=none; d=google.com; s=arc-20160816; b=mfEy2jtOigl7kHbLEDrDeeA9uo3Ry0lpWZrR5ikutDxv7aM2mzWOAG73iIiecj2Y9m fH1cPQl8dofGaV11V9jKSpM9XOq9Jnu808RE1LVzvcH1PV8pMMggjkPP4W3/orw6Vz3X Y/2WuI29F7ozdTPZWlKqSODW100pkwPhSK6IhXFhOa9mtNa58x/Orm/hAgQmbSefSKkb 38QUn4sfuypeDBKPNqr1ZgZIA6Rs8MeLgCw3aflrG2+yTgSnQFz4+4lBHJf7t2/fuRMJ y+SL5G8Y/2T9m5PKSH9B/1CTt1Thfczd0Q20YpAJgZN8u47J/mdYSbLmQpzwf/mf9B50 oloA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=XGDhibOI5uYUCAn06dHBl5WSGMiFmDmWbWu22CvOLkk=; b=jufpzVmJhpx62Yo29Xjv7J9229RKAhaLXp5Xdu9UdaaERCk8G6eER7WuGAMDboF/Tg mgEj1K7OIOO4tCRnfpWsPh5vefTNvZ95b2VZfjaF3HVQbLXyvji9XwADEw/JmuiVozB8 GJ73O2j22RYO2rF1lOcNDMpRxwYg2EBcg9L+HQY+wVPdkWqzPKU7TCnO2VFuflFB3qpy 7v6oIl59OSFGq6gqoRimOZ79G9S2XSMk/sDJJ45/PPKW/da1xk28luCl3aj39kD4niX+ 1tY9xAMSoKR2UOMDy+KP7950s9y53pYihTZDSXwxwqUjB1i18Xu6/CFa1RJUvcestWxh CirA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l9si911730otd.134.2020.03.04.02.53.32; Wed, 04 Mar 2020 02:53:44 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387871AbgCDKw4 (ORCPT + 99 others); Wed, 4 Mar 2020 05:52:56 -0500 Received: from cloudserver094114.home.pl ([79.96.170.134]:61188 "EHLO cloudserver094114.home.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729261AbgCDKwz (ORCPT ); Wed, 4 Mar 2020 05:52:55 -0500 Received: from 79.184.237.41.ipv4.supernova.orange.pl (79.184.237.41) (HELO kreacher.localnet) by serwer1319399.home.pl (79.96.170.134) with SMTP (IdeaSmtpServer 0.83.341) id e6e3b8ac55937e48; Wed, 4 Mar 2020 11:52:54 +0100 From: "Rafael J. Wysocki" To: Linux ACPI Cc: LKML , "Rafael J. Wysocki" , Daniel Drake , Jian-Hong Pan Subject: [PATCH v2 4/6] ACPI: EC: Simplify acpi_ec_add() Date: Wed, 04 Mar 2020 11:48:10 +0100 Message-ID: <3645328.ZVAHyXvlRV@kreacher> In-Reply-To: <2411774.6kdisLRoUK@kreacher> References: <2094703.CetWLLyMuz@kreacher> <2411774.6kdisLRoUK@kreacher> 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" 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 --- -> v2: Reorder (previously [5/6]) and rebase. --- drivers/acpi/ec.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c index 6f501d552e6e..116163add41b 100644 --- a/drivers/acpi/ec.c +++ b/drivers/acpi/ec.c @@ -1605,19 +1605,18 @@ static bool acpi_ec_ecdt_get_handle(acpi_handle *phandle) static int acpi_ec_add(struct acpi_device *device) { - struct acpi_ec *ec = NULL; - bool dep_update = true; - acpi_status status; + struct acpi_ec *ec; 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)) { - boot_ec_is_ecdt = true; + /* Fast path: this device corresponds to the boot EC. */ ec = boot_ec; - dep_update = false; } else { + acpi_status status; + ec = acpi_ec_alloc(); if (!ec) return -ENOMEM; @@ -1660,10 +1659,9 @@ static int acpi_ec_add(struct acpi_device *device) ret = !!request_region(ec->command_addr, 1, "EC cmd"); WARN(!ret, "Could not request EC cmd io port 0x%lx", ec->command_addr); - if (dep_update) { - /* Reprobe devices depending on the EC */ - acpi_walk_dep_device_list(ec->handle); - } + /* Reprobe devices depending on the EC */ + acpi_walk_dep_device_list(ec->handle); + acpi_handle_debug(ec->handle, "enumerated.\n"); return 0; -- 2.16.4