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=-18.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 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 51A76C4338F for ; Wed, 28 Jul 2021 17:49:53 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8481760BD3 for ; Wed, 28 Jul 2021 17:49:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 8481760BD3 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=ti.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A092D82CDA; Wed, 28 Jul 2021 19:49:50 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=ti.com header.i=@ti.com header.b="F9OwfwbT"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 721D982D1C; Wed, 28 Jul 2021 19:49:48 +0200 (CEST) Received: from fllv0016.ext.ti.com (fllv0016.ext.ti.com [198.47.19.142]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 2360782C88 for ; Wed, 28 Jul 2021 19:49:45 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=p.yadav@ti.com Received: from lelv0266.itg.ti.com ([10.180.67.225]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 16SHngTq126018; Wed, 28 Jul 2021 12:49:42 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1627494582; bh=yaJdZgusDiJ/Rhrg8HjanFZ+/0+uFulLr0YqSEebS2M=; h=Date:From:To:CC:Subject:References:In-Reply-To; b=F9OwfwbTLvMO0l8l8vUqsz2OqGWBxsQFfLVDu6x76V4h4DxflPTv0OZuJNjoEd728 aOLesss6fcoBdDR3JAXDT8u3Jstty/TCmq1LSGMfMZr8NFEN3Q0aQB5gyrfE9dZGOR bwcvFdcz+5bLzctSR3CU2B8kIwsI2o8YDz3tMfv0= Received: from DLEE113.ent.ti.com (dlee113.ent.ti.com [157.170.170.24]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 16SHngvL094052 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 28 Jul 2021 12:49:42 -0500 Received: from DLEE112.ent.ti.com (157.170.170.23) by DLEE113.ent.ti.com (157.170.170.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Wed, 28 Jul 2021 12:49:41 -0500 Received: from lelv0327.itg.ti.com (10.180.67.183) by DLEE112.ent.ti.com (157.170.170.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2 via Frontend Transport; Wed, 28 Jul 2021 12:49:41 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by lelv0327.itg.ti.com (8.15.2/8.15.2) with ESMTP id 16SHnfch018222; Wed, 28 Jul 2021 12:49:41 -0500 Date: Wed, 28 Jul 2021 23:19:40 +0530 From: Pratyush Yadav To: Bin Meng CC: Jagan Teki , Vignesh Raghavendra , , Tom Rini , Simon Glass Subject: Re: [PATCH] spi: spi-mem-nodm: Fix read data size issue Message-ID: <20210728174938.wd4fdk6pwrkcmp4e@ti.com> References: <20210728125014.536900-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20210728125014.536900-1-bmeng.cn@gmail.com> User-Agent: NeoMutt/20171215 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean +Tom, Simon, On 28/07/21 08:50PM, Bin Meng wrote: > When slave drivers don't set the max_read_size, the spi-mem should > directly use data.nbytes and not limit to any size. But current > logic will limit to the max_write_size. With the push towards using DM, do we really need to maintain the nodm version anymore? Are there any users left? If there are, I think they should migrate to using DM instead of trying to fix depreciated code. Thoughts? > > This commit mirrors the same changes in the dm version done in > commit 535b1fdb8e5e ("spi: spi-mem: Fix read data size issue"). > > Signed-off-by: Bin Meng > --- > > drivers/spi/spi-mem-nodm.c | 10 ++++++---- > 1 file changed, 6 insertions(+), 4 deletions(-) > > diff --git a/drivers/spi/spi-mem-nodm.c b/drivers/spi/spi-mem-nodm.c > index a228c808c7..77ddb19a9f 100644 > --- a/drivers/spi/spi-mem-nodm.c > +++ b/drivers/spi/spi-mem-nodm.c > @@ -93,12 +93,14 @@ int spi_mem_adjust_op_size(struct spi_slave *slave, > if (slave->max_write_size && len > slave->max_write_size) > return -EINVAL; > > - if (op->data.dir == SPI_MEM_DATA_IN && slave->max_read_size) > - op->data.nbytes = min(op->data.nbytes, > - slave->max_read_size); > - else if (slave->max_write_size) > + if (op->data.dir == SPI_MEM_DATA_IN) { > + if (slave->max_read_size) > + op->data.nbytes = min(op->data.nbytes, > + slave->max_read_size); > + } else if (slave->max_write_size) { > op->data.nbytes = min(op->data.nbytes, > slave->max_write_size - len); > + } > > if (!op->data.nbytes) > return -EINVAL; > -- > 2.25.1 > -- Regards, Pratyush Yadav Texas Instruments Inc.