Commit 63c52460 authored by Wolfram Sang's avatar Wolfram Sang Committed by Wolfram Sang

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: default avatarWolfram Sang <wsa+renesas@sang-engineering.com>
Reviewed-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: default avatarWolfram Sang <wsa@the-dreams.de>
parent 0130e3bf
...@@ -373,25 +373,18 @@ static int sh_mobile_i2c_isr_rx(struct sh_mobile_i2c_data *pd) ...@@ -373,25 +373,18 @@ static int sh_mobile_i2c_isr_rx(struct sh_mobile_i2c_data *pd)
unsigned char data; unsigned char data;
int real_pos; int real_pos;
do { real_pos = pd->pos - 2;
if (pd->pos == -1) { if (pd->pos == -1) {
i2c_op(pd, OP_TX_FIRST); i2c_op(pd, OP_TX_FIRST);
break; } else if (pd->pos == 0) {
}
if (pd->pos == 0) {
i2c_op(pd, OP_TX_TO_RX); i2c_op(pd, OP_TX_TO_RX);
break; } else if (pd->pos == pd->msg->len) {
}
real_pos = pd->pos - 2;
if (pd->pos == pd->msg->len) {
if (pd->stop_after_dma) { if (pd->stop_after_dma) {
/* Simulate PIO end condition after DMA transfer */ /* Simulate PIO end condition after DMA transfer */
i2c_op(pd, OP_RX_STOP); i2c_op(pd, OP_RX_STOP);
pd->pos++; pd->pos++;
break; goto done;
} }
if (real_pos < 0) if (real_pos < 0)
...@@ -404,8 +397,7 @@ static int sh_mobile_i2c_isr_rx(struct sh_mobile_i2c_data *pd) ...@@ -404,8 +397,7 @@ static int sh_mobile_i2c_isr_rx(struct sh_mobile_i2c_data *pd)
if (real_pos >= 0) if (real_pos >= 0)
pd->msg->buf[real_pos] = data; pd->msg->buf[real_pos] = data;
} while (0); done:
pd->pos++; pd->pos++;
return pd->pos == (pd->msg->len + 2); return pd->pos == (pd->msg->len + 2);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment