Commit 902675fa authored by Rafael J. Wysocki's avatar Rafael J. Wysocki

ACPI: EC: Simplify error handling in advance_transaction()

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: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent d2a2e6cc
...@@ -617,9 +617,9 @@ static inline void ec_transaction_transition(struct acpi_ec *ec, unsigned long f ...@@ -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) static void advance_transaction(struct acpi_ec *ec, bool interrupt)
{ {
struct transaction *t; struct transaction *t = ec->curr;
u8 status;
bool wakeup = false; bool wakeup = false;
u8 status;
ec_dbg_stm("%s (%d)", interrupt ? "IRQ" : "TASK", smp_processor_id()); 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) ...@@ -639,7 +639,7 @@ static void advance_transaction(struct acpi_ec *ec, bool interrupt)
acpi_clear_gpe(NULL, ec->gpe); acpi_clear_gpe(NULL, ec->gpe);
status = acpi_ec_read_status(ec); status = acpi_ec_read_status(ec);
t = ec->curr;
/* /*
* Another IRQ or a guarded polling mode advancement is detected, * Another IRQ or a guarded polling mode advancement is detected,
* the next QR_EC submission is then allowed. * the next QR_EC submission is then allowed.
...@@ -651,9 +651,10 @@ static void advance_transaction(struct acpi_ec *ec, bool interrupt) ...@@ -651,9 +651,10 @@ static void advance_transaction(struct acpi_ec *ec, bool interrupt)
clear_bit(EC_FLAGS_QUERY_GUARDING, &ec->flags); clear_bit(EC_FLAGS_QUERY_GUARDING, &ec->flags);
acpi_ec_complete_query(ec); acpi_ec_complete_query(ec);
} }
if (!t)
goto out;
} }
if (!t)
goto err;
if (t->flags & ACPI_EC_COMMAND_POLL) { if (t->flags & ACPI_EC_COMMAND_POLL) {
if (t->wlen > t->wi) { if (t->wlen > t->wi) {
if ((status & ACPI_EC_FLAG_IBF) == 0) if ((status & ACPI_EC_FLAG_IBF) == 0)
...@@ -688,14 +689,13 @@ static void advance_transaction(struct acpi_ec *ec, bool interrupt) ...@@ -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 * 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. * otherwise will take a not handled IRQ as a false one.
*/ */
if (!(status & ACPI_EC_FLAG_SCI)) { if (!(status & ACPI_EC_FLAG_SCI) && interrupt) {
if (interrupt && t) { if (t->irq_count < ec_storm_threshold)
if (t->irq_count < ec_storm_threshold) ++t->irq_count;
++t->irq_count;
/* Allow triggering on 0 threshold */ /* Allow triggering on 0 threshold */
if (t->irq_count == ec_storm_threshold) if (t->irq_count == ec_storm_threshold)
acpi_ec_mask_events(ec); acpi_ec_mask_events(ec);
}
} }
out: out:
if (status & ACPI_EC_FLAG_SCI) if (status & ACPI_EC_FLAG_SCI)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment