diff options
author | Wolfram Sang <wsa+renesas@sang-engineering.com> | 2019-01-16 22:05:54 +0100 |
---|---|---|
committer | Wolfram Sang <wsa@the-dreams.de> | 2019-01-23 00:18:09 +0100 |
commit | 63c524600353a9c2d097041863a9ab36ed2db79b (patch) | |
tree | 02892bc0c3674cbe5a25ece33c7c2d41712af0e0 /drivers/i2c/busses/i2c-sh_mobile.c | |
parent | 0130e3bfa9fa102252ad318d0f5608cc09822baa (diff) | |
download | linux-63c524600353a9c2d097041863a9ab36ed2db79b.tar.bz2 |
i2c: sh_mobile: refactor rx isr
Remove the do_while loop which was just there to have an easy exit with
"break;" and replace it with if-else-blocks which should make the state
machine clearer.
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
Diffstat (limited to 'drivers/i2c/busses/i2c-sh_mobile.c')
-rw-r--r-- | drivers/i2c/busses/i2c-sh_mobile.c | 50 |
1 files changed, 21 insertions, 29 deletions
diff --git a/drivers/i2c/busses/i2c-sh_mobile.c b/drivers/i2c/busses/i2c-sh_mobile.c index ab6969ed7eff..dd4df961d8eb 100644 --- a/drivers/i2c/busses/i2c-sh_mobile.c +++ b/drivers/i2c/busses/i2c-sh_mobile.c @@ -373,39 +373,31 @@ static int sh_mobile_i2c_isr_rx(struct sh_mobile_i2c_data *pd) unsigned char data; int real_pos; - do { - if (pd->pos == -1) { - i2c_op(pd, OP_TX_FIRST); - break; - } - - if (pd->pos == 0) { - i2c_op(pd, OP_TX_TO_RX); - break; - } - - real_pos = pd->pos - 2; + real_pos = pd->pos - 2; - if (pd->pos == pd->msg->len) { - if (pd->stop_after_dma) { - /* Simulate PIO end condition after DMA transfer */ - i2c_op(pd, OP_RX_STOP); - pd->pos++; - break; - } - - if (real_pos < 0) - i2c_op(pd, OP_RX_STOP); - else - data = i2c_op(pd, OP_RX_STOP_DATA); - } else if (real_pos >= 0) { - data = i2c_op(pd, OP_RX); + if (pd->pos == -1) { + i2c_op(pd, OP_TX_FIRST); + } else if (pd->pos == 0) { + i2c_op(pd, OP_TX_TO_RX); + } else if (pd->pos == pd->msg->len) { + if (pd->stop_after_dma) { + /* Simulate PIO end condition after DMA transfer */ + i2c_op(pd, OP_RX_STOP); + pd->pos++; + goto done; } - if (real_pos >= 0) - pd->msg->buf[real_pos] = data; - } while (0); + if (real_pos < 0) + i2c_op(pd, OP_RX_STOP); + else + data = i2c_op(pd, OP_RX_STOP_DATA); + } else if (real_pos >= 0) { + data = i2c_op(pd, OP_RX); + } + if (real_pos >= 0) + pd->msg->buf[real_pos] = data; + done: pd->pos++; return pd->pos == (pd->msg->len + 2); } |