Skip to content

Commit 9aa60f3

Browse files
committed
ACPI: EC: Do not return result from advance_transaction()
Notice that the if the event state is EC_EVENT_READY, the event handling work cannot be pending, so it is not necessary to check the return value of queue_work() in acpi_ec_submit_event(). Moreover, whether or not there is any EC work pending at the moment can always be checked by looking at the events_in_progress and queries_in_progress counters, so acpi_ec_submit_event() and consequently advance_transaction() need not return results. Accordingly, make acpi_ec_dispatch_gpe() always use the counters mentioned above (for first_ec) to check if there is any pending EC work to flush and turn both acpi_ec_submit_event() and advance_transaction() into void functions (again, because they were void functions in the past). While at it, add a clarifying comment about the acpi_ec_mask_events() call in advance_transaction(). Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 977dc30 commit 9aa60f3

1 file changed

Lines changed: 19 additions & 19 deletions

File tree

drivers/acpi/ec.c

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ struct acpi_ec_query {
168168
};
169169

170170
static int acpi_ec_submit_query(struct acpi_ec *ec);
171-
static bool advance_transaction(struct acpi_ec *ec, bool interrupt);
171+
static void advance_transaction(struct acpi_ec *ec, bool interrupt);
172172
static void acpi_ec_event_handler(struct work_struct *work);
173173

174174
struct acpi_ec *first_ec;
@@ -441,11 +441,15 @@ static bool acpi_ec_submit_flushable_request(struct acpi_ec *ec)
441441
return true;
442442
}
443443

444-
static bool acpi_ec_submit_event(struct acpi_ec *ec)
444+
static void acpi_ec_submit_event(struct acpi_ec *ec)
445445
{
446+
/*
447+
* It is safe to mask the events here, because acpi_ec_close_event()
448+
* will run at least once after this.
449+
*/
446450
acpi_ec_mask_events(ec);
447451
if (!acpi_ec_event_enabled(ec))
448-
return false;
452+
return;
449453

450454
if (ec->event_state == EC_EVENT_READY) {
451455
ec_dbg_evt("Command(%s) submitted/blocked",
@@ -460,17 +464,11 @@ static bool acpi_ec_submit_event(struct acpi_ec *ec)
460464
* queue up the event work to start the same loop again.
461465
*/
462466
if (ec->events_to_process++ > 0)
463-
return true;
467+
return;
464468

465469
ec->events_in_progress++;
466-
return queue_work(ec_wq, &ec->work);
470+
queue_work(ec_wq, &ec->work);
467471
}
468-
469-
/*
470-
* The event handling work has not been completed yet, so it needs to be
471-
* flushed.
472-
*/
473-
return true;
474472
}
475473

476474
static void acpi_ec_complete_event(struct acpi_ec *ec)
@@ -655,11 +653,10 @@ static void acpi_ec_spurious_interrupt(struct acpi_ec *ec, struct transaction *t
655653
acpi_ec_mask_events(ec);
656654
}
657655

658-
static bool advance_transaction(struct acpi_ec *ec, bool interrupt)
656+
static void advance_transaction(struct acpi_ec *ec, bool interrupt)
659657
{
660658
struct transaction *t = ec->curr;
661659
bool wakeup = false;
662-
bool ret = false;
663660
u8 status;
664661

665662
ec_dbg_stm("%s (%d)", interrupt ? "IRQ" : "TASK", smp_processor_id());
@@ -724,12 +721,10 @@ static bool advance_transaction(struct acpi_ec *ec, bool interrupt)
724721

725722
out:
726723
if (status & ACPI_EC_FLAG_SCI)
727-
ret = acpi_ec_submit_event(ec);
724+
acpi_ec_submit_event(ec);
728725

729726
if (wakeup && interrupt)
730727
wake_up(&ec->wait);
731-
732-
return ret;
733728
}
734729

735730
static void start_transaction(struct acpi_ec *ec)
@@ -2051,6 +2046,11 @@ void acpi_ec_set_gpe_wake_mask(u8 action)
20512046
acpi_set_gpe_wake_mask(NULL, first_ec->gpe, action);
20522047
}
20532048

2049+
static bool acpi_ec_work_in_progress(struct acpi_ec *ec)
2050+
{
2051+
return ec->events_in_progress + ec->queries_in_progress > 0;
2052+
}
2053+
20542054
bool acpi_ec_dispatch_gpe(void)
20552055
{
20562056
bool work_in_progress = false;
@@ -2084,7 +2084,8 @@ bool acpi_ec_dispatch_gpe(void)
20842084
if (acpi_ec_gpe_status_set(first_ec)) {
20852085
pm_pr_dbg("ACPI EC GPE status set\n");
20862086

2087-
work_in_progress = advance_transaction(first_ec, false);
2087+
advance_transaction(first_ec, false);
2088+
work_in_progress = acpi_ec_work_in_progress(first_ec);
20882089
}
20892090

20902091
spin_unlock_irq(&first_ec->lock);
@@ -2102,8 +2103,7 @@ bool acpi_ec_dispatch_gpe(void)
21022103

21032104
spin_lock_irq(&first_ec->lock);
21042105

2105-
work_in_progress = first_ec->events_in_progress +
2106-
first_ec->queries_in_progress > 0;
2106+
work_in_progress = acpi_ec_work_in_progress(first_ec);
21072107

21082108
spin_unlock_irq(&first_ec->lock);
21092109
} while (work_in_progress && !pm_wakeup_pending());

0 commit comments

Comments
 (0)