From patchwork Wed Sep 7 20:54:35 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 9319921 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 51F48607D3 for ; Wed, 7 Sep 2016 20:56:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 41E7D2942B for ; Wed, 7 Sep 2016 20:56:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3026029427; Wed, 7 Sep 2016 20:56:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C7C6F29427 for ; Wed, 7 Sep 2016 20:56:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757365AbcIGU4I (ORCPT ); Wed, 7 Sep 2016 16:56:08 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:33632 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757138AbcIGUzz (ORCPT ); Wed, 7 Sep 2016 16:55:55 -0400 Received: by mail-wm0-f67.google.com with SMTP id b187so852914wme.0 for ; Wed, 07 Sep 2016 13:55:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:subject:to:references:cc:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=fb61E3HtnPzn05L13DG7EKmCXDIMKJlL7DCdkAOnL0E=; b=Br0VFJfIRVL9uYSB8g4sLiWcdf7FkPK1btX8Yi4Ov0onuqECYDXeLByyuL/OA2tD3R uSDyrK2KLrIixE3Su7VipuFBStfbO78Xjem5+oF0ipvEhFLHSzjYKY4m+8zvm17cWtPh VS/9+uWkhGlIbayYs0NKkiC3uIP7A/n+2Lq4HD9CQvMac2MHKC1cYE9VcJsw+uOp93sc 998ScDEukZPNwtBjYfVHCHWYlkxAMRhmlosihv0KN8sAZWp8FAZ2pyCKOjofhbxbSC3p gOokJqgi2jCgkM16+XPGpQB2DPhoCzsyk02aMVQFKW71onrUVyNnrf6VzkQg3pGyfHHI l+QQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:subject:to:references:cc:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=fb61E3HtnPzn05L13DG7EKmCXDIMKJlL7DCdkAOnL0E=; b=kkLA+DvtG98stmpZLPaDjV8uN7IKm2pmCG6tbvU1PLiYwwxEroPBdO7WA773Cg6cWv EjRNusoeMCSSXM+m3Qxd9TB3sIX1IwFxF7yEtNKz190q3NNfgY6OO4YbyHo3NU40ot0G 38PSuwoH2cyamZ3yHwQyJWpsPFTeZowKME5SzkPO6Vdc53jDBoYmT0Km6bdC7QC27Y7+ RsbUv6EaFFAllPB/oWGIlROLxfRJhIXycUhKo8zE/DldWKsmsIcdeSKlErJItakwrd2w IGX2gjBJ6ugRVn/4sv+ej0by9xZbGvXAYf0sNMK0cEDAsD8mhLXNpj2B2qe1rr6FgadV dytQ== X-Gm-Message-State: AE9vXwP34azFboDJghad2BtC7c64fMcRSqL1r5i+LqwEfO0MDBS8qi7EcEL6Fa2ltUs1nQ== X-Received: by 10.28.74.217 with SMTP id n86mr6014657wmi.84.1473281754291; Wed, 07 Sep 2016 13:55:54 -0700 (PDT) Received: from ?IPv6:2003:62:5f43:9500:6565:4488:ad4:60db? (p200300625F439500656544880AD460DB.dip0.t-ipconnect.de. [2003:62:5f43:9500:6565:4488:ad4:60db]) by smtp.googlemail.com with ESMTPSA id u124sm6052535wmu.10.2016.09.07.13.55.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 07 Sep 2016 13:55:54 -0700 (PDT) From: Heiner Kallweit Subject: [PATCH v3 14/15] spi: fsl-espi: improve message length handling To: Mark Brown References: Cc: "linux-spi@vger.kernel.org" Message-ID: Date: Wed, 7 Sep 2016 22:54:35 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Move checking for a zero-length message up in the call chain and use m->frame_length instead of re-calculating the overall length of all transfers in the message. Signed-off-by: Heiner Kallweit --- v2: - rebased v3: - new numbering --- drivers/spi/spi-fsl-espi.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/spi/spi-fsl-espi.c b/drivers/spi/spi-fsl-espi.c index 88935a3..84355bb 100644 --- a/drivers/spi/spi-fsl-espi.c +++ b/drivers/spi/spi-fsl-espi.c @@ -283,8 +283,7 @@ static int fsl_espi_do_trans(struct spi_message *m, struct spi_transfer *trans) fsl_espi_setup_transfer(spi, trans); - if (trans->len) - ret = fsl_espi_bufs(spi, trans); + ret = fsl_espi_bufs(spi, trans); if (trans->delay_usecs) udelay(trans->delay_usecs); @@ -313,7 +312,7 @@ static int fsl_espi_do_one_msg(struct spi_master *master, struct spi_message *m) { struct mpc8xxx_spi *mspi = spi_master_get_devdata(m->spi->master); - unsigned int delay_usecs = 0, xfer_len = 0; + unsigned int delay_usecs = 0; struct spi_transfer *t, trans = {}; int ret; @@ -322,8 +321,6 @@ static int fsl_espi_do_one_msg(struct spi_master *master, goto out; list_for_each_entry(t, &m->transfers, transfer_list) { - if ((t->tx_buf) || (t->rx_buf)) - xfer_len += t->len; if (t->delay_usecs > delay_usecs) delay_usecs = t->delay_usecs; } @@ -331,14 +328,15 @@ static int fsl_espi_do_one_msg(struct spi_master *master, t = list_first_entry(&m->transfers, struct spi_transfer, transfer_list); - trans.len = xfer_len; + trans.len = m->frame_length; trans.speed_hz = t->speed_hz; trans.bits_per_word = t->bits_per_word; trans.delay_usecs = delay_usecs; trans.tx_buf = mspi->local_buf; trans.rx_buf = mspi->local_buf; - ret = fsl_espi_trans(m, &trans); + if (trans.len) + ret = fsl_espi_trans(m, &trans); m->actual_length = ret ? 0 : trans.len; out: