Changeset 3878

Show
Ignore:
Timestamp:
12/20/03 01:18:27 (9 years ago)
Author:
mds
Message:

tweaks to emulation patch.

  • add I2C_M_RECV_PEC flag so adapter will receive one extra byte
  • add PEC functionality to algo-bit
  • copy over only what's necessary on read in i2c-core
Location:
i2c/trunk/kernel
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • i2c/trunk/kernel/i2c-algo-bit.c

    r3877 r3878  
    402402                                count = inval + 1;      /* plus one for [Count] itself */ 
    403403                                msg->len = count; 
     404                                if (msg->flags & I2C_M_RECV_PEC) 
     405                                        count++; /* plus one for PEC */ 
    404406                        } else { 
    405407                                printk(KERN_ERR "i2c-algo-bit.o: readbytes: bad block count (%d).\n", inval); 
     
    537539               I2C_FUNC_PROTOCOL_MANGLING | 
    538540               I2C_FUNC_SMBUS_BLOCK_PROC_CALL | 
    539                I2C_FUNC_SMBUS_READ_BLOCK_DATA; 
     541               I2C_FUNC_SMBUS_READ_BLOCK_DATA | 
     542               I2C_FUNC_SMBUS_BLOCK_PROC_CALL_PEC | 
     543               I2C_FUNC_SMBUS_READ_BLOCK_DATA_PEC; 
    540544} 
    541545 
  • i2c/trunk/kernel/i2c-core.c

    r3877 r3878  
    12091209          most things with sane defaults, to keep the code below somewhat 
    12101210          simpler. */ 
    1211         unsigned char msgbuf0[34]; 
    1212         unsigned char msgbuf1[34]; 
     1211        unsigned char msgbuf0[I2C_SMBUS_BLOCK_MAX+2]; 
     1212        unsigned char msgbuf1[I2C_SMBUS_BLOCK_MAX+2]; 
    12131213        int num = read_write == I2C_SMBUS_READ?2:1; 
    12141214        struct i2c_msg msg[2] = { { addr, flags, 1, msgbuf0 },  
    12151215                                  { addr, flags | I2C_M_RD, 0, msgbuf1 } 
    12161216                                }; 
    1217         int i; 
     1217        int i, len; 
    12181218 
    12191219        msgbuf0[0] = command; 
     
    12711271                        msg[1].flags |= I2C_M_RECV_LEN; 
    12721272                        msg[1].len = I2C_SMBUS_BLOCK_MAX + 1; 
    1273                         if (size == I2C_SMBUS_BLOCK_DATA_PEC) 
     1273                        if (size == I2C_SMBUS_BLOCK_DATA_PEC) { 
    12741274                                msg[1].len++; 
     1275                                msg[1].flags |= I2C_M_RECV_PEC; 
     1276                        } 
    12751277                } else { 
    12761278                        msg[0].len = data->block[0] + 2; 
     
    13121314                msg[1].flags |= I2C_M_RECV_LEN; 
    13131315                msg[1].len = I2C_SMBUS_BLOCK_MAX + 1; 
    1314                 if (size == I2C_SMBUS_BLOCK_PROC_CALL_PEC) 
     1316                if (size == I2C_SMBUS_BLOCK_PROC_CALL_PEC) { 
    13151317                        msg[1].len++; 
     1318                        msg[1].flags |= I2C_M_RECV_PEC; 
     1319                } 
    13161320                break; 
    13171321        case I2C_SMBUS_I2C_BLOCK_DATA: 
     
    13581362                                break; 
    13591363                        case I2C_SMBUS_BLOCK_DATA: 
     1364                        case I2C_SMBUS_BLOCK_PROC_CALL: 
    13601365                        case I2C_SMBUS_BLOCK_DATA_PEC: 
    1361                         case I2C_SMBUS_BLOCK_PROC_CALL: 
    13621366                        case I2C_SMBUS_BLOCK_PROC_CALL_PEC: 
    1363                                 for (i = 0; i < I2C_SMBUS_BLOCK_MAX + 2; i++) 
     1367                                len = msgbuf1[0] + 1; 
     1368                                if(size == I2C_SMBUS_BLOCK_DATA_PEC || 
     1369                                   size == I2C_SMBUS_BLOCK_PROC_CALL_PEC) 
     1370                                        len++; 
     1371                                for (i = 0; i < len; i++) 
    13641372                                        data->block[i] = msgbuf1[i]; 
    13651373                                break; 
  • i2c/trunk/kernel/i2c.h

    r3877 r3878  
    362362#define I2C_M_IGNORE_NAK        0x1000 
    363363#define I2C_M_NO_RD_ACK         0x0800 
    364 #define I2C_M_RECV_LEN          0x0400 
     364#define I2C_M_RECV_LEN          0x0400 /* length will be first received byte */ 
     365#define I2C_M_RECV_PEC          0x0200 /* receive one more than the returned 
     366                                          length byte for the PEC */ 
    365367        __u16 len;              /* msg length                           */ 
    366368        __u8 *buf;              /* pointer to msg data                  */