From: Felipe Balbi <ba...@ti.com>

this is important in cases where client driver
wants to know how many bytes were actually
transferred.

Signed-off-by: Felipe Balbi <ba...@ti.com>
Signed-off-by: Shubhrajyoti D <shubhrajy...@ti.com>
---
 drivers/i2c/busses/i2c-omap.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index 266bba7..fc726a6 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -189,6 +189,7 @@ struct omap_i2c_dev {
        u8                      *buf;
        u8                      *regs;
        size_t                  buf_len;
+       u16                     actual;
        struct i2c_adapter      adapter;
        u8                      threshold;
        u8                      fifo_size;      /* use as flag and value
@@ -601,6 +602,7 @@ static int omap_i2c_xfer_msg(struct i2c_adapter *adap,
                omap_i2c_init(dev);
                return -ETIMEDOUT;
        }
+       msg->actual = dev->actual;
 
        if (likely(!dev->cmd_err))
                return 0;
@@ -828,6 +830,7 @@ static void omap_i2c_receive_data(struct omap_i2c_dev *dev, 
u8 num_bytes,
                w = omap_i2c_read_reg(dev, OMAP_I2C_DATA_REG);
                *dev->buf++ = w;
                dev->buf_len--;
+               dev->actual++;
 
                /*
                 * Data reg in 2430, omap3 and
@@ -848,6 +851,7 @@ static int omap_i2c_transmit_data(struct omap_i2c_dev *dev, 
u8 num_bytes,
        while (num_bytes--) {
                w = *dev->buf++;
                dev->buf_len--;
+               dev->actual++;
 
                /*
                 * Data reg in 2430, omap3 and
@@ -908,6 +912,7 @@ omap_i2c_isr(int this_irq, void *dev_id)
 
                if (stat & OMAP_I2C_STAT_NACK) {
                        err |= OMAP_I2C_STAT_NACK;
+                       dev->actual--;
                        omap_i2c_ack_stat(dev, OMAP_I2C_STAT_NACK);
                        goto out;
                }
-- 
1.7.5.4

--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to