* static s32 i2c_smbus_xfer_emulated
@ 2011-06-14 6:39 Kassey Lee
[not found] ` <BANLkTinS1RA6iQfjZaVOE-q4qCtbt17LPg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
0 siblings, 1 reply; 2+ messages in thread
From: Kassey Lee @ 2011-06-14 6:39 UTC (permalink / raw)
To: linux-i2c-u79uwXL29TY76Z2rM5mHXA, khali-PUYAD+kWke1g9hUCZPvPmw,
grant.likely-s3s/WqlpOiPyB63q8FvJNQ
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 ?
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 }
};
--
Best regards
Kassey
Application Processor Systems Engineering, Marvell Technology Group Ltd.
Shanghai, China.
^ permalink raw reply [flat|nested] 2+ messages in thread[parent not found: <BANLkTinS1RA6iQfjZaVOE-q4qCtbt17LPg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>]
* Re: static s32 i2c_smbus_xfer_emulated [not found] ` <BANLkTinS1RA6iQfjZaVOE-q4qCtbt17LPg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> @ 2011-06-16 16:44 ` Jean Delvare 0 siblings, 0 replies; 2+ messages in thread From: Jean Delvare @ 2011-06-16 16:44 UTC (permalink / raw) To: Kassey Lee Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA, grant.likely-s3s/WqlpOiPyB63q8FvJNQ 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 ^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-06-16 16:44 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-14 6:39 static s32 i2c_smbus_xfer_emulated Kassey Lee
[not found] ` <BANLkTinS1RA6iQfjZaVOE-q4qCtbt17LPg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-06-16 16:44 ` Jean Delvare
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).