Commit 34765c19 authored by Viresh Kumar's avatar Viresh Kumar Committed by Wolfram Sang

i2c: sh_mobile: simplify code and remove false compilation warning

This currently generates a warning:

drivers/i2c/busses/i2c-sh_mobile.c: In function 'sh_mobile_i2c_isr':
drivers/i2c/busses/i2c-sh_mobile.c:399:26: warning: 'data' may be used uninitialized in this function [-Wmaybe-uninitialized]

Though the code looks okay and shouldn't ever use the variable
uninitialized. Fix the warning by moving the code around and getting rid
of 'data'.
Signed-off-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
Tested-by: default avatarWolfram Sang <wsa+renesas@sang-engineering.com>
[wsa: minor updates to commit message]
Signed-off-by: default avatarWolfram Sang <wsa@kernel.org>
parent 01590f36
...@@ -366,7 +366,6 @@ static int sh_mobile_i2c_isr_tx(struct sh_mobile_i2c_data *pd) ...@@ -366,7 +366,6 @@ static int sh_mobile_i2c_isr_tx(struct sh_mobile_i2c_data *pd)
static int sh_mobile_i2c_isr_rx(struct sh_mobile_i2c_data *pd) static int sh_mobile_i2c_isr_rx(struct sh_mobile_i2c_data *pd)
{ {
unsigned char data;
int real_pos; int real_pos;
/* switch from TX (address) to RX (data) adds two interrupts */ /* switch from TX (address) to RX (data) adds two interrupts */
...@@ -387,13 +386,11 @@ static int sh_mobile_i2c_isr_rx(struct sh_mobile_i2c_data *pd) ...@@ -387,13 +386,11 @@ static int sh_mobile_i2c_isr_rx(struct sh_mobile_i2c_data *pd)
if (real_pos < 0) if (real_pos < 0)
i2c_op(pd, OP_RX_STOP); i2c_op(pd, OP_RX_STOP);
else else
data = i2c_op(pd, OP_RX_STOP_DATA); pd->msg->buf[real_pos] = i2c_op(pd, OP_RX_STOP_DATA);
} else if (real_pos >= 0) { } else if (real_pos >= 0) {
data = i2c_op(pd, OP_RX); pd->msg->buf[real_pos] = i2c_op(pd, OP_RX);
} }
if (real_pos >= 0)
pd->msg->buf[real_pos] = data;
done: 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