i2c: meson: improve and simplify interrupt handler
The preceding changes in this patch series now allow to simplify the interrupt handler significantly. Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
This commit is contained in:
parent
3911764cfb
commit
cda816d163
|
@ -242,41 +242,21 @@ static irqreturn_t meson_i2c_irq(int irqno, void *dev_id)
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (i2c->state) {
|
if (i2c->state == STATE_READ && i2c->count)
|
||||||
case STATE_READ:
|
meson_i2c_get_data(i2c, i2c->msg->buf + i2c->pos, i2c->count);
|
||||||
if (i2c->count > 0) {
|
|
||||||
meson_i2c_get_data(i2c, i2c->msg->buf + i2c->pos,
|
|
||||||
i2c->count);
|
|
||||||
i2c->pos += i2c->count;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (i2c->pos >= i2c->msg->len) {
|
|
||||||
i2c->state = STATE_IDLE;
|
|
||||||
complete(&i2c->done);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
meson_i2c_prepare_xfer(i2c);
|
|
||||||
break;
|
|
||||||
case STATE_WRITE:
|
|
||||||
i2c->pos += i2c->count;
|
i2c->pos += i2c->count;
|
||||||
|
|
||||||
if (i2c->pos >= i2c->msg->len) {
|
if (i2c->pos >= i2c->msg->len) {
|
||||||
i2c->state = STATE_IDLE;
|
i2c->state = STATE_IDLE;
|
||||||
complete(&i2c->done);
|
complete(&i2c->done);
|
||||||
break;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
meson_i2c_prepare_xfer(i2c);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
out:
|
|
||||||
if (i2c->state != STATE_IDLE)
|
|
||||||
/* Restart the processing */
|
/* Restart the processing */
|
||||||
meson_i2c_set_mask(i2c, REG_CTRL, REG_CTRL_START,
|
meson_i2c_prepare_xfer(i2c);
|
||||||
REG_CTRL_START);
|
meson_i2c_set_mask(i2c, REG_CTRL, REG_CTRL_START, REG_CTRL_START);
|
||||||
|
out:
|
||||||
spin_unlock(&i2c->lock);
|
spin_unlock(&i2c->lock);
|
||||||
|
|
||||||
return IRQ_HANDLED;
|
return IRQ_HANDLED;
|
||||||
|
|
Loading…
Reference in New Issue