From patchwork Tue Dec 4 12:26:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vignesh Raghavendra X-Patchwork-Id: 1007593 X-Patchwork-Delegate: jagannadh.teki@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=quarantine dis=none) header.from=ti.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ti.com header.i=@ti.com header.b="n3iBMtNR"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 438Llb1TD5z9s7W for ; Tue, 4 Dec 2018 23:29:31 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id EC544C2236A; Tue, 4 Dec 2018 12:27:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 652E2C22289; Tue, 4 Dec 2018 12:27:21 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id ADB89C2227D; Tue, 4 Dec 2018 12:26:48 +0000 (UTC) Received: from lelv0143.ext.ti.com (lelv0143.ext.ti.com [198.47.23.248]) by lists.denx.de (Postfix) with ESMTPS id A2B06C22253 for ; Tue, 4 Dec 2018 12:26:44 +0000 (UTC) Received: from fllv0034.itg.ti.com ([10.64.40.246]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id wB4CQdta055937; Tue, 4 Dec 2018 06:26:39 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1543926399; bh=7twWw/fcvARyVG2DyKsXY5+VLCp82a+vNxPcaD+L6/s=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=n3iBMtNRcjiYWn7diWeLHtomGHEVSiuCpm79WmjyXG+R1zNL7KUi/9spHubCD65SG 6+Jo/gi4D9sjaqw2hiwjtge7mSErWV+o6d2zLpaZLi0NW/GybsrtVaEmL4NAA3ysQy F3DXeLjS3jMlZzqTqyKU1eS2ck/kyM6LunCiKMYs= Received: from DFLE104.ent.ti.com (dfle104.ent.ti.com [10.64.6.25]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id wB4CQdTP107339 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 4 Dec 2018 06:26:39 -0600 Received: from DFLE108.ent.ti.com (10.64.6.29) by DFLE104.ent.ti.com (10.64.6.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1591.10; Tue, 4 Dec 2018 06:26:38 -0600 Received: from dlep32.itg.ti.com (157.170.170.100) by DFLE108.ent.ti.com (10.64.6.29) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1591.10 via Frontend Transport; Tue, 4 Dec 2018 06:26:38 -0600 Received: from a0132425.india.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep32.itg.ti.com (8.14.3/8.13.8) with ESMTP id wB4CQMWa017678; Tue, 4 Dec 2018 06:26:34 -0600 From: Vignesh R To: Nobuhiro Iwamatsu , Heiko Schocher , Jagan Teki , Patrick Delaunay , Christophe Kerello , Patrice Chotard Date: Tue, 4 Dec 2018 17:56:50 +0530 Message-ID: <20181204122659.14720-3-vigneshr@ti.com> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181204122659.14720-1-vigneshr@ti.com> References: <20181204122659.14720-1-vigneshr@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Cc: Tom Rini , u-boot@lists.denx.de, uboot-stm32@st-md-mailman.stormreply.com, Miquel Raynal , Fabio Estevam , Boris Brezillon Subject: [U-Boot] [RFC PATCH v2 02/11] spi-mem: Claim SPI bus before spi mem access X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 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" It is necessary to call spi_claim_bus() before starting any SPI transactions and this restriction would also apply when calling spi-mem operationss. Therefore claim and release bus before requesting transfer via exec_op. Signed-off-by: Vignesh R --- drivers/spi/spi-mem.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/spi/spi-mem.c b/drivers/spi/spi-mem.c index 1da20b8de5c4..4c1463118ab2 100644 --- a/drivers/spi/spi-mem.c +++ b/drivers/spi/spi-mem.c @@ -231,7 +231,13 @@ int spi_mem_exec_op(struct spi_slave *slave, const struct spi_mem_op *op) mutex_lock(&ctlr->bus_lock_mutex); mutex_lock(&ctlr->io_mutex); #endif + ret = spi_claim_bus(slave); + if (ret < 0) + return ret; + ret = ops->mem_ops->exec_op(slave, op); + + spi_release_bus(slave); #ifndef __UBOOT__ mutex_unlock(&ctlr->io_mutex); mutex_unlock(&ctlr->bus_lock_mutex);