diff options
author | ChromeOS Developer <dparker@chromium.org> | 2014-03-22 14:04:25 -0700 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2014-03-26 19:28:58 +0000 |
commit | e2e2f5d848b1d763b8a0f420ee0878cbc395856f (patch) | |
tree | a20020833a8c893ea211ad26faa3173c007f2b5a | |
parent | d9bd95200f3252c141653a2e83f7580b00a4782d (diff) | |
download | chrome-ec-e2e2f5d848b1d763b8a0f420ee0878cbc395856f.tar.gz |
lm4: Update i2c handler to use task_wait_event_mask
BUG=chrome-os-partner:27180
BRANCH=rambi
TEST=Verify i2c devices are still working (battery, charger)
Change-Id: I9dc70454df35be9c9be3d9020c8dc3b760de5e07
Signed-off-by: Dave Parker <dparker@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/191301
Reviewed-by: Randall Spangler <rspangler@chromium.org>
-rw-r--r-- | chip/lm4/i2c.c | 26 |
1 files changed, 1 insertions, 25 deletions
diff --git a/chip/lm4/i2c.c b/chip/lm4/i2c.c index f50296678b..57359646dc 100644 --- a/chip/lm4/i2c.c +++ b/chip/lm4/i2c.c @@ -167,7 +167,6 @@ int i2c_xfer(int port, int slave_addr, const uint8_t *out, int out_size, struct i2c_port_data *pd = pdata + port; uint32_t reg_mcs = LM4_I2C_MCS(port); int events = 0; - int other_events = 0; if (out_size == 0 && in_size == 0) return EC_SUCCESS; @@ -224,35 +223,12 @@ int i2c_xfer(int port, int slave_addr, const uint8_t *out, int out_size, task_trigger_irq(i2c_irqs[port]); /* Wait for transfer complete or timeout */ - while (!(events & (TASK_EVENT_I2C_IDLE | TASK_EVENT_TIMER))) { - /* - * We could be clever and track how long we were actually - * asleep, and wait for the remainder if we were woken up - * for some other event. But that would consume additional - * stack space and processing time for the infrequent case - * of an I2C timeout, so isn't worth it. - */ - events = task_wait_event(I2C_TIMEOUT_US); - - /* - * We want to wait here quietly until the transaction is - * complete, but we don't want to lose any pending events that - * will be needed by the task that started the I2C transaction - * in the first place. So we save them up and restore them on - * completion or timeout. See the usleep() implementation for a - * similar situation. - */ - other_events |= events & - ~(TASK_EVENT_I2C_IDLE | TASK_EVENT_TIMER); - } + events = task_wait_event_mask(TASK_EVENT_I2C_IDLE, I2C_TIMEOUT_US); /* Disable interrupts */ LM4_I2C_MIMR(port) = 0x00; pd->task_waiting = TASK_ID_INVALID; - /* Restore any events that we saw while waiting */ - task_set_event(task_get_current(), other_events, 0); - /* Handle timeout */ if (events & TASK_EVENT_TIMER) pd->err = EC_ERROR_TIMEOUT; |