linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org>
To: Kassey Lee <kassey1216-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org
Subject: Re: static s32 i2c_smbus_xfer_emulated
Date: Thu, 16 Jun 2011 18:44:11 +0200	[thread overview]
Message-ID: <20110616184411.7272ca08@endymion.delvare> (raw)
In-Reply-To: <BANLkTinS1RA6iQfjZaVOE-q4qCtbt17LPg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>

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

      parent reply	other threads:[~2011-06-16 16:44 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110616184411.7272ca08@endymion.delvare \
    --to=khali-puyad+kwke1g9huczpvpmw@public.gmane.org \
    --cc=grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org \
    --cc=kassey1216-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).