From: Wolfram Sang <wsa+renesas@sang-engineering.com>
To: linux-i2c@vger.kernel.org
Cc: linux-renesas-soc@vger.kernel.org,
Wolfram Sang <wsa+renesas@sang-engineering.com>
Subject: [RFC/RFT 3/7] i2c: sh_mobile: drop 'data' argument from i2c_op function
Date: Wed, 16 Jan 2019 22:05:51 +0100 [thread overview]
Message-ID: <20190116210555.12209-4-wsa+renesas@sang-engineering.com> (raw)
In-Reply-To: <20190116210555.12209-1-wsa+renesas@sang-engineering.com>
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: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
drivers/i2c/busses/i2c-sh_mobile.c | 41 ++++++++++++++++----------------------
1 file changed, 17 insertions(+), 24 deletions(-)
diff --git a/drivers/i2c/busses/i2c-sh_mobile.c b/drivers/i2c/busses/i2c-sh_mobile.c
index 27b57b376549..ae5804c12998 100644
--- a/drivers/i2c/busses/i2c-sh_mobile.c
+++ b/drivers/i2c/busses/i2c-sh_mobile.c
@@ -303,13 +303,12 @@ static int sh_mobile_i2c_v2_init(struct sh_mobile_i2c_data *pd)
return sh_mobile_i2c_check_timing(pd);
}
-static unsigned char i2c_op(struct sh_mobile_i2c_data *pd,
- enum sh_mobile_i2c_op op, unsigned char data)
+static unsigned char i2c_op(struct sh_mobile_i2c_data *pd, enum sh_mobile_i2c_op op)
{
unsigned char ret = 0;
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);
@@ -317,12 +316,12 @@ static unsigned char i2c_op(struct sh_mobile_i2c_data *pd,
case OP_START: /* issue start and trigger DTE interrupt */
iic_wr(pd, ICCR, ICCR_ICE | ICCR_TRS | ICCR_BBSY);
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, ICDR, data);
+ iic_wr(pd, ICDR, i2c_8bit_addr_from_msg(pd->msg));
break;
case OP_TX: /* write data */
- iic_wr(pd, ICDR, data);
+ iic_wr(pd, ICDR, pd->msg->buf[pd->pos]);
break;
case OP_TX_STOP: /* issue a stop (or rep_start) */
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)
static int sh_mobile_i2c_isr_tx(struct sh_mobile_i2c_data *pd)
{
- unsigned char data;
-
if (pd->pos == pd->msg->len) {
- i2c_op(pd, OP_TX_STOP, 0);
+ i2c_op(pd, OP_TX_STOP);
return 1;
}
- 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);
- }
+ if (sh_mobile_i2c_is_first_byte(pd))
+ i2c_op(pd, OP_TX_FIRST);
+ else
+ i2c_op(pd, OP_TX);
pd->pos++;
return 0;
@@ -386,13 +380,12 @@ static int sh_mobile_i2c_isr_rx(struct sh_mobile_i2c_data *pd)
do {
if (sh_mobile_i2c_is_first_byte(pd)) {
- data = i2c_8bit_addr_from_msg(pd->msg);
- i2c_op(pd, OP_TX_FIRST, data);
+ i2c_op(pd, OP_TX_FIRST);
break;
}
if (pd->pos == 0) {
- i2c_op(pd, OP_TX_TO_RX, 0);
+ i2c_op(pd, OP_TX_TO_RX);
break;
}
@@ -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->stop_after_dma) {
/* Simulate PIO end condition after DMA transfer */
- i2c_op(pd, OP_RX_STOP, 0);
+ i2c_op(pd, OP_RX_STOP);
pd->pos++;
break;
}
if (real_pos < 0) {
- i2c_op(pd, OP_RX_STOP, 0);
+ i2c_op(pd, OP_RX_STOP);
break;
}
- data = i2c_op(pd, OP_RX_STOP_DATA, 0);
+ data = i2c_op(pd, OP_RX_STOP_DATA);
} else if (real_pos >= 0) {
- data = i2c_op(pd, OP_RX, 0);
+ data = i2c_op(pd, OP_RX);
}
if (real_pos >= 0)
@@ -687,7 +680,7 @@ static int sh_mobile_i2c_xfer(struct i2c_adapter *adapter,
start_ch(pd, msg, do_start);
if (do_start)
- i2c_op(pd, OP_START, 0);
+ i2c_op(pd, OP_START);
/* The interrupt handler takes care of the rest... */
timeout = wait_event_timeout(pd->wait,
--
2.11.0
next prev parent reply other threads:[~2019-01-16 21:06 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-16 21:05 [RFC/RFT 0/7] i2c: sh_mobile: state machine simplifications Wolfram Sang
2019-01-16 21:05 ` [RFC/RFT 1/7] i2c: sh_mobile: simplify sending address for RX Wolfram Sang
2019-01-17 10:11 ` Geert Uytterhoeven
2019-01-17 10:18 ` Wolfram Sang
2019-01-17 10:23 ` Geert Uytterhoeven
2019-01-16 21:05 ` [RFC/RFT 2/7] i2c: sh_mobile: remove get_data function Wolfram Sang
2019-01-17 10:25 ` Geert Uytterhoeven
2019-01-16 21:05 ` Wolfram Sang [this message]
2019-01-17 10:30 ` [RFC/RFT 3/7] i2c: sh_mobile: drop 'data' argument from i2c_op function Geert Uytterhoeven
2019-01-16 21:05 ` [RFC/RFT 4/7] i2c: sh_mobile: remove is_first_byte function Wolfram Sang
2019-01-17 10:30 ` Geert Uytterhoeven
2019-01-16 21:05 ` [RFC/RFT 5/7] i2c: sh_mobile: replace break; with if-block Wolfram Sang
2019-01-17 10:32 ` Geert Uytterhoeven
2019-01-16 21:05 ` [RFC/RFT 6/7] i2c: sh_mobile: refactor rx isr Wolfram Sang
2019-01-17 10:36 ` Geert Uytterhoeven
2019-01-16 21:05 ` [RFC/RFT 7/7] i2c: sh_mobile: update copyright and comments Wolfram Sang
2019-01-17 10:41 ` Geert Uytterhoeven
2019-01-17 17:05 ` Wolfram Sang
2019-01-18 8:34 ` Geert Uytterhoeven
2019-01-18 10:16 ` Wolfram Sang
2019-01-22 23:12 ` [RFC/RFT 0/7] i2c: sh_mobile: state machine simplifications Wolfram Sang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190116210555.12209-4-wsa+renesas@sang-engineering.com \
--to=wsa+renesas@sang-engineering.com \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).