From patchwork Sun Sep 4 08:02:10 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 9312429 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 CA8C9600CA for ; Sun, 4 Sep 2016 08:08:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BBEB8287DA for ; Sun, 4 Sep 2016 08:08:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B0BA628925; Sun, 4 Sep 2016 08:08:00 +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 5A2D9287DA for ; Sun, 4 Sep 2016 08:08:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752611AbcIDIH5 (ORCPT ); Sun, 4 Sep 2016 04:07:57 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:33334 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752219AbcIDIHn (ORCPT ); Sun, 4 Sep 2016 04:07:43 -0400 Received: by mail-wm0-f66.google.com with SMTP id w207so8683766wmw.0 for ; Sun, 04 Sep 2016 01:07:43 -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=MsQ3IF6HZwuaozncZOFiSbobIDK3uQyYudgCY01kmMs=; b=m3Ib82vIF1BoM9b0fO+yTCH4E0p7C+PxIxnTxwQ9ceTPseYWRc0Qg0ab++Z5oGiFb3 3CP7M4WZ1HbQveikMwbjuOw4dqYzPw6N7UhuL/icERrdAfzSnDknD0hjjLS01JjPpH+B AQHFq9pSw9bkeleAW6fT1Vpt9FQufTmBKLCpAQg2pV4TWqcKWfZAR84b+qbjh/kktISk 17lX8fnlg+yMbkCUP78l/E+sB5EZoEqyI2BXKFwHPrX1rIvGPs+zcEO10lTvS9f669Mf CgJvI0v7vmYJSJf+ecWHNwhHzGxG8oQEWYA5GiPrTi82puvwj0ntLAZYw9k93/HbyK6C yOjg== 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=MsQ3IF6HZwuaozncZOFiSbobIDK3uQyYudgCY01kmMs=; b=KYuV3fKSSQPiBGujc2uk/0m7IRGSWfJJTDi+BYC+WaKSNNt3PP3C/zUtjYM0s3K6DW JXrcSOiEoDLiGkaSlkzkpvByc9Ff4LPFhNP6hbwMBk+avNqewC3pcRdTl0DXURX/nJ5L zLahQa+ZySxn0auGaamlKa9caklLv0OA6+5zUgOB8zpcWLogewd5T65RX9+PwlCjjoyU waK7bHrucPSde9o3/nr0aGHR3UVL7vNrHUBiN02/aT4AcW8HLUn88HOhIhpdupz+2Jds wW1Uh/bDVNuJkinO42q4/C4zHkvbEXEgV34ewn+O+afTindPARczQsdoy46cH1caN0BL a9VA== X-Gm-Message-State: AE9vXwOAd85ztt+C/HNYr2EbzsyOx/s5hLJ/RaW7j6zdKl12fdhMvHygVMg7I6bdkR7wTg== X-Received: by 10.28.62.204 with SMTP id l195mr9809699wma.117.1472976462198; Sun, 04 Sep 2016 01:07:42 -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 n7sm7423228wjs.34.2016.09.04.01.07.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 04 Sep 2016 01:07:41 -0700 (PDT) From: Heiner Kallweit Subject: [PATCH v2 15/18] spi: fsl-espi: centralize populating struct spi_transfer To: Mark Brown References: Cc: "linux-spi@vger.kernel.org" Message-ID: <8c09f863-6eb4-6fe8-bc3d-acd3cf19c4aa@gmail.com> Date: Sun, 4 Sep 2016 10:02:10 +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 --- v2: - rebased --- drivers/spi/spi-fsl-espi.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/spi/spi-fsl-espi.c b/drivers/spi/spi-fsl-espi.c index a32bc3a..79c89bf 100644 --- a/drivers/spi/spi-fsl-espi.c +++ b/drivers/spi/spi-fsl-espi.c @@ -272,17 +272,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) @@ -305,8 +296,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 = mspi->local_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 +308,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 +323,19 @@ 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 = mspi->local_buf; + trans.rx_buf = mspi->local_buf; ret = fsl_espi_trans(m, &trans, rx_buf);