Commit d16f2bfe authored by Wolfram Sang's avatar Wolfram Sang Committed by Wolfram Sang

i2c: sh_mobile: drop 'data' argument from i2c_op function

It is clear that we always send the address in TX_FIRST and data in TX.
No need to pass it from the caller.
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 1f32fbdf
...@@ -303,13 +303,12 @@ static int sh_mobile_i2c_v2_init(struct sh_mobile_i2c_data *pd) ...@@ -303,13 +303,12 @@ static int sh_mobile_i2c_v2_init(struct sh_mobile_i2c_data *pd)
return sh_mobile_i2c_check_timing(pd); return sh_mobile_i2c_check_timing(pd);
} }
static unsigned char i2c_op(struct sh_mobile_i2c_data *pd, static unsigned char i2c_op(struct sh_mobile_i2c_data *pd, enum sh_mobile_i2c_op op)
enum sh_mobile_i2c_op op, unsigned char data)
{ {
unsigned char ret = 0; unsigned char ret = 0;
unsigned long flags; unsigned long flags;
dev_dbg(pd->dev, "op %d, data in 0x%02x\n", op, data); dev_dbg(pd->dev, "op %d\n", op);
spin_lock_irqsave(&pd->lock, flags); spin_lock_irqsave(&pd->lock, flags);
...@@ -317,12 +316,12 @@ static unsigned char i2c_op(struct sh_mobile_i2c_data *pd, ...@@ -317,12 +316,12 @@ static unsigned char i2c_op(struct sh_mobile_i2c_data *pd,
case OP_START: /* issue start and trigger DTE interrupt */ case OP_START: /* issue start and trigger DTE interrupt */
iic_wr(pd, ICCR, ICCR_ICE | ICCR_TRS | ICCR_BBSY); iic_wr(pd, ICCR, ICCR_ICE | ICCR_TRS | ICCR_BBSY);
break; break;
case OP_TX_FIRST: /* disable DTE interrupt and write data */ case OP_TX_FIRST: /* disable DTE interrupt and write client address */
iic_wr(pd, ICIC, ICIC_WAITE | ICIC_ALE | ICIC_TACKE); iic_wr(pd, ICIC, ICIC_WAITE | ICIC_ALE | ICIC_TACKE);
iic_wr(pd, ICDR, data); iic_wr(pd, ICDR, i2c_8bit_addr_from_msg(pd->msg));
break; break;
case OP_TX: /* write data */ case OP_TX: /* write data */
iic_wr(pd, ICDR, data); iic_wr(pd, ICDR, pd->msg->buf[pd->pos]);
break; break;
case OP_TX_STOP: /* issue a stop (or rep_start) */ case OP_TX_STOP: /* issue a stop (or rep_start) */
iic_wr(pd, ICCR, pd->send_stop ? ICCR_ICE | ICCR_TRS iic_wr(pd, ICCR, pd->send_stop ? ICCR_ICE | ICCR_TRS
...@@ -360,20 +359,15 @@ static bool sh_mobile_i2c_is_first_byte(struct sh_mobile_i2c_data *pd) ...@@ -360,20 +359,15 @@ static bool sh_mobile_i2c_is_first_byte(struct sh_mobile_i2c_data *pd)
static int sh_mobile_i2c_isr_tx(struct sh_mobile_i2c_data *pd) static int sh_mobile_i2c_isr_tx(struct sh_mobile_i2c_data *pd)
{ {
unsigned char data;
if (pd->pos == pd->msg->len) { if (pd->pos == pd->msg->len) {
i2c_op(pd, OP_TX_STOP, 0); i2c_op(pd, OP_TX_STOP);
return 1; return 1;
} }
if (sh_mobile_i2c_is_first_byte(pd)) { if (sh_mobile_i2c_is_first_byte(pd))
data = i2c_8bit_addr_from_msg(pd->msg); i2c_op(pd, OP_TX_FIRST);
i2c_op(pd, OP_TX_FIRST, data); else
} else { i2c_op(pd, OP_TX);
data = pd->msg->buf[pd->pos];
i2c_op(pd, OP_TX, data);
}
pd->pos++; pd->pos++;
return 0; return 0;
...@@ -386,13 +380,12 @@ static int sh_mobile_i2c_isr_rx(struct sh_mobile_i2c_data *pd) ...@@ -386,13 +380,12 @@ static int sh_mobile_i2c_isr_rx(struct sh_mobile_i2c_data *pd)
do { do {
if (sh_mobile_i2c_is_first_byte(pd)) { if (sh_mobile_i2c_is_first_byte(pd)) {
data = i2c_8bit_addr_from_msg(pd->msg); i2c_op(pd, OP_TX_FIRST);
i2c_op(pd, OP_TX_FIRST, data);
break; break;
} }
if (pd->pos == 0) { if (pd->pos == 0) {
i2c_op(pd, OP_TX_TO_RX, 0); i2c_op(pd, OP_TX_TO_RX);
break; break;
} }
...@@ -401,18 +394,18 @@ static int sh_mobile_i2c_isr_rx(struct sh_mobile_i2c_data *pd) ...@@ -401,18 +394,18 @@ static int sh_mobile_i2c_isr_rx(struct sh_mobile_i2c_data *pd)
if (pd->pos == pd->msg->len) { 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, 0); i2c_op(pd, OP_RX_STOP);
pd->pos++; pd->pos++;
break; break;
} }
if (real_pos < 0) { if (real_pos < 0) {
i2c_op(pd, OP_RX_STOP, 0); i2c_op(pd, OP_RX_STOP);
break; break;
} }
data = i2c_op(pd, OP_RX_STOP_DATA, 0); data = i2c_op(pd, OP_RX_STOP_DATA);
} else if (real_pos >= 0) { } else if (real_pos >= 0) {
data = i2c_op(pd, OP_RX, 0); data = i2c_op(pd, OP_RX);
} }
if (real_pos >= 0) if (real_pos >= 0)
...@@ -687,7 +680,7 @@ static int sh_mobile_i2c_xfer(struct i2c_adapter *adapter, ...@@ -687,7 +680,7 @@ static int sh_mobile_i2c_xfer(struct i2c_adapter *adapter,
start_ch(pd, msg, do_start); start_ch(pd, msg, do_start);
if (do_start) if (do_start)
i2c_op(pd, OP_START, 0); i2c_op(pd, OP_START);
/* The interrupt handler takes care of the rest... */ /* The interrupt handler takes care of the rest... */
timeout = wait_event_timeout(pd->wait, timeout = wait_event_timeout(pd->wait,
......
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