The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Jean Delvare <khali@linux-fr.org>
To: York Sun <yorksun@freescale.com>
Cc: <guenter.roeck@ericsson.com>,
	Tabi Timur-B04825 <B04825@freescale.com>,
	<linux-i2c@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<B29983@freescale.com>
Subject: Re: [PATCH] i2c/busses: (mpc) Add support for SMBUS_READ_BLOCK_DATA
Date: Wed, 16 Nov 2011 18:38:06 +0100	[thread overview]
Message-ID: <20111116183806.6130f0fb@endymion.delvare> (raw)
In-Reply-To: <1321464509.7847.41.camel@oslab-l1>

On Wed, 16 Nov 2011 09:28:29 -0800, York Sun wrote:
> I am not sure if this mail will reach the list as I am not subscribed.
> 
> In the v2 patch (actually both version), you wrote
> 
> > +		byte = readb(i2c->base + MPC_I2C_DR);
> > +
> > +		/* Adjust length if first received byte is length */
> > +		if (i == 0 && recv_len) {
> > +			if (byte == 0 || byte > I2C_SMBUS_BLOCK_MAX)
> > +				return -EPROTO;
> > +			length += byte;
> > +			/*
> > +			 * For block reads, generate txack here if data length
> > +			 * is 1 byte (total length is 2 bytes).
> > +			 */
> > +			if (length == 2)
> > +				writeccr(i2c, CCR_MIEN | CCR_MEN | CCR_MSTA
> > +					 | CCR_TXAK);
> > +		}
> > +		data[i] = byte;
> 
> I am wondering if the first byte should be left out for data[] if the
> recv_len is non-zero. If I understand correctly, this patch is to
> support of SMBus with multiple byte read. The SMBus is different from
> I2C bus on multiple byte. The first data is byte count vs slave data for
> I2C. So you will receive all data preceded by the byte count, which is
> one more than your loop.

That's why he wrote

	length += byte;

and not

	length = byte;

length is initialized to 1 for SMBus block reads.

-- 
Jean Delvare

  parent reply	other threads:[~2011-11-16 17:38 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-15  6:27 [PATCH] i2c/busses: (mpc) Add support for SMBUS_READ_BLOCK_DATA 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
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 [this message]
  -- strict thread matches above, loose matches on Subject: below --
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=20111116183806.6130f0fb@endymion.delvare \
    --to=khali@linux-fr.org \
    --cc=B04825@freescale.com \
    --cc=B29983@freescale.com \
    --cc=guenter.roeck@ericsson.com \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=yorksun@freescale.com \
    /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