Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=91f27958d686da713c3b0a1dc205288898e44124
Commit:     91f27958d686da713c3b0a1dc205288898e44124
Parent:     4bd28ebda2d48f16c1f16ff936a6927a4ef2194d
Author:     Manuel Lauss <[EMAIL PROTECTED]>
AuthorDate: Sun Jan 27 18:14:52 2008 +0100
Committer:  Jean Delvare <[EMAIL PROTECTED]>
CommitDate: Sun Jan 27 18:14:52 2008 +0100

    i2c-au1550: properly terminate zero-byte transfers
    
    Zero-bytes transfers would leave the bus transaction unfinished
    (no i2c stop is sent), with the following transfer actually
    sending the slave address to the previously addressed device,
    resulting in weird device failures (e.g. reset minute register
    values in my RTC).
    This patch instructs the controller to send an I2C STOP right after
    the slave address in case of a zero-byte transfer.
    
    Signed-off-by: Manuel Lauss <[EMAIL PROTECTED]>
    Signed-off-by: Jean Delvare <[EMAIL PROTECTED]>
---
 drivers/i2c/busses/i2c-au1550.c |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/i2c/busses/i2c-au1550.c b/drivers/i2c/busses/i2c-au1550.c
index 2f68416..7d51a43 100644
--- a/drivers/i2c/busses/i2c-au1550.c
+++ b/drivers/i2c/busses/i2c-au1550.c
@@ -105,7 +105,7 @@ wait_master_done(struct i2c_au1550_data *adap)
 }
 
 static int
-do_address(struct i2c_au1550_data *adap, unsigned int addr, int rd)
+do_address(struct i2c_au1550_data *adap, unsigned int addr, int rd, int q)
 {
        volatile psc_smb_t      *sp;
        u32                     stat;
@@ -134,6 +134,10 @@ do_address(struct i2c_au1550_data *adap, unsigned int 
addr, int rd)
        if (rd)
                addr |= 1;
 
+       /* zero-byte xfers stop immediately */
+       if (q)
+               addr |= PSC_SMBTXRX_STP;
+
        /* Put byte into fifo, start up master.
        */
        sp->psc_smbtxrx = addr;
@@ -142,7 +146,7 @@ do_address(struct i2c_au1550_data *adap, unsigned int addr, 
int rd)
        au_sync();
        if (wait_ack(adap))
                return -EIO;
-       return 0;
+       return (q) ? wait_master_done(adap) : 0;
 }
 
 static u32
@@ -262,7 +266,8 @@ au1550_xfer(struct i2c_adapter *i2c_adap, struct i2c_msg 
*msgs, int num)
 
        for (i = 0; !err && i < num; i++) {
                p = &msgs[i];
-               err = do_address(adap, p->addr, p->flags & I2C_M_RD);
+               err = do_address(adap, p->addr, p->flags & I2C_M_RD,
+                                (p->len == 0));
                if (err || !p->len)
                        continue;
                if (p->flags & I2C_M_RD)
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to