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 autolearn=unavailable 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 895A9C433DB for ; Thu, 25 Feb 2021 11:22:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 44D7964F14 for ; Thu, 25 Feb 2021 11:22:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235066AbhBYLV4 (ORCPT ); Thu, 25 Feb 2021 06:21:56 -0500 Received: from mga14.intel.com ([192.55.52.115]:33867 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234548AbhBYLVr (ORCPT ); Thu, 25 Feb 2021 06:21:47 -0500 IronPort-SDR: cqu2pBjhKfPwu1nKe9s1CD/ZuZH3X9b+gwSp3I3q8y/v/TKJxVpgaqTyAbTGJ5Yu/mtH1tLC21 85GDt6+3mwgA== X-IronPort-AV: E=McAfee;i="6000,8403,9905"; a="184790291" X-IronPort-AV: E=Sophos;i="5.81,205,1610438400"; d="scan'208";a="184790291" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Feb 2021 03:20:00 -0800 IronPort-SDR: 1P/mJl6SAnf563iICc4wL5539Tioyys6RloOQ/05gFhu6+njg154KlieXPQ+bAHxn0oo866GVn p46NldlC2HpA== X-IronPort-AV: E=Sophos;i="5.81,205,1610438400"; d="scan'208";a="442531676" Received: from smile.fi.intel.com (HELO smile) ([10.237.68.40]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Feb 2021 03:19:58 -0800 Received: from andy by smile with local (Exim 4.94) (envelope-from ) id 1lFEgV-0080Jh-Of; Thu, 25 Feb 2021 13:19:55 +0200 Date: Thu, 25 Feb 2021 13:19:55 +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] i2c: designware: Get right data length Message-ID: References: <20210225023528.121135-1-zhangliguang@linux.alibaba.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210225023528.121135-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: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. > Signed-off-by: Liguang Zhang > --- > 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 > -- With Best Regards, Andy Shevchenko