diff options
author | Wolfram Sang <wsa+renesas@sang-engineering.com> | 2015-09-03 22:20:08 +0200 |
---|---|---|
committer | Wolfram Sang <wsa@the-dreams.de> | 2015-10-09 23:30:32 +0200 |
commit | 344beeb23bfc11502fc54875f37ccdf51b6639b9 (patch) | |
tree | 31f0b06eb1a265d8f79461e9bbd3bb6559a88894 /drivers/i2c/busses/i2c-rcar.c | |
parent | i2c: rcar: remove spinlock (diff) | |
download | linux-344beeb23bfc11502fc54875f37ccdf51b6639b9.tar.xz linux-344beeb23bfc11502fc54875f37ccdf51b6639b9.zip |
i2c: rcar: refactor setup of a msg
We want to reuse this function later.
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
Diffstat (limited to 'drivers/i2c/busses/i2c-rcar.c')
-rw-r--r-- | drivers/i2c/busses/i2c-rcar.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/drivers/i2c/busses/i2c-rcar.c b/drivers/i2c/busses/i2c-rcar.c index e65418b34d86..6e459a338ccc 100644 --- a/drivers/i2c/busses/i2c-rcar.c +++ b/drivers/i2c/busses/i2c-rcar.c @@ -106,7 +106,8 @@ enum rcar_i2c_type { struct rcar_i2c_priv { void __iomem *io; struct i2c_adapter adap; - struct i2c_msg *msg; + struct i2c_msg *msg; + int msgs_left; struct clk *clk; wait_queue_head_t wait; @@ -254,6 +255,11 @@ static void rcar_i2c_prepare_msg(struct rcar_i2c_priv *priv) { int read = !!rcar_i2c_is_recv(priv); + priv->pos = 0; + priv->flags = 0; + if (priv->msgs_left == 1) + rcar_i2c_flags_set(priv, ID_LAST_MSG); + rcar_i2c_write(priv, ICMAR, (priv->msg->addr << 1) | read); rcar_i2c_write(priv, ICMSR, 0); rcar_i2c_write(priv, ICMCR, RCAR_BUS_PHASE_START); @@ -498,11 +504,8 @@ static int rcar_i2c_master_xfer(struct i2c_adapter *adap, } /* init each data */ - priv->msg = &msgs[i]; - priv->pos = 0; - priv->flags = 0; - if (i == num - 1) - rcar_i2c_flags_set(priv, ID_LAST_MSG); + priv->msg = &msgs[i]; + priv->msgs_left = num - i; rcar_i2c_prepare_msg(priv); |