From patchwork Fri Jun 28 18:44:04 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hartley Sweeten X-Patchwork-Id: 2800471 Return-Path: X-Original-To: patchwork-spi-devel-general@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 0015E9F245 for ; Fri, 28 Jun 2013 18:44:51 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 13E96201E1 for ; Fri, 28 Jun 2013 18:44:51 +0000 (UTC) Received: from lists.sourceforge.net (lists.sourceforge.net [216.34.181.88]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E2992201D9 for ; Fri, 28 Jun 2013 18:44:49 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=sfs-ml-1.v29.ch3.sourceforge.com) by sfs-ml-1.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1Usdf6-0005ne-Kl; Fri, 28 Jun 2013 18:44:48 +0000 Received: from sog-mx-2.v43.ch3.sourceforge.com ([172.29.43.192] helo=mx.sourceforge.net) by sfs-ml-1.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1Usdf3-0005n0-P6 for spi-devel-general@lists.sourceforge.net; Fri, 28 Jun 2013 18:44:45 +0000 X-ACL-Warn: Received: from mail1.bemta7.messagelabs.com ([216.82.254.109]) by sog-mx-2.v43.ch3.sourceforge.com with esmtps (TLSv1:AES256-SHA:256) (Exim 4.76) id 1Usdf1-0001Xl-KP for spi-devel-general@lists.sourceforge.net; Fri, 28 Jun 2013 18:44:45 +0000 Received: from [216.82.255.3:42553] by server-13.bemta-7.messagelabs.com id E6/0B-01729-599DDC15; Fri, 28 Jun 2013 18:44:37 +0000 X-Env-Sender: hartleys@visionengravers.com X-Msg-Ref: server-13.tower-209.messagelabs.com!1372445076!6021990!1 X-Originating-IP: [216.166.12.180] X-StarScan-Received: X-StarScan-Version: 6.9.9; banners=-,-,- X-VirusChecked: Checked Received: (qmail 19767 invoked from network); 28 Jun 2013 18:44:36 -0000 Received: from out001.collaborationhost.net (HELO out001.collaborationhost.net) (216.166.12.180) by server-13.tower-209.messagelabs.com with RC4-SHA encrypted SMTP; 28 Jun 2013 18:44:36 -0000 Received: from etch.local (10.2.3.210) by smtp.collaborationhost.net (10.2.0.232) with Microsoft SMTP Server (TLS) id 8.3.213.0; Fri, 28 Jun 2013 13:44:36 -0500 From: H Hartley Sweeten To: Linux Kernel Subject: [PATCH 4/8] spi: spi-ep93xx: remove bits_per_word() helper Date: Fri, 28 Jun 2013 11:44:04 -0700 User-Agent: KMail/1.9.9 MIME-Version: 1.0 Content-Disposition: inline Message-ID: <201306281144.04549.hartleys@visionengravers.com> X-Spam-Score: 0.0 (/) X-Headers-End: 1Usdf1-0001Xl-KP Cc: grant.likely@linaro.org, spi-devel-general@lists.sourceforge.net, mika.westerberg@iki.fi, broonie@kernel.org, Ryan Mallon X-BeenThere: spi-devel-general@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list List-Id: Linux SPI core/device drivers discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: spi-devel-general-bounces@lists.sourceforge.net X-Spam-Status: No, score=-8.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This inline helper function is only used to determine the bus width of the current transfer (8 or 16 bit). Add a bool flag to the private structure and set it appropriately for each transfer. Signed-off-by: H Hartley Sweeten Cc: Ryan Mallon Cc: Mika Westerberg Cc: Mark Brown Cc: Grant Likely --- drivers/spi/spi-ep93xx.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/drivers/spi/spi-ep93xx.c b/drivers/spi/spi-ep93xx.c index bcfd35a..4fab3bb 100644 --- a/drivers/spi/spi-ep93xx.c +++ b/drivers/spi/spi-ep93xx.c @@ -116,6 +116,7 @@ struct ep93xx_spi { unsigned long min_rate; unsigned long max_rate; bool running; + bool word_xfer; struct workqueue_struct *wq; struct work_struct msg_work; struct completion wait; @@ -407,17 +408,9 @@ static void ep93xx_spi_chip_setup(const struct ep93xx_spi *espi, writew(cr0, espi->regs_base + SSPCR0); } -static inline int bits_per_word(const struct ep93xx_spi *espi) -{ - struct spi_message *msg = espi->current_msg; - struct spi_transfer *t = msg->state; - - return t->bits_per_word; -} - static void ep93xx_do_write(struct ep93xx_spi *espi, struct spi_transfer *t) { - if (bits_per_word(espi) > 8) { + if (espi->word_xfer) { u16 tx_val = 0; if (t->tx_buf) @@ -436,7 +429,7 @@ static void ep93xx_do_write(struct ep93xx_spi *espi, struct spi_transfer *t) static void ep93xx_do_read(struct ep93xx_spi *espi, struct spi_transfer *t) { - if (bits_per_word(espi) > 8) { + if (espi->word_xfer) { u16 rx_val; rx_val = readw(espi->regs_base + SSPDR); @@ -522,7 +515,7 @@ ep93xx_spi_dma_prepare(struct ep93xx_spi *espi, enum dma_transfer_direction dir) size_t len = t->len; int i, ret, nents; - if (bits_per_word(espi) > 8) + if (espi->word_xfer) buswidth = DMA_SLAVE_BUSWIDTH_2_BYTES; else buswidth = DMA_SLAVE_BUSWIDTH_1_BYTE; @@ -699,6 +692,7 @@ static void ep93xx_spi_process_transfer(struct ep93xx_spi *espi, ep93xx_spi_chip_setup(espi, chip); + espi->word_xfer = (t->bits_per_word > 8) ? true : false; espi->rx = 0; espi->tx = 0;