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

i2c: rcar: refactor setup of a msg

We want to reuse this function later.
Signed-off-by: default avatarWolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: default avatarWolfram Sang <wsa@the-dreams.de>
parent ff2316b8
...@@ -106,7 +106,8 @@ enum rcar_i2c_type { ...@@ -106,7 +106,8 @@ enum rcar_i2c_type {
struct rcar_i2c_priv { struct rcar_i2c_priv {
void __iomem *io; void __iomem *io;
struct i2c_adapter adap; struct i2c_adapter adap;
struct i2c_msg *msg; struct i2c_msg *msg;
int msgs_left;
struct clk *clk; struct clk *clk;
wait_queue_head_t wait; wait_queue_head_t wait;
...@@ -255,6 +256,11 @@ static void rcar_i2c_prepare_msg(struct rcar_i2c_priv *priv) ...@@ -255,6 +256,11 @@ static void rcar_i2c_prepare_msg(struct rcar_i2c_priv *priv)
{ {
int read = !!rcar_i2c_is_recv(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, ICMAR, (priv->msg->addr << 1) | read);
rcar_i2c_write(priv, ICMSR, 0); rcar_i2c_write(priv, ICMSR, 0);
rcar_i2c_write(priv, ICMCR, RCAR_BUS_PHASE_START); rcar_i2c_write(priv, ICMCR, RCAR_BUS_PHASE_START);
...@@ -499,11 +505,8 @@ static int rcar_i2c_master_xfer(struct i2c_adapter *adap, ...@@ -499,11 +505,8 @@ static int rcar_i2c_master_xfer(struct i2c_adapter *adap,
} }
/* init each data */ /* init each data */
priv->msg = &msgs[i]; priv->msg = &msgs[i];
priv->pos = 0; priv->msgs_left = num - i;
priv->flags = 0;
if (i == num - 1)
rcar_i2c_flags_set(priv, ID_LAST_MSG);
rcar_i2c_prepare_msg(priv); rcar_i2c_prepare_msg(priv);
......
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