linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rjw@rjwysocki.net>
To: Linux ACPI <linux-acpi@vger.kernel.org>
Cc: LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH 3/5] ACPI: EC: Simplify error handling in advance_transaction()
Date: Mon, 23 Nov 2020 20:38:37 +0100	[thread overview]
Message-ID: <3207399.h1hCrb0iRi@kreacher> (raw)
In-Reply-To: <3259005.CeRvrUlyd7@kreacher>

From: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>

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 <rafael.j.wysocki@intel.com>
---
 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





  parent reply	other threads:[~2020-11-23 19:41 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-23 19:35 [PATCH 0/5] ACPI: EC: Cleanups in advance_transaction() Rafael J. Wysocki
2020-11-23 19:37 ` [PATCH 1/5] ACPI: EC: Fold acpi_ec_clear_gpe() into its caller Rafael J. Wysocki
2020-11-23 19:37 ` [PATCH 2/5] ACPI: EC: Rename acpi_ec_is_gpe_raised() Rafael J. Wysocki
2020-11-23 19:38 ` Rafael J. Wysocki [this message]
2020-11-23 19:39 ` [PATCH 4/5] ACPI: EC: Untangle error handling in advance_transaction() Rafael J. Wysocki
2020-11-23 19:40 ` [PATCH 5/5] ACPI: EC: Clean up status flags checks " Rafael J. Wysocki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3207399.h1hCrb0iRi@kreacher \
    --to=rjw@rjwysocki.net \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).