From patchwork Thu Aug 25 04:51:01 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 9298649 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 5CE46608A7 for ; Thu, 25 Aug 2016 04:55:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4C918291C1 for ; Thu, 25 Aug 2016 04:55:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 41453291C0; Thu, 25 Aug 2016 04:55:04 +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 DE5F8291C1 for ; Thu, 25 Aug 2016 04:55:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754773AbcHYEyo (ORCPT ); Thu, 25 Aug 2016 00:54:44 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:36842 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754703AbcHYExd (ORCPT ); Thu, 25 Aug 2016 00:53:33 -0400 Received: by mail-wm0-f65.google.com with SMTP id i138so5623578wmf.3 for ; Wed, 24 Aug 2016 21:53:33 -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=2JZbH+yg7Uo0ZVgEnNqjvjXku0frwSCWGNHCLx46sTk=; b=hWtsr+LY59y8CG57mbjeUhgVS569U7Xhaib9adgUgFJaESmS6R8tqB6aKF2VN0BmZN hz2a3A3KhusyiMmyuJExIGqzckM4tI8X5x2KuYNFC1eG9mwL/02X+q4ykzsaJsCTN6YF xfBEGob7nd4U2lydRFHGjCIOZ2D/Jooixd7ADWnd+yY9aN5m1+nsXGUF7Zj1k3jJVv3I ecsSVrXzNgjfZeHk65qmn9GLI4NOu3rVoNfBu24JKc1vKI2peJEVGgIJzEGMEH51rhDW fl0kPpJ8aaaLQYk0Pk1ajG/m6EfNvW+40snXiWvqEaorva3TeiGpv/5ebStxhSL4yvL/ 5opA== 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=2JZbH+yg7Uo0ZVgEnNqjvjXku0frwSCWGNHCLx46sTk=; b=YQxZwd3WeChydkk+gvrM9hPO7//MgmoRITtWPAoMD/D+aPIa82/28YUB/2hLvnVAfh irG9CPlFp2V4MIU+tIKQObElZukoy2Ix35HuHwybpZFjbS++QhFPWonFr638NmXamv6M kzu2YrhY2vuYRwTeftGkxfbOF9+MJeyN+iUDENJH0B9TdY02rULmjX4QAIEjk5faGHsA km1Eh1VTRDlucEzHY96FcdgOs9ZFXasit4+e1JbGAPd68MqPGDfGK8WGlYA/pvR1MQqQ +Ve1eFVGHq8KisWZlRAvcYcIBKg7N9UmvvpTcRUw9fdIIFw76XpvZ6PRGvGAQ6qcPmt7 YL4Q== X-Gm-Message-State: AEkoouvKuFu9U1QKAt1QG/DRFs0hNSpMCMbWb+sVdmQFojnqepWGtqlQ6zBonFUaCuTJnA== X-Received: by 10.194.192.195 with SMTP id hi3mr5388910wjc.108.1472100812160; Wed, 24 Aug 2016 21:53:32 -0700 (PDT) Received: from ?IPv6:2003:62:5f43:9500:dd82:2805:e44f:720e? (p200300625F439500DD822805E44F720E.dip0.t-ipconnect.de. [2003:62:5f43:9500:dd82:2805:e44f:720e]) by smtp.googlemail.com with ESMTPSA id o2sm13124854wjo.3.2016.08.24.21.53.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 24 Aug 2016 21:53:31 -0700 (PDT) From: Heiner Kallweit Subject: [PATCH 19/23] spi: fsl-espi: centralize populating struct spi_transfer To: Mark Brown References: Cc: "linux-spi@vger.kernel.org" Message-ID: Date: Thu, 25 Aug 2016 06:51:01 +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 Better structure the code by population all elements of struct spi_transfer in one place. Signed-off-by: Heiner Kallweit --- drivers/spi/spi-fsl-espi.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/spi/spi-fsl-espi.c b/drivers/spi/spi-fsl-espi.c index d398caf..56f3a3d 100644 --- a/drivers/spi/spi-fsl-espi.c +++ b/drivers/spi/spi-fsl-espi.c @@ -273,17 +273,8 @@ static int fsl_espi_bufs(struct spi_device *spi, struct spi_transfer *t) static int fsl_espi_do_trans(struct spi_message *m, struct spi_transfer *trans) { struct spi_device *spi = m->spi; - struct spi_transfer *t, *first; int ret = 0; - first = list_first_entry(&m->transfers, struct spi_transfer, - transfer_list); - list_for_each_entry(t, &m->transfers, transfer_list) { - trans->speed_hz = t->speed_hz; - trans->bits_per_word = t->bits_per_word; - trans->delay_usecs = max(first->delay_usecs, t->delay_usecs); - } - fsl_espi_setup_transfer(spi, trans); if (trans->len) @@ -306,7 +297,6 @@ static int fsl_espi_trans(struct spi_message *m, struct spi_transfer *trans, tx_only = fsl_espi_copy_to_buf(m, mspi); - trans->tx_buf = trans->rx_buf = mspi->local_buf; ret = fsl_espi_do_trans(m, trans); /* If there is at least one RX byte then copy it to rx_buff */ @@ -319,8 +309,9 @@ static int fsl_espi_trans(struct spi_message *m, struct spi_transfer *trans, 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); u8 *rx_buf = NULL; - unsigned int xfer_len = 0; + unsigned int delay_usecs = 0, xfer_len = 0; struct spi_transfer *t, trans = {}; int ret; @@ -333,9 +324,18 @@ static int fsl_espi_do_one_msg(struct spi_master *master, rx_buf = t->rx_buf; if ((t->tx_buf) || (t->rx_buf)) xfer_len += t->len; + if (t->delay_usecs > delay_usecs) + delay_usecs = t->delay_usecs; } + t = list_first_entry(&m->transfers, struct spi_transfer, + transfer_list); + trans.len = xfer_len; + trans.speed_hz = t->speed_hz; + trans.bits_per_word = t->bits_per_word; + trans.delay_usecs = delay_usecs; + trans.tx_buf = trans.rx_buf = mspi->local_buf; ret = fsl_espi_trans(m, &trans, rx_buf);