aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c
diff options
context:
space:
mode:
authorHeiner Kallweit <hkallweit1@gmail.com>2017-03-25 09:14:08 -0400
committerWolfram Sang <wsa@the-dreams.de>2017-03-30 11:31:29 -0400
commitcda816d163e08abb698f10ec32aa2d173ad93e7f (patch)
tree03b9791ebb63b422b68f419baa8bffe142a2a24a /drivers/i2c
parent3911764cfbe7f5d229498d818aa2eff6e5611da8 (diff)
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>
Diffstat (limited to 'drivers/i2c')
-rw-r--r--drivers/i2c/busses/i2c-meson.c40
1 files changed, 10 insertions, 30 deletions
diff --git a/drivers/i2c/busses/i2c-meson.c b/drivers/i2c/busses/i2c-meson.c
index be9f83bd92fc..88d15b92ec35 100644
--- a/drivers/i2c/busses/i2c-meson.c
+++ b/drivers/i2c/busses/i2c-meson.c
@@ -242,41 +242,21 @@ static irqreturn_t meson_i2c_irq(int irqno, void *dev_id)
242 goto out; 242 goto out;
243 } 243 }
244 244
245 switch (i2c->state) { 245 if (i2c->state == STATE_READ && i2c->count)
246 case STATE_READ: 246 meson_i2c_get_data(i2c, i2c->msg->buf + i2c->pos, i2c->count);
247 if (i2c->count > 0) {
248 meson_i2c_get_data(i2c, i2c->msg->buf + i2c->pos,
249 i2c->count);
250 i2c->pos += i2c->count;
251 }
252
253 if (i2c->pos >= i2c->msg->len) {
254 i2c->state = STATE_IDLE;
255 complete(&i2c->done);
256 break;
257 }
258
259 meson_i2c_prepare_xfer(i2c);
260 break;
261 case STATE_WRITE:
262 i2c->pos += i2c->count;
263 247
264 if (i2c->pos >= i2c->msg->len) { 248 i2c->pos += i2c->count;
265 i2c->state = STATE_IDLE;
266 complete(&i2c->done);
267 break;
268 }
269 249
270 meson_i2c_prepare_xfer(i2c); 250 if (i2c->pos >= i2c->msg->len) {
271 break; 251 i2c->state = STATE_IDLE;
252 complete(&i2c->done);
253 goto out;
272 } 254 }
273 255
256 /* Restart the processing */
257 meson_i2c_prepare_xfer(i2c);
258 meson_i2c_set_mask(i2c, REG_CTRL, REG_CTRL_START, REG_CTRL_START);
274out: 259out:
275 if (i2c->state != STATE_IDLE)
276 /* Restart the processing */
277 meson_i2c_set_mask(i2c, REG_CTRL, REG_CTRL_START,
278 REG_CTRL_START);
279
280 spin_unlock(&i2c->lock); 260 spin_unlock(&i2c->lock);
281 261
282 return IRQ_HANDLED; 262 return IRQ_HANDLED;