From patchwork Fri Nov 25 22:58:49 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 9448187 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 4945260779 for ; Fri, 25 Nov 2016 23:00:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 30BD227F95 for ; Fri, 25 Nov 2016 23:00:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 16EDE27F94; Fri, 25 Nov 2016 23:00:52 +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 ADA8827F0B for ; Fri, 25 Nov 2016 23:00:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751041AbcKYXAu (ORCPT ); Fri, 25 Nov 2016 18:00:50 -0500 Received: from mail-wj0-f195.google.com ([209.85.210.195]:35205 "EHLO mail-wj0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750997AbcKYXAu (ORCPT ); Fri, 25 Nov 2016 18:00:50 -0500 Received: by mail-wj0-f195.google.com with SMTP id o2so3205775wje.2 for ; Fri, 25 Nov 2016 15:00:49 -0800 (PST) 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=EgH9Fb1JsVHU0jb+cpg702jT1lSI6TT3c/2bDLlSyF0=; b=0o4urU1Aq0kj0Q1+AjmRxr+1CrlBUPUs17NmUf07h0NhTTmHf4PXXjfLVjyXaxI8gN g9j3BMTqjvF1QR38oRx6/A40YROHbTVOCx9DF8OOGU6u6SZYS9hn4BeJsccU1ETQJ+HZ gCwU7MVjmMCoIpoQLs0JDeWNbNZDxid2CuZw6jrHf5FADRFpCy3RHWAEYnM1Jk8uPrsY o2FCkEjDoETsJ2WvZvO52eKzHVnZyUa0FYnHWQgNSHQ9X2OshrNcjIqsDkQ8e4PSAMB6 7p0RRZqYgSRIwVR0WgUCDLjz4sKzrNNw4MqSmxGV4j7lUy56OMkUP3NWO2mJi9z3eZFw uQJw== 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=EgH9Fb1JsVHU0jb+cpg702jT1lSI6TT3c/2bDLlSyF0=; b=Pinhb85hzlv+yjyKSEL98OrcrBPPpk9QL/BAY4yFfmVOjRlRo8ilu6s69shbj8v8OR VAE8k0139OIrvE3Mx3uQcCXzVYSAD9jnDiovHS/V9LH294Yo1kz/GB04I1BruzNEZsue wA8K9CxymfkwP5WNyR3VLqbMenJRRIPKIyBm9y/nKZQ1+Z6+QKLmB7PJdTMpcXGtjWJa LiT4fd3g4bk2Mt8C48bGMImpfxzV573E2aj3blCo77ZvP9vqg7d3hg6RvWASdscZlRf2 KLfpTSYjSDJX3RF87Sh5kwhggDKfoOMkssrWtEr1e0Wrq3vYhzxczYtjHzANj6oY+yHM XbRw== X-Gm-Message-State: AKaTC02sHvvA7NYa/m3iOjESP5ImnsFciqUowAdRLN8Se9TYeSznVfhe/dj1USdMSMSbEA== X-Received: by 10.194.201.103 with SMTP id jz7mr10232258wjc.70.1480114848539; Fri, 25 Nov 2016 15:00:48 -0800 (PST) Received: from ?IPv6:2003:62:5f58:9d00:6166:92fb:e75e:7735? (p200300625F589D00616692FBE75E7735.dip0.t-ipconnect.de. [2003:62:5f58:9d00:6166:92fb:e75e:7735]) by smtp.googlemail.com with ESMTPSA id ab10sm49150062wjc.45.2016.11.25.15.00.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 25 Nov 2016 15:00:48 -0800 (PST) From: Heiner Kallweit Subject: [PATCH 1/4] spi: fsl-espi: determine need for byte swap only once To: Mark Brown References: <2424ba57-be1a-d32d-0c14-1662c2d02409@gmail.com> Cc: "linux-spi@vger.kernel.org" Message-ID: Date: Fri, 25 Nov 2016 23:58:49 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.5.0 MIME-Version: 1.0 In-Reply-To: <2424ba57-be1a-d32d-0c14-1662c2d02409@gmail.com> 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 Determine need for byte swap only once and store it in new member swab in struct fsl_espi. Signed-off-by: Heiner Kallweit --- This extension is needed for subsequent patches of this series. --- drivers/spi/spi-fsl-espi.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/spi/spi-fsl-espi.c b/drivers/spi/spi-fsl-espi.c index 4fbcc36..4222578 100644 --- a/drivers/spi/spi-fsl-espi.c +++ b/drivers/spi/spi-fsl-espi.c @@ -98,6 +98,7 @@ struct fsl_espi { const void *tx; void *rx; + bool swab; unsigned int rx_len; unsigned int tx_len; unsigned int rxskip; @@ -140,14 +141,14 @@ static void fsl_espi_memcpy_swab(void *to, const void *from, struct spi_message *m, struct spi_transfer *t) { + struct fsl_espi *espi = spi_master_get_devdata(m->spi->master); unsigned int len = t->len; - if (!(m->spi->mode & SPI_LSB_FIRST) || t->bits_per_word <= 8) { + if (!espi->swab) { memcpy(to, from, len); return; } - /* In case of LSB-first and bits_per_word > 8 byte-swap all words */ while (len) if (len >= 4) { *(u32 *)to = swahb32p(from); @@ -384,6 +385,9 @@ static int fsl_espi_trans(struct spi_message *m, struct spi_transfer *trans) struct spi_device *spi = m->spi; int ret; + /* In case of LSB-first and bits_per_word > 8 byte-swap all words */ + espi->swab = spi->mode & SPI_LSB_FIRST && trans->bits_per_word > 8; + espi->rxskip = fsl_espi_check_rxskip_mode(m); if (trans->rx_nbits == SPI_NBITS_DUAL && !espi->rxskip) { dev_err(espi->dev, "Dual output mode requires RXSKIP mode!\n");