From 91a6726b56d119445808a86997137d2a62fed898 Mon Sep 17 00:00:00 2001 From: Charlie Mooney Date: Thu, 16 Aug 2012 11:05:35 -0700 Subject: [PATCH] Replacing usleep with interrupt friendly udelay There was a usleep put into a function that can be called from in an interrupt context, which doesn't work. This just switches it over to udelay which will work in an interrupt. Also flips the condition on the i2c if/else that might send it there. It was backwards before BUG=chrome-os-partner:12688 TEST=Run "battery" "pmu" boot the machine and use the keyboard. Then replace the in_interrupt_context() function with "1" to force it to use polling and repeat the test. Everything should work in both cases. BOARD=snow Change-Id: Ib2a8c7f9e5e2eb3f6b00678d6307afc9dd5f0518 Signed-off-by: Charlie Mooney Reviewed-on: https://gerrit.chromium.org/gerrit/30575 Reviewed-by: Simon Glass --- chip/stm32/dma.c | 2 +- chip/stm32/i2c.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/chip/stm32/dma.c b/chip/stm32/dma.c index c37063a894..935ffed038 100644 --- a/chip/stm32/dma.c +++ b/chip/stm32/dma.c @@ -217,7 +217,7 @@ int dma_wait(int channel) if (deadline.val <= get_time().val) return -1; else - usleep(DMA_POLLING_INTERVAL_US); + udelay(DMA_POLLING_INTERVAL_US); } return 0; } diff --git a/chip/stm32/i2c.c b/chip/stm32/i2c.c index 8ac6823cea..5205abbda6 100644 --- a/chip/stm32/i2c.c +++ b/chip/stm32/i2c.c @@ -131,7 +131,7 @@ static int i2c_write_raw_slave(int port, void *buf, int len) /* Configuring i2c2 to use DMA */ STM32_I2C_CR2(port) |= (1 << 11); - if (!in_interrupt_context()) { + if (in_interrupt_context()) { /* Poll for the transmission complete flag */ dma_wait(DMAC_I2C_TX); dma_clear_isr(DMAC_I2C_TX);