diff mbox series

[RFC/RFT,2/7] i2c: sh_mobile: remove get_data function

Message ID 20190116210555.12209-3-wsa+renesas@sang-engineering.com
State Accepted
Headers show
Series i2c: sh_mobile: state machine simplifications | expand

Commit Message

Wolfram Sang Jan. 16, 2019, 9:05 p.m. UTC
It makes the code much easier comprehensible to explicitly code that the
first byte will be client address and all the following bytes are the
actual data.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
 drivers/i2c/busses/i2c-sh_mobile.c | 23 ++++++++---------------
 1 file changed, 8 insertions(+), 15 deletions(-)

Comments

Geert Uytterhoeven Jan. 17, 2019, 10:25 a.m. UTC | #1
On Thu, Jan 17, 2019 at 1:36 AM Wolfram Sang
<wsa+renesas@sang-engineering.com> wrote:
> It makes the code much easier comprehensible to explicitly code that the
> first byte will be client address and all the following bytes are the
> actual data.
>
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>

Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>

Gr{oetje,eeting}s,

                        Geert
diff mbox series

Patch

diff --git a/drivers/i2c/busses/i2c-sh_mobile.c b/drivers/i2c/busses/i2c-sh_mobile.c
index e18e3cedf817..27b57b376549 100644
--- a/drivers/i2c/busses/i2c-sh_mobile.c
+++ b/drivers/i2c/busses/i2c-sh_mobile.c
@@ -358,18 +358,6 @@  static bool sh_mobile_i2c_is_first_byte(struct sh_mobile_i2c_data *pd)
 	return pd->pos == -1;
 }
 
-static void sh_mobile_i2c_get_data(struct sh_mobile_i2c_data *pd,
-				   unsigned char *buf)
-{
-	switch (pd->pos) {
-	case -1:
-		*buf = i2c_8bit_addr_from_msg(pd->msg);
-		break;
-	default:
-		*buf = pd->msg->buf[pd->pos];
-	}
-}
-
 static int sh_mobile_i2c_isr_tx(struct sh_mobile_i2c_data *pd)
 {
 	unsigned char data;
@@ -379,8 +367,13 @@  static int sh_mobile_i2c_isr_tx(struct sh_mobile_i2c_data *pd)
 		return 1;
 	}
 
-	sh_mobile_i2c_get_data(pd, &data);
-	i2c_op(pd, sh_mobile_i2c_is_first_byte(pd) ? OP_TX_FIRST : OP_TX, data);
+	if (sh_mobile_i2c_is_first_byte(pd)) {
+		data = i2c_8bit_addr_from_msg(pd->msg);
+		i2c_op(pd, OP_TX_FIRST, data);
+	} else {
+		data = pd->msg->buf[pd->pos];
+		i2c_op(pd, OP_TX, data);
+	}
 
 	pd->pos++;
 	return 0;
@@ -393,7 +386,7 @@  static int sh_mobile_i2c_isr_rx(struct sh_mobile_i2c_data *pd)
 
 	do {
 		if (sh_mobile_i2c_is_first_byte(pd)) {
-			sh_mobile_i2c_get_data(pd, &data);
+			data = i2c_8bit_addr_from_msg(pd->msg);
 			i2c_op(pd, OP_TX_FIRST, data);
 			break;
 		}