From patchwork Sun Sep 4 08:02: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: 9312435 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 437F0600CA for ; Sun, 4 Sep 2016 08:08:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 34A8A287DA for ; Sun, 4 Sep 2016 08:08:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 29B9828925; Sun, 4 Sep 2016 08:08:14 +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=-4.4 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, 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 C6CD0287DA for ; Sun, 4 Sep 2016 08:08:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752106AbcIDIIN (ORCPT ); Sun, 4 Sep 2016 04:08:13 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:35475 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752582AbcIDIHr (ORCPT ); Sun, 4 Sep 2016 04:07:47 -0400 Received: by mail-wm0-f66.google.com with SMTP id c133so8695782wmd.2 for ; Sun, 04 Sep 2016 01:07:45 -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=Nv7fR64k9ArY0hSZbztvOhBEUuV4/I2eyxkh1cZLYnw=; b=CM1x8tNFMNuzQMwtCix5vzBpqmROY+F8P+ovBfE9wG2yN2R6rI1CrZq72UCY5rAdGO KyBObYbteeGiabM95Zs4YFsboWYmsIagtd15jaIuKhvDo+6ydpBRw/qzFR+sano1klc9 l8t8combdzo4RFA83nkeW76xaUtV53vX9Ao1wnFeoNU+DNYzKUtulPMUJUWAJMOqw3uX /UN05Rddxpmrj91rqCZExTvzQoI8gJyWlLCk+UN0jFPV/cQLPnZtvAW/TWwFnkTzN3Ul U5QQD7gvQiwXeRPWhhOHFpmFh+lVBDO1YKvXylg8dZa9Npj9ONS+EW6upjeYvrtu2Jrk DPMg== 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=Nv7fR64k9ArY0hSZbztvOhBEUuV4/I2eyxkh1cZLYnw=; b=m8TOOYdo2AXLQ4XnhTe4H5DHNr+rJodN27S4z+eS6vzQ6VvcTUYn4Pk76GVS+d3sJ7 Q3RY5oMf6kE+DFkWEh4pyCdW2E9Rbp/xbuzOyzmKYWzLLoQigQ7KXhy9b7mmtuAxyb1j 4NKGF4ZOTnACLhhp2jepdZi81mrGpvCV/DpySOhZxmUhrD/c+jDKrfM6NA4aY/C2EdnO r0URGbmzfxzKToO2/VhXp3HQ7LHLZnvDx7kWulfxSZyV1FWxkC9JbheQdVXp4UptepSi sUSc0bMlMx6LR6QLZ8ysSh11mWX/lvP6TEXBykOjGC9M117AnDw+who1RnijKyLb20s8 tKxQ== X-Gm-Message-State: AE9vXwO+xWiZYy+YosYCsE4/5Txxs4YQd9jBfu2aQpqBEY2RXrCd/zMAPLIi5MbUkWAIDQ== X-Received: by 10.194.148.81 with SMTP id tq17mr29364606wjb.67.1472976464511; Sun, 04 Sep 2016 01:07:44 -0700 (PDT) Received: from ?IPv6:2003:62:5f43:9500:c1f5:c528:a3d:f8c4? (p200300625F439500C1F5C5280A3DF8C4.dip0.t-ipconnect.de. [2003:62:5f43:9500:c1f5:c528:a3d:f8c4]) by smtp.googlemail.com with ESMTPSA id ya1sm19885383wjb.23.2016.09.04.01.07.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 04 Sep 2016 01:07:44 -0700 (PDT) From: Heiner Kallweit Subject: [PATCH v2 17/18] spi: fsl-espi: improve message length handling To: Mark Brown References: Cc: "linux-spi@vger.kernel.org" Message-ID: <7d4a66bb-11ed-a870-7d3d-5c64cc0bd7e4@gmail.com> Date: Sun, 4 Sep 2016 10:02: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 --- 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: