提交 f8b8eb71 编写于 作者: L Lv Zheng 提交者: Rafael J. Wysocki

ACPI / EC: Cleanup transaction state transition.

This patch collects transaction state transition code into one function. We
then could have a single function to maintain transaction transition
related behaviors. No functional changes.
Signed-off-by: NLv Zheng <lv.zheng@intel.com>
Tested-by: NGabriele Mazzotta <gabriele.mzt@gmail.com>
Tested-by: NTigran Gabrielyan <tigrangab@gmail.com>
Tested-by: NAdrien D <ghbdtn@openmailbox.org>
Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
上级 3174abcf
...@@ -391,7 +391,7 @@ static void acpi_ec_submit_query(struct acpi_ec *ec) ...@@ -391,7 +391,7 @@ static void acpi_ec_submit_query(struct acpi_ec *ec)
static void acpi_ec_complete_query(struct acpi_ec *ec) static void acpi_ec_complete_query(struct acpi_ec *ec)
{ {
if (ec->curr->command == ACPI_EC_COMMAND_QUERY) { if (test_bit(EC_FLAGS_QUERY_PENDING, &ec->flags)) {
clear_bit(EC_FLAGS_QUERY_PENDING, &ec->flags); clear_bit(EC_FLAGS_QUERY_PENDING, &ec->flags);
ec_dbg_req("Event stopped"); ec_dbg_req("Event stopped");
} }
...@@ -421,6 +421,15 @@ static int ec_transaction_completed(struct acpi_ec *ec) ...@@ -421,6 +421,15 @@ static int ec_transaction_completed(struct acpi_ec *ec)
return ret; return ret;
} }
static inline void ec_transaction_transition(struct acpi_ec *ec, unsigned long flag)
{
ec->curr->flags |= flag;
if (ec->curr->command == ACPI_EC_COMMAND_QUERY) {
if (flag == ACPI_EC_COMMAND_POLL)
acpi_ec_complete_query(ec);
}
}
static void advance_transaction(struct acpi_ec *ec) static void advance_transaction(struct acpi_ec *ec)
{ {
struct transaction *t; struct transaction *t;
...@@ -449,7 +458,7 @@ static void advance_transaction(struct acpi_ec *ec) ...@@ -449,7 +458,7 @@ static void advance_transaction(struct acpi_ec *ec)
if ((status & ACPI_EC_FLAG_OBF) == 1) { if ((status & ACPI_EC_FLAG_OBF) == 1) {
t->rdata[t->ri++] = acpi_ec_read_data(ec); t->rdata[t->ri++] = acpi_ec_read_data(ec);
if (t->rlen == t->ri) { if (t->rlen == t->ri) {
t->flags |= ACPI_EC_COMMAND_COMPLETE; ec_transaction_transition(ec, ACPI_EC_COMMAND_COMPLETE);
if (t->command == ACPI_EC_COMMAND_QUERY) if (t->command == ACPI_EC_COMMAND_QUERY)
ec_dbg_req("Command(%s) hardware completion", ec_dbg_req("Command(%s) hardware completion",
acpi_ec_cmd_string(t->command)); acpi_ec_cmd_string(t->command));
...@@ -459,7 +468,7 @@ static void advance_transaction(struct acpi_ec *ec) ...@@ -459,7 +468,7 @@ static void advance_transaction(struct acpi_ec *ec)
goto err; goto err;
} else if (t->wlen == t->wi && } else if (t->wlen == t->wi &&
(status & ACPI_EC_FLAG_IBF) == 0) { (status & ACPI_EC_FLAG_IBF) == 0) {
t->flags |= ACPI_EC_COMMAND_COMPLETE; ec_transaction_transition(ec, ACPI_EC_COMMAND_COMPLETE);
wakeup = true; wakeup = true;
} }
goto out; goto out;
...@@ -467,17 +476,15 @@ static void advance_transaction(struct acpi_ec *ec) ...@@ -467,17 +476,15 @@ static void advance_transaction(struct acpi_ec *ec)
if (EC_FLAGS_QUERY_HANDSHAKE && if (EC_FLAGS_QUERY_HANDSHAKE &&
!(status & ACPI_EC_FLAG_SCI) && !(status & ACPI_EC_FLAG_SCI) &&
(t->command == ACPI_EC_COMMAND_QUERY)) { (t->command == ACPI_EC_COMMAND_QUERY)) {
t->flags |= ACPI_EC_COMMAND_POLL; ec_transaction_transition(ec, ACPI_EC_COMMAND_POLL);
acpi_ec_complete_query(ec);
t->rdata[t->ri++] = 0x00; t->rdata[t->ri++] = 0x00;
t->flags |= ACPI_EC_COMMAND_COMPLETE; ec_transaction_transition(ec, ACPI_EC_COMMAND_COMPLETE);
ec_dbg_req("Command(%s) software completion", ec_dbg_req("Command(%s) software completion",
acpi_ec_cmd_string(t->command)); acpi_ec_cmd_string(t->command));
wakeup = true; wakeup = true;
} else if ((status & ACPI_EC_FLAG_IBF) == 0) { } else if ((status & ACPI_EC_FLAG_IBF) == 0) {
acpi_ec_write_cmd(ec, t->command); acpi_ec_write_cmd(ec, t->command);
t->flags |= ACPI_EC_COMMAND_POLL; ec_transaction_transition(ec, ACPI_EC_COMMAND_POLL);
acpi_ec_complete_query(ec);
} else } else
goto err; goto err;
goto out; goto out;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册