aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/ec.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi/ec.c')
-rw-r--r--drivers/acpi/ec.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
index 453ba1e534ef..444cd9ed12c7 100644
--- a/drivers/acpi/ec.c
+++ b/drivers/acpi/ec.c
@@ -298,6 +298,18 @@ static int ec_check_ibf0(struct acpi_ec *ec)
298 return (status & ACPI_EC_FLAG_IBF) == 0; 298 return (status & ACPI_EC_FLAG_IBF) == 0;
299} 299}
300 300
301static int ec_wait_ibf0(struct acpi_ec *ec)
302{
303 unsigned long delay = jiffies + msecs_to_jiffies(ACPI_EC_DELAY);
304 /* interrupt wait manually if GPE mode is not active */
305 unsigned long timeout = test_bit(EC_FLAGS_GPE_MODE, &ec->flags) ?
306 msecs_to_jiffies(ACPI_EC_DELAY) : msecs_to_jiffies(1);
307 while (time_before(jiffies, delay))
308 if (wait_event_timeout(ec->wait, ec_check_ibf0(ec), timeout))
309 return 0;
310 return -ETIME;
311}
312
301static int acpi_ec_transaction(struct acpi_ec *ec, struct transaction *t, 313static int acpi_ec_transaction(struct acpi_ec *ec, struct transaction *t,
302 int force_poll) 314 int force_poll)
303{ 315{
@@ -315,8 +327,7 @@ static int acpi_ec_transaction(struct acpi_ec *ec, struct transaction *t,
315 goto unlock; 327 goto unlock;
316 } 328 }
317 } 329 }
318 if (!wait_event_timeout(ec->wait, ec_check_ibf0(ec), 330 if (ec_wait_ibf0(ec)) {
319 msecs_to_jiffies(ACPI_EC_DELAY))) {
320 pr_err(PREFIX "input buffer is not empty, " 331 pr_err(PREFIX "input buffer is not empty, "
321 "aborting transaction\n"); 332 "aborting transaction\n");
322 status = -ETIME; 333 status = -ETIME;