*** ec.c 2011-03-15 02:20:32.000000000 +0100 --- ec_patched.c 2011-09-25 09:21:29.360422000 +0200 *************** *** 223,228 **** --- 223,229 ---- if (ec_transaction_done(ec)) return 0; } else { + msleep(1); if (wait_event_timeout(ec->wait, ec_transaction_done(ec), msecs_to_jiffies(1))) *************** *** 230,237 **** } advance_transaction(ec, acpi_ec_read_status(ec)); } while (time_before(jiffies, delay)); ! if (acpi_ec_read_status(ec) & ACPI_EC_FLAG_IBF) ! break; pr_debug(PREFIX "controller reset, restart transaction\n"); spin_lock_irqsave(&ec->curr_lock, flags); start_transaction(ec); --- 231,238 ---- } advance_transaction(ec, acpi_ec_read_status(ec)); } while (time_before(jiffies, delay)); ! // if (acpi_ec_read_status(ec) & ACPI_EC_FLAG_IBF) ! // break; pr_debug(PREFIX "controller reset, restart transaction\n"); spin_lock_irqsave(&ec->curr_lock, flags); start_transaction(ec); *************** *** 268,273 **** --- 269,284 ---- return (status & ACPI_EC_FLAG_IBF) == 0; } + /* try to clean input buffer with burst_disable transaction */ + static int acpi_ec_clean_buffer(struct acpi_ec *ec) + { + struct transaction t = {.command = ACPI_EC_BURST_DISABLE, + .wdata = NULL, .rdata = NULL, + .wlen = 0, .rlen = 0}; + return acpi_ec_transaction_unlocked(ec, &t); + } + + static int ec_wait_ibf0(struct acpi_ec *ec) { unsigned long delay = jiffies + msecs_to_jiffies(ec_delay); *************** *** 276,282 **** if (wait_event_timeout(ec->wait, ec_check_ibf0(ec), msecs_to_jiffies(1))) return 0; ! return -ETIME; } static int acpi_ec_transaction(struct acpi_ec *ec, struct transaction *t) --- 287,294 ---- if (wait_event_timeout(ec->wait, ec_check_ibf0(ec), msecs_to_jiffies(1))) return 0; ! // return -ETIME; ! return acpi_ec_clean_buffer(ec); } static int acpi_ec_transaction(struct acpi_ec *ec, struct transaction *t)