Commit 3f205d7b authored by Heiner Kallweit's avatar Heiner Kallweit Committed by Wolfram Sang

i2c: meson: don't create separate token chain just for the stop command

We can directly add the stop token to the token chain including the
last transfer chunk. This is more efficient than creating a separate
token chain just for the stop command.
And it allows us to get rid of state STATE_STOP completely.
Signed-off-by: default avatarHeiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: default avatarWolfram Sang <wsa@the-dreams.de>
parent 38ed55ca
...@@ -55,7 +55,6 @@ enum { ...@@ -55,7 +55,6 @@ enum {
STATE_IDLE, STATE_IDLE,
STATE_READ, STATE_READ,
STATE_WRITE, STATE_WRITE,
STATE_STOP,
}; };
/** /**
...@@ -208,19 +207,9 @@ static void meson_i2c_prepare_xfer(struct meson_i2c *i2c) ...@@ -208,19 +207,9 @@ static void meson_i2c_prepare_xfer(struct meson_i2c *i2c)
if (write) if (write)
meson_i2c_put_data(i2c, i2c->msg->buf + i2c->pos, i2c->count); meson_i2c_put_data(i2c, i2c->msg->buf + i2c->pos, i2c->count);
}
static void meson_i2c_stop(struct meson_i2c *i2c)
{
dev_dbg(i2c->dev, "%s: last %d\n", __func__, i2c->last);
if (i2c->last) { if (i2c->last && i2c->pos + i2c->count >= i2c->msg->len)
i2c->state = STATE_STOP;
meson_i2c_add_token(i2c, TOKEN_STOP); meson_i2c_add_token(i2c, TOKEN_STOP);
} else {
i2c->state = STATE_IDLE;
complete(&i2c->done);
}
} }
static irqreturn_t meson_i2c_irq(int irqno, void *dev_id) static irqreturn_t meson_i2c_irq(int irqno, void *dev_id)
...@@ -265,7 +254,8 @@ static irqreturn_t meson_i2c_irq(int irqno, void *dev_id) ...@@ -265,7 +254,8 @@ static irqreturn_t meson_i2c_irq(int irqno, void *dev_id)
} }
if (i2c->pos >= i2c->msg->len) { if (i2c->pos >= i2c->msg->len) {
meson_i2c_stop(i2c); i2c->state = STATE_IDLE;
complete(&i2c->done);
break; break;
} }
...@@ -275,16 +265,13 @@ static irqreturn_t meson_i2c_irq(int irqno, void *dev_id) ...@@ -275,16 +265,13 @@ static irqreturn_t meson_i2c_irq(int irqno, void *dev_id)
i2c->pos += i2c->count; i2c->pos += i2c->count;
if (i2c->pos >= i2c->msg->len) { if (i2c->pos >= i2c->msg->len) {
meson_i2c_stop(i2c); i2c->state = STATE_IDLE;
complete(&i2c->done);
break; break;
} }
meson_i2c_prepare_xfer(i2c); meson_i2c_prepare_xfer(i2c);
break; break;
case STATE_STOP:
i2c->state = STATE_IDLE;
complete(&i2c->done);
break;
} }
out: out:
......
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