On Tue, 14 Jun 2011 14:39:24 +0800, Kassey Lee wrote:
> hi, Jean:
>
>
> here is the structur of i2c_msg,
>
> struct i2c_msg {
> __u16 addr; /* slave address */
> __u16 flags;
> #define I2C_M_TEN 0x0010 /* this is a ten bit chip address */
> #define I2C_M_RD 0x0001 /* read data, from slave to master */
> #define I2C_M_NOSTART 0x4000 /* if I2C_FUNC_PROTOCOL_MANGLING */
> #define I2C_M_REV_DIR_ADDR 0x2000 /* if I2C_FUNC_PROTOCOL_MANGLING */
> #define I2C_M_IGNORE_NAK 0x1000 /* if I2C_FUNC_PROTOCOL_MANGLING */
> #define I2C_M_NO_RD_ACK 0x0800 /* if I2C_FUNC_PROTOCOL_MANGLING */
> #define I2C_M_RECV_LEN 0x0400 /* length will be first received byte
> */
> __u16 len; /* msg length */
> __u8 *buf; /* pointer to msg data */
> };
>
> do you think it is better to use __u8 other than unsigned char here ?
What problem are you trying to solve, please?
> thanks
>
> static s32 i2c_smbus_xfer_emulated(struct i2c_adapter *adapter, u16 addr,
> unsigned short flags,
> char read_write, u8 command, int size,
> union i2c_smbus_data *data)
> {
> /* So we need to generate a series of msgs. In the case of writing, we
> need to use only one message; when reading, we need two. We
> initialize
> most things with sane defaults, to keep the code below somewhat
> simpler. */
> unsigned char msgbuf0[I2C_SMBUS_BLOCK_MAX+3];
> unsigned char msgbuf1[I2C_SMBUS_BLOCK_MAX+2];
>
> int num = read_write == I2C_SMBUS_READ ? 2 : 1;
> struct i2c_msg msg[2] = { { addr, flags, 1, msgbuf0 },
> { addr, flags | I2C_M_RD, 0, msgbuf1 }
> };
>
>
--
Jean Delvare
--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html