From: 乱石 <zhangliguang@linux.alibaba.com>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Jarkko Nikula <jarkko.nikula@linux.intel.com>,
Mika Westerberg <mika.westerberg@linux.intel.com>,
Philipp Zabel <p.zabel@pengutronix.de>,
linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] i2c: designware: Get right data length
Date: Thu, 25 Feb 2021 22:06:59 +0800 [thread overview]
Message-ID: <c89a0aa3-b580-7726-e7d7-4b3ce103e90a@linux.alibaba.com> (raw)
In-Reply-To: <YDeH27Vgble8FetC@smile.fi.intel.com>
Hi,
在 2021/2/25 19:19, Andy Shevchenko 写道:
> On Thu, Feb 25, 2021 at 10:35:28AM +0800, Liguang Zhang wrote:
>> IC_DATA_CMD[11] indicates the first data byte received after the address
>> phase for receive transfer in Master receiver or Slave receiver mode,
>> this bit was set in some transfer flow. IC_DATA_CMD[7:0] contains the
>> data to be transmitted or received on the I2C bus, so we should use the
>> lower 8 bits to get the right data length.
> Thanks for the report and fix!
> My comments below.
Thanks for your comments. I will optimize my code follow your comments
and send v2 revision.
Regards,
Liguang
>
>> Signed-off-by: Liguang Zhang <zhangliguang@linux.alibaba.com>
>> ---
>> drivers/i2c/busses/i2c-designware-master.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/i2c/busses/i2c-designware-master.c b/drivers/i2c/busses/i2c-designware-master.c
>> index d6425ad6e6a3..c3cf76f6c607 100644
>> --- a/drivers/i2c/busses/i2c-designware-master.c
>> +++ b/drivers/i2c/busses/i2c-designware-master.c
>> @@ -432,7 +432,7 @@ i2c_dw_read(struct dw_i2c_dev *dev)
>> regmap_read(dev->map, DW_IC_DATA_CMD, &tmp);
>> /* Ensure length byte is a valid value */
>> if (flags & I2C_M_RECV_LEN &&
>> - tmp <= I2C_SMBUS_BLOCK_MAX && tmp > 0) {
>> + (tmp & 0xff) <= I2C_SMBUS_BLOCK_MAX && tmp > 0) {
> Can we rather describe this as
>
> #define DW_IC_DATA_CMD_DAT GENMASK(7, 0)
>
> in *.h file and...
>
> (tmp & DW_IC_DATA_CMD_DAT) <= I2C_SMBUS_BLOCK_MAX && tmp > 0) {
> ...here?
>
>> len = i2c_dw_recv_len(dev, tmp);
>> }
>> *buf++ = tmp;
>> --
>> 2.19.1.6.gb485710b
>>
prev parent reply other threads:[~2021-02-25 14:08 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-25 2:35 [PATCH] i2c: designware: Get right data length Liguang Zhang
2021-02-25 11:19 ` Andy Shevchenko
2021-02-25 14:06 ` 乱石 [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=c89a0aa3-b580-7726-e7d7-4b3ce103e90a@linux.alibaba.com \
--to=zhangliguang@linux.alibaba.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=jarkko.nikula@linux.intel.com \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mika.westerberg@linux.intel.com \
--cc=p.zabel@pengutronix.de \
/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