Commit 42c0783b authored by Wolfram Sang's avatar Wolfram Sang Committed by Wolfram Sang

i2c: rcar: remove macros dealing with flags

These macros don't really hide complexity, but C idioms. Removing them
makes the code easier to read IMO and make a planned extension easier.
Acked-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: default avatarWolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: default avatarWolfram Sang <wsa@the-dreams.de>
parent 0c739738
...@@ -122,9 +122,6 @@ struct rcar_i2c_priv { ...@@ -122,9 +122,6 @@ struct rcar_i2c_priv {
#define rcar_i2c_priv_to_dev(p) ((p)->adap.dev.parent) #define rcar_i2c_priv_to_dev(p) ((p)->adap.dev.parent)
#define rcar_i2c_is_recv(p) ((p)->msg->flags & I2C_M_RD) #define rcar_i2c_is_recv(p) ((p)->msg->flags & I2C_M_RD)
#define rcar_i2c_flags_set(p, f) ((p)->flags |= (f))
#define rcar_i2c_flags_has(p, f) ((p)->flags & (f))
#define LOOP_TIMEOUT 1024 #define LOOP_TIMEOUT 1024
...@@ -258,7 +255,7 @@ static void rcar_i2c_prepare_msg(struct rcar_i2c_priv *priv) ...@@ -258,7 +255,7 @@ static void rcar_i2c_prepare_msg(struct rcar_i2c_priv *priv)
priv->pos = 0; priv->pos = 0;
if (priv->msgs_left == 1) if (priv->msgs_left == 1)
rcar_i2c_flags_set(priv, ID_LAST_MSG); priv->flags |= ID_LAST_MSG;
rcar_i2c_write(priv, ICMAR, (priv->msg->addr << 1) | read); rcar_i2c_write(priv, ICMAR, (priv->msg->addr << 1) | read);
/* /*
...@@ -266,7 +263,7 @@ static void rcar_i2c_prepare_msg(struct rcar_i2c_priv *priv) ...@@ -266,7 +263,7 @@ static void rcar_i2c_prepare_msg(struct rcar_i2c_priv *priv)
* of ICMSR and ICMCR depends on whether we issue START or REP_START. Since * of ICMSR and ICMCR depends on whether we issue START or REP_START. Since
* it didn't cause a drawback for me, let's rather be safe than sorry. * it didn't cause a drawback for me, let's rather be safe than sorry.
*/ */
if (rcar_i2c_flags_has(priv, ID_FIRST_MSG)) { if (priv->flags & ID_FIRST_MSG) {
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);
} else { } else {
...@@ -438,7 +435,7 @@ static irqreturn_t rcar_i2c_irq(int irq, void *ptr) ...@@ -438,7 +435,7 @@ static irqreturn_t rcar_i2c_irq(int irq, void *ptr)
/* Arbitration lost */ /* Arbitration lost */
if (msr & MAL) { if (msr & MAL) {
rcar_i2c_flags_set(priv, (ID_DONE | ID_ARBLOST)); priv->flags |= ID_DONE | ID_ARBLOST;
goto out; goto out;
} }
...@@ -446,14 +443,14 @@ static irqreturn_t rcar_i2c_irq(int irq, void *ptr) ...@@ -446,14 +443,14 @@ static irqreturn_t rcar_i2c_irq(int irq, void *ptr)
if (msr & MNR) { if (msr & MNR) {
/* HW automatically sends STOP after received NACK */ /* HW automatically sends STOP after received NACK */
rcar_i2c_write(priv, ICMIER, RCAR_IRQ_STOP); rcar_i2c_write(priv, ICMIER, RCAR_IRQ_STOP);
rcar_i2c_flags_set(priv, ID_NACK); priv->flags |= ID_NACK;
goto out; goto out;
} }
/* Stop */ /* Stop */
if (msr & MST) { if (msr & MST) {
priv->msgs_left--; /* The last message also made it */ priv->msgs_left--; /* The last message also made it */
rcar_i2c_flags_set(priv, ID_DONE); priv->flags |= ID_DONE;
goto out; goto out;
} }
...@@ -463,7 +460,7 @@ static irqreturn_t rcar_i2c_irq(int irq, void *ptr) ...@@ -463,7 +460,7 @@ static irqreturn_t rcar_i2c_irq(int irq, void *ptr)
rcar_i2c_irq_send(priv, msr); rcar_i2c_irq_send(priv, msr);
out: out:
if (rcar_i2c_flags_has(priv, ID_DONE)) { if (priv->flags & ID_DONE) {
rcar_i2c_write(priv, ICMIER, 0); rcar_i2c_write(priv, ICMIER, 0);
rcar_i2c_write(priv, ICMSR, 0); rcar_i2c_write(priv, ICMSR, 0);
wake_up(&priv->wait); wake_up(&priv->wait);
...@@ -501,15 +498,14 @@ static int rcar_i2c_master_xfer(struct i2c_adapter *adap, ...@@ -501,15 +498,14 @@ static int rcar_i2c_master_xfer(struct i2c_adapter *adap,
priv->flags = ID_FIRST_MSG; priv->flags = ID_FIRST_MSG;
rcar_i2c_prepare_msg(priv); rcar_i2c_prepare_msg(priv);
time_left = wait_event_timeout(priv->wait, time_left = wait_event_timeout(priv->wait, priv->flags & ID_DONE,
rcar_i2c_flags_has(priv, ID_DONE),
num * adap->timeout); num * adap->timeout);
if (!time_left) { if (!time_left) {
rcar_i2c_init(priv); rcar_i2c_init(priv);
ret = -ETIMEDOUT; ret = -ETIMEDOUT;
} else if (rcar_i2c_flags_has(priv, ID_NACK)) { } else if (priv->flags & ID_NACK) {
ret = -ENXIO; ret = -ENXIO;
} else if (rcar_i2c_flags_has(priv, ID_ARBLOST)) { } else if (priv->flags & ID_ARBLOST) {
ret = -EAGAIN; ret = -EAGAIN;
} else { } else {
ret = num - priv->msgs_left; /* The number of transfer */ ret = num - priv->msgs_left; /* The number of transfer */
......
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