mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: York Sun <yorksun@freescale.com>
To: Jean Delvare <khali@linux-fr.org>
Cc: <guenter.roeck@ericsson.com>,
	Tabi Timur-B04825 <B04825@freescale.com>,
	"linux-i2c@vger.kernel.org" <linux-i2c@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"B29983@freescale.com" <B29983@freescale.com>
Subject: Re: [PATCH] i2c/busses: (mpc) Add support for SMBUS_READ_BLOCK_DATA
Date: Wed, 16 Nov 2011 10:20:38 -0800	[thread overview]
Message-ID: <1321467638.7847.73.camel@oslab-l1> (raw)
In-Reply-To: <20111116190954.67c846fc@endymion.delvare>

On Wed, 2011-11-16 at 19:09 +0100, Jean Delvare wrote:
> On Wed, 16 Nov 2011 09:55:35 -0800, York Sun wrote:
> > On Wed, 2011-11-16 at 09:36 -0800, Guenter Roeck wrote:
> > > York,
> > > 
> > > The calling code expects the data length in data[0], and the actual data
> > > in data[1] .. data[<byte_count>]. The initial value for length is 1; the
> > > byte count is added to it, so <byte count + 1> bytes are placed into the
> > > buffer.
> > > 
> > > Thanks,
> > > Guenter
> > 
> > Thanks for explanation. I am more confused by the length += byte now.
> > For I2C bus, if you need length of byte, just keep reading until you get
> > all of them. Of course you need to deal with the ACK. For SMBus, it is
> > similar but you shouldn't read more after the byte count which is in the
> > first data.
> 
> You shouldn't read less either. The slave tells how much bytes it wants
> to send, and the master must honor that.
> 
> > If you want to read length of data but the block size is
> > bigger than length, you should call block read at first place. If the
> > block size is smaller than length, why increase the length? Does your
> > SMBus controller only support fixed block size and not support single
> > byte read? If it does, I would do
> > 
> > Block, Block, Block, byte, byte... until length of data
> 
> Your thinking is too focused on I2C block reads (or even block read of
> data over the network or on disk). SMBus block read is something
> completely different. It's not about reading 200 bytes of data and
> receiving it in 16-byte chunks (I2C block read works that way, on
> EEPROMs in particular.) There is no "data length" and "block size" to
> compare to each other. It's about reading the value of _one_ register
> and this value happens to be multi-byte. There is typically _no_
> register pointer increment (automatic or not) involved as can happen
> with EEPROMs. If an SMBus block read from register N returns 10 bytes,
> you're not going to read the next 10 bytes from register N+10. There
> are no "next 10 bytes" to read, and register N+10 is something
> completely unrelated.
> 
> And for this reason, it is not possible to mix SMBus block reads with
> byte reads, as can be done with I2C block reads.
> 
> Also note that there is a limit of 32 bytes for SMBus block transfers,
> per SMBus specification. All slaves and masters must comply with it.
> 
> I hope I managed to clarify the case this time...
> 

You have made it much clear. If block size is fixed and block read
cannot mix with byte read, shall we do this

if length < block_size
   read block_size
else {
   while (length) {
       read block_size
       length -= block_size
   }

York





  reply	other threads:[~2011-11-16 18:20 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-15  6:27 Guenter Roeck
2011-11-15  8:54 ` Jean Delvare
2011-11-15 16:29   ` Guenter Roeck
2011-11-15 19:02   ` Tabi Timur-B04825
2011-11-15 19:14     ` Guenter Roeck
2011-11-15 20:05       ` Jean Delvare
2011-11-15 21:14         ` Guenter Roeck
     [not found] ` <CAOZdJXUPO5PyMkAw-2EPvy_qSUuqsgUA7Gr8mKUX7HyShoXk3g@mail.gmail.com>
     [not found]   ` <E6AF40B3BFC8A9428EACB47497F0F4B62DC687@039-SN1MPN1-002.039d.mgd.msft.net>
     [not found]     ` <ECEE0D23-8F53-402C-A97F-4DB0F0E9C79B@freescale.com>
2011-11-16 17:28       ` York Sun
2011-11-16 17:36         ` Guenter Roeck
2011-11-16 17:55           ` York Sun
2011-11-16 18:09             ` Guenter Roeck
2011-11-16 18:09             ` Jean Delvare
2011-11-16 18:20               ` York Sun [this message]
2011-11-16 18:51                 ` Guenter Roeck
2011-11-16 18:56                   ` Timur Tabi
2011-11-16 18:58                   ` sun york-R58495
2011-11-16 19:10                 ` Jean Delvare
2011-11-16 19:15                   ` York Sun
2011-11-16 19:18                     ` Jean Delvare
2011-11-16 19:24                       ` York Sun
2011-11-17 18:18                         ` Guenter Roeck
2011-11-17 19:23                           ` York Sun
2011-11-18  3:15                           ` Tang Yuantian-B29983
2011-12-01  7:06                       ` Tang Yuantian-B29983
2011-12-07  2:52                       ` Tang Yuantian-B29983
2011-12-07  3:20                         ` Guenter Roeck
2011-12-07  5:25                           ` Tang Yuantian-B29983
2011-12-07  7:29                             ` Jean Delvare
2012-02-23  6:57                               ` Huang Changming-R66093
2011-11-16 17:38         ` Jean Delvare
2011-12-12  4:10 Yuantian.tang
2011-12-12  9:28 ` Guenter Roeck

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=1321467638.7847.73.camel@oslab-l1 \
    --to=yorksun@freescale.com \
    --cc=B04825@freescale.com \
    --cc=B29983@freescale.com \
    --cc=guenter.roeck@ericsson.com \
    --cc=khali@linux-fr.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.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

all inboxes | Powered by JetHome®