Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1270349pxu; Mon, 23 Nov 2020 16:36:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJwP/WeqOMwVulN6sKZqoYAxJyMIJmKUFHAL1JxSqgVF8XXDmgx0MnwVOYZb+QMk2qCXwNFI X-Received: by 2002:a17:906:4116:: with SMTP id j22mr1960446ejk.373.1606178196180; Mon, 23 Nov 2020 16:36:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606178196; cv=none; d=google.com; s=arc-20160816; b=kPZNc4ufb/DHAKGBXzCfXhWd6Xv8z/sUsqt1bUpn9oo08AV1ZMjmTJF5TSyAQXJfCG kGE0kInSmNthBNkGQUnwItqXnKa13rrFk+VMcyzjOnEjg0aydwZs3XNGNhTjv5Hl1Jlf 3nrlw8ATX8F1R3NCAn/KUeFFwdl8DfViL1BBzNpRAqETbp+sCthRfZZlpYR8tmjIwmC8 Gq3v/hY05I32E/bNtxeGj2Q9tyHuDJIzbDNKVhopgiy2S2N6WGxXaZHVOzaQFpZ6mzXX 7JG4/mQtBMCi6zsrgaO3YHfPM3kjOEUCuQkXzFlDJZiH6lAOVfGoHTtiE2ZPNt2bdp2N KB2w== 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=Gyx8Wd35LRgOmQhJgT5tWbP6QJNBgxzgg9r8B9K0qHM=; b=WaNFliAqm4egYa5FXYvNlzYgHmePXVt/xOToOELrHXk3/kgqeo8cvG/NdhjSF6pfJ4 V7yGJeU0fKvtyP47nEnnBPIeh7UsnBJI6i0FpEUrcO8lEJIqoNQES0lN26DPbdlkLVWU 4d+2uh/BTyuXDHY7Bs6aN5F/CYgsKNqqtOTVPZyC3Rp2QNUmZXfeS5M0iZx5hcU2x5rR VJGBR7fHzogwzV7w9AaVbrcWD8ZtnNut3l4+zfzVQWXTfJylYnZAMRYyedf+A2EWQxKw FaWkhf3s6oXpaoFlBD2Xf9vIKpMNf7dSj43oQGV0yNvJYgS38cEAUZCM2A+0bOyqYIP9 8Zkw== 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 e1si7670718ejf.335.2020.11.23.16.36.13; Mon, 23 Nov 2020 16:36:36 -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 S1730848AbgKWTlH (ORCPT + 99 others); Mon, 23 Nov 2020 14:41:07 -0500 Received: from cloudserver094114.home.pl ([79.96.170.134]:41168 "EHLO cloudserver094114.home.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730235AbgKWTlG (ORCPT ); Mon, 23 Nov 2020 14:41:06 -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 61c4e727b3eb1d26; Mon, 23 Nov 2020 20:41:04 +0100 From: "Rafael J. Wysocki" To: Linux ACPI Cc: LKML Subject: [PATCH 4/5] ACPI: EC: Untangle error handling in advance_transaction() Date: Mon, 23 Nov 2020 20:39:27 +0100 Message-ID: <3740828.yVBKsGfhbx@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" Introduce acpi_ec_spurious_interrupt() for recording spurious interrupts and use it for error handling in advance_transaction(), drop the (now redundant) original error handling block from there along with a frew goto statements that are not necessary any more. No intentional functional impact. Signed-off-by: Rafael J. Wysocki --- drivers/acpi/ec.c | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c index 23e7b2dec98e..091f0e9f37a0 100644 --- a/drivers/acpi/ec.c +++ b/drivers/acpi/ec.c @@ -615,6 +615,16 @@ static inline void ec_transaction_transition(struct acpi_ec *ec, unsigned long f } } +static void acpi_ec_spurious_interrupt(struct acpi_ec *ec, struct transaction *t) +{ + if (t->irq_count < ec_storm_threshold) + ++t->irq_count; + + /* Trigger if the threshold is 0 too. */ + if (t->irq_count == ec_storm_threshold) + acpi_ec_mask_events(ec); +} + static void advance_transaction(struct acpi_ec *ec, bool interrupt) { struct transaction *t = ec->curr; @@ -659,8 +669,8 @@ static void advance_transaction(struct acpi_ec *ec, bool interrupt) if (t->wlen > t->wi) { if ((status & ACPI_EC_FLAG_IBF) == 0) acpi_ec_write_data(ec, t->wdata[t->wi++]); - else - goto err; + else if (interrupt && !(status & ACPI_EC_FLAG_SCI)) + acpi_ec_spurious_interrupt(ec, t); } else if (t->rlen > t->ri) { if ((status & ACPI_EC_FLAG_OBF) == 1) { t->rdata[t->ri++] = acpi_ec_read_data(ec); @@ -671,32 +681,19 @@ static void advance_transaction(struct acpi_ec *ec, bool interrupt) acpi_ec_cmd_string(ACPI_EC_COMMAND_QUERY)); wakeup = true; } - } else - goto err; + } else if (interrupt && !(status & ACPI_EC_FLAG_SCI)) { + acpi_ec_spurious_interrupt(ec, t); + } } else if (t->wlen == t->wi && (status & ACPI_EC_FLAG_IBF) == 0) { ec_transaction_transition(ec, ACPI_EC_COMMAND_COMPLETE); wakeup = true; } - goto out; } else if (!(status & ACPI_EC_FLAG_IBF)) { acpi_ec_write_cmd(ec, t->command); ec_transaction_transition(ec, ACPI_EC_COMMAND_POLL); - goto out; } -err: - /* - * 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) && 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) acpi_ec_submit_query(ec); -- 2.26.2