From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D4606C433E6 for ; Thu, 25 Feb 2021 15:07:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 90AF564F23 for ; Thu, 25 Feb 2021 15:07:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232139AbhBYPHW (ORCPT ); Thu, 25 Feb 2021 10:07:22 -0500 Received: from mga11.intel.com ([192.55.52.93]:55245 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231591AbhBYPHS (ORCPT ); Thu, 25 Feb 2021 10:07:18 -0500 IronPort-SDR: tWPNzI4iSHctuHePv9IZPGq5MctOoQsgemyA93Od3kuGnGMnj6D48iFgTYhWb7Y2Oh7t3+NVgS pp59mcnFJ3OA== X-IronPort-AV: E=McAfee;i="6000,8403,9905"; a="182122428" X-IronPort-AV: E=Sophos;i="5.81,206,1610438400"; d="scan'208";a="182122428" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Feb 2021 07:05:31 -0800 IronPort-SDR: UlEjrfLqOxhB2QPygFOqEgSk5foRtoa+ThCF3tAG2RJgwTwU0Tzyg6Uoo9Fd9zKTg5A5ov6/ed YDyPqnxSJ07Q== X-IronPort-AV: E=Sophos;i="5.81,206,1610438400"; d="scan'208";a="433989020" Received: from smile.fi.intel.com (HELO smile) ([10.237.68.40]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Feb 2021 07:05:15 -0800 Received: from andy by smile with local (Exim 4.94) (envelope-from ) id 1lFICU-0082q2-CR; Thu, 25 Feb 2021 17:05:10 +0200 Date: Thu, 25 Feb 2021 17:05:10 +0200 From: Andy Shevchenko To: Liguang Zhang Cc: Jarkko Nikula , Mika Westerberg , Philipp Zabel , linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] i2c: designware: Get right data length Message-ID: References: <20210225142631.1882-1-zhangliguang@linux.alibaba.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210225142631.1882-1-zhangliguang@linux.alibaba.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Feb 25, 2021 at 10:26:31PM +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 real data length. Reviewed-by: Andy Shevchenko > Signed-off-by: Liguang Zhang > --- > drivers/i2c/busses/i2c-designware-core.h | 2 ++ > drivers/i2c/busses/i2c-designware-master.c | 2 +- > 2 files changed, 3 insertions(+), 1 deletion(-) > > diff --git a/drivers/i2c/busses/i2c-designware-core.h b/drivers/i2c/busses/i2c-designware-core.h > index 85307cfa7109..5392b82f68a4 100644 > --- a/drivers/i2c/busses/i2c-designware-core.h > +++ b/drivers/i2c/busses/i2c-designware-core.h > @@ -38,6 +38,8 @@ > #define DW_IC_CON_TX_EMPTY_CTRL BIT(8) > #define DW_IC_CON_RX_FIFO_FULL_HLD_CTRL BIT(9) > > +#define DW_IC_DATA_CMD_DAT GENMASK(7, 0) > + > /* > * Registers offset > */ > diff --git a/drivers/i2c/busses/i2c-designware-master.c b/drivers/i2c/busses/i2c-designware-master.c > index d6425ad6e6a3..dd27b9dbe931 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 & DW_IC_DATA_CMD_DAT) <= I2C_SMBUS_BLOCK_MAX && tmp > 0) { > len = i2c_dw_recv_len(dev, tmp); > } > *buf++ = tmp; > -- > 2.19.1.6.gb485710b > -- With Best Regards, Andy Shevchenko