Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1105205pxu; Mon, 23 Nov 2020 11:45:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJyzqpZN3Ur9gRqng4fmIQt1kgR3LXH50uZacZ4wltEbIb5nEL64C2LMy/nBJ94CSiEkNMJ+ X-Received: by 2002:aa7:dc49:: with SMTP id g9mr713014edu.383.1606160728088; Mon, 23 Nov 2020 11:45:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606160728; cv=none; d=google.com; s=arc-20160816; b=RQUCRiC7b9L5Slm19+dENmt4V0I+jLlqVCHz2puKggxJCJz8z0JsRoLEa9QrzuB+az 8lfBrbReP1PeU8T+jcgaqBNGJOJQLYj+m8PZuqwkuZeXgM/3vL0rTh0GWKzCFxp0ar4J yw42/N4ajmI2kzqeaLamhd/Fr+0ll2zEbwWLePsIAR4pEgQK9qS6jOqqXa2+NpdFUnjT XiaFb/nmsdRlf0ohBTbgCbugcFU6inC27Z5yKiRCNRVQkru9/Oa8usCUysljyDMeIVes L37Wf8GwRD0CwmC8J3CGccMxwpjEm5bQsM+TJn28XqQgfmqaXnPKMUVnw7GTyNgKgbZy Homg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=PvtIyz0nRqHUVAd5MZ/Aai6SAkyLhTzLwSmTcmVmAqg=; b=Q9vK6LNsR65/U5XpZRU6l59XMHb6XIlQe6ZwWyl5Bds9dbRPIcuMRmrNsKMootcb7E 8HpDqJ3BsrbFfRAXrlQx7zaChysMKxl3WrC2KwcG3lCGSB8nu9cdpg3uH4IVOQIlaLXB YDpkypmCe1k/pt9HgeAmeNanLxurDGDBKlgfp65eoMMY5gNkRZ3ePmm0ft5OgZaLxnuz aScvSwFYJVe2jmIQw5pD4SNHE32+46N3fKCLC0MsNmIZUIdQmZRTjCLv4dOUTr/1UPJq pEELwepnV1M6rV1ySJviFhX30kRQUHYO/adTA01wHCV1QbrG6x1In0vJsEpJRbfKAcu9 dTBA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h14si4027525edl.381.2020.11.23.11.45.04; Mon, 23 Nov 2020 11:45:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730874AbgKWTlI (ORCPT + 99 others); Mon, 23 Nov 2020 14:41:08 -0500 Received: from cloudserver094114.home.pl ([79.96.170.134]:44568 "EHLO cloudserver094114.home.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730205AbgKWTlI (ORCPT ); Mon, 23 Nov 2020 14:41:08 -0500 Received: from 89-64-88-191.dynamic.chello.pl (89.64.88.191) (HELO kreacher.localnet) by serwer1319399.home.pl (79.96.170.134) with SMTP (IdeaSmtpServer 0.83.520) id fd3d7e39cee1b48e; Mon, 23 Nov 2020 20:41:05 +0100 From: "Rafael J. Wysocki" To: Linux ACPI Cc: LKML Subject: [PATCH 3/5] ACPI: EC: Simplify error handling in advance_transaction() Date: Mon, 23 Nov 2020 20:38:37 +0100 Message-ID: <3207399.h1hCrb0iRi@kreacher> In-Reply-To: <3259005.CeRvrUlyd7@kreacher> References: <3259005.CeRvrUlyd7@kreacher> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: "Rafael J. Wysocki" Notice that the value of t in advance_transaction() does not change after its initialization and: - Initialize t upfront (and rearrange the definitions of local variables while at it). - Check it against NULL in a block executed when it is NULL. - Skip error handling for t == NULL, because a valid pointer value of t is required for the error handling. - Drop the (now redundant) check of t against NULL from the error handling block and reduce the indentation level in there. No intentional functional impact. Signed-off-by: Rafael J. Wysocki --- drivers/acpi/ec.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c index c4be16a495e1..23e7b2dec98e 100644 --- a/drivers/acpi/ec.c +++ b/drivers/acpi/ec.c @@ -617,9 +617,9 @@ static inline void ec_transaction_transition(struct acpi_ec *ec, unsigned long f static void advance_transaction(struct acpi_ec *ec, bool interrupt) { - struct transaction *t; - u8 status; + struct transaction *t = ec->curr; bool wakeup = false; + u8 status; ec_dbg_stm("%s (%d)", interrupt ? "IRQ" : "TASK", smp_processor_id()); @@ -639,7 +639,7 @@ static void advance_transaction(struct acpi_ec *ec, bool interrupt) acpi_clear_gpe(NULL, ec->gpe); status = acpi_ec_read_status(ec); - t = ec->curr; + /* * Another IRQ or a guarded polling mode advancement is detected, * the next QR_EC submission is then allowed. @@ -651,9 +651,10 @@ static void advance_transaction(struct acpi_ec *ec, bool interrupt) clear_bit(EC_FLAGS_QUERY_GUARDING, &ec->flags); acpi_ec_complete_query(ec); } + if (!t) + goto out; } - if (!t) - goto err; + if (t->flags & ACPI_EC_COMMAND_POLL) { if (t->wlen > t->wi) { if ((status & ACPI_EC_FLAG_IBF) == 0) @@ -688,14 +689,13 @@ static void advance_transaction(struct acpi_ec *ec, bool interrupt) * If SCI bit is set, then don't think it's a false IRQ * otherwise will take a not handled IRQ as a false one. */ - if (!(status & ACPI_EC_FLAG_SCI)) { - if (interrupt && t) { - if (t->irq_count < ec_storm_threshold) - ++t->irq_count; - /* Allow triggering on 0 threshold */ - if (t->irq_count == ec_storm_threshold) - acpi_ec_mask_events(ec); - } + if (!(status & ACPI_EC_FLAG_SCI) && interrupt) { + if (t->irq_count < ec_storm_threshold) + ++t->irq_count; + + /* Allow triggering on 0 threshold */ + if (t->irq_count == ec_storm_threshold) + acpi_ec_mask_events(ec); } out: if (status & ACPI_EC_FLAG_SCI) -- 2.26.2