From patchwork Fri Jan 23 16:08:43 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda Delgado X-Patchwork-Id: 5696131 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id D1D93C058D for ; Fri, 23 Jan 2015 16:27:30 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EF36F202E5 for ; Fri, 23 Jan 2015 16:27:29 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1FC05202C8 for ; Fri, 23 Jan 2015 16:27:29 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1YEh1a-000820-7X; Fri, 23 Jan 2015 16:23:58 +0000 Received: from casper.infradead.org ([2001:770:15f::2]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YEgnk-0003Mc-D5 for linux-arm-kernel@bombadil.infradead.org; Fri, 23 Jan 2015 16:09:40 +0000 Received: from mail-lb0-x231.google.com ([2a00:1450:4010:c04::231]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YEgnd-0004KU-5W for linux-arm-kernel@lists.infradead.org; Fri, 23 Jan 2015 16:09:34 +0000 Received: by mail-lb0-f177.google.com with SMTP id p9so7812998lbv.8 for ; Fri, 23 Jan 2015 08:09:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=HVFmuugyLxLJWumbad+1Zzww6eTv6TeKbArhfkNuVVU=; b=kD8MCp4vmdBbPol988n5x+X7Twvlmbmz74QRmx4NKRrtTbo7xNp6uoLxf4+rXwyuFx h3S7kx6W/XcTS0JPDQ5roHXPtNbf6ciBSKH7MwueWPYLLWzAh7VcbsotGIp6lX3F86OR rtryNAlZhh+UpZzHnB6U3Bc0N8W9uJAGGRvvSuYLthVK8dWclBC/Ip7MG2LiZ+FDswAt urFWr3aQQnzPqZJvPZIXMAOg5l1s96pD4XaGYudi6yOLm+EYK2gABK0mfQmSROmdlrQE R9LFrsiKpjyTWxSUZWFaNH0+3/f94ZxRa/KVwaFVSXO+Pr74tdd2xEW5XpYgP5j7EwDt d1Nw== X-Received: by 10.112.129.228 with SMTP id nz4mr8154395lbb.8.1422029350902; Fri, 23 Jan 2015 08:09:10 -0800 (PST) Received: from neopili.qtec.com (cpe.xe-3-0-1-778.vbrnqe10.dk.customer.tdc.net. [80.197.57.18]) by mx.google.com with ESMTPSA id h7sm542990lbl.41.2015.01.23.08.09.09 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 23 Jan 2015 08:09:10 -0800 (PST) From: Ricardo Ribalda Delgado To: Mark Brown , Michal Simek , =?UTF-8?q?S=C3=B6ren=20Brinkmann?= , linux-spi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 11/18] spi/xilinx: Remove rx_fn and tx_fn pointer Date: Fri, 23 Jan 2015 17:08:43 +0100 Message-Id: <1422029330-10971-12-git-send-email-ricardo.ribalda@gmail.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1422029330-10971-1-git-send-email-ricardo.ribalda@gmail.com> References: <1422029330-10971-1-git-send-email-ricardo.ribalda@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150123_160933_274505_68BB66E9 X-CRM114-Status: GOOD ( 15.45 ) X-Spam-Score: -2.7 (--) Cc: Ricardo Ribalda Delgado X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_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 Simplify the code by removing the tx and and rx function pointers and substitute them by a single function. Signed-off-by: Ricardo Ribalda Delgado --- drivers/spi/spi-xilinx.c | 69 +++++++++++++----------------------------------- 1 file changed, 18 insertions(+), 51 deletions(-) diff --git a/drivers/spi/spi-xilinx.c b/drivers/spi/spi-xilinx.c index 29edf1b..6b6c658 100644 --- a/drivers/spi/spi-xilinx.c +++ b/drivers/spi/spi-xilinx.c @@ -92,8 +92,6 @@ struct xilinx_spi { u32 cs_inactive; /* Level of the CS pins when inactive*/ unsigned int (*read_fn)(void __iomem *); void (*write_fn)(u32, void __iomem *); - void (*tx_fn)(struct xilinx_spi *); - void (*rx_fn)(struct xilinx_spi *); }; static void xspi_write32(u32 val, void __iomem *addr) @@ -116,49 +114,32 @@ static unsigned int xspi_read32_be(void __iomem *addr) return ioread32be(addr); } -static void xspi_tx8(struct xilinx_spi *xspi) -{ - xspi->write_fn(*xspi->tx_ptr, xspi->regs + XSPI_TXD_OFFSET); - xspi->tx_ptr++; -} - -static void xspi_tx16(struct xilinx_spi *xspi) -{ - xspi->write_fn(*(u16 *)(xspi->tx_ptr), xspi->regs + XSPI_TXD_OFFSET); - xspi->tx_ptr += 2; -} - -static void xspi_tx32(struct xilinx_spi *xspi) +static void xilinx_spi_tx(struct xilinx_spi *xspi) { xspi->write_fn(*(u32 *)(xspi->tx_ptr), xspi->regs + XSPI_TXD_OFFSET); - xspi->tx_ptr += 4; + xspi->tx_ptr += xspi->bits_per_word/8; } -static void xspi_rx8(struct xilinx_spi *xspi) +static void xilinx_spi_rx(struct xilinx_spi *xspi) { u32 data = xspi->read_fn(xspi->regs + XSPI_RXD_OFFSET); - if (xspi->rx_ptr) { - *xspi->rx_ptr = data & 0xff; - xspi->rx_ptr++; - } -} -static void xspi_rx16(struct xilinx_spi *xspi) -{ - u32 data = xspi->read_fn(xspi->regs + XSPI_RXD_OFFSET); - if (xspi->rx_ptr) { - *(u16 *)(xspi->rx_ptr) = data & 0xffff; - xspi->rx_ptr += 2; - } -} + if (!xspi->rx_ptr) + return; -static void xspi_rx32(struct xilinx_spi *xspi) -{ - u32 data = xspi->read_fn(xspi->regs + XSPI_RXD_OFFSET); - if (xspi->rx_ptr) { + switch (xspi->bits_per_word) { + case 8: + *(u8 *)(xspi->rx_ptr) = data; + break; + case 16: + *(u16 *)(xspi->rx_ptr) = data; + break; + case 32: *(u32 *)(xspi->rx_ptr) = data; - xspi->rx_ptr += 4; + break; } + + xspi->rx_ptr += xspi->bits_per_word/8; } static void xspi_init_hw(struct xilinx_spi *xspi) @@ -250,7 +231,7 @@ static void xilinx_spi_fill_tx_fifo(struct xilinx_spi *xspi, int n_words) while (n_words--) if (xspi->tx_ptr) - xspi->tx_fn(xspi); + xilinx_spi_tx(xspi); else xspi->write_fn(0, xspi->regs + XSPI_TXD_OFFSET); return; @@ -301,7 +282,7 @@ static int xilinx_spi_txrx_bufs(struct spi_device *spi, struct spi_transfer *t) /* Read out all the data from the Rx FIFO */ while (n_words--) - xspi->rx_fn(xspi); + xilinx_spi_rx(xspi); } return t->len - xspi->remaining_bytes; @@ -423,20 +404,6 @@ static int xilinx_spi_probe(struct platform_device *pdev) master->bits_per_word_mask = SPI_BPW_MASK(bits_per_word); xspi->bits_per_word = bits_per_word; - if (xspi->bits_per_word == 8) { - xspi->tx_fn = xspi_tx8; - xspi->rx_fn = xspi_rx8; - } else if (xspi->bits_per_word == 16) { - xspi->tx_fn = xspi_tx16; - xspi->rx_fn = xspi_rx16; - } else if (xspi->bits_per_word == 32) { - xspi->tx_fn = xspi_tx32; - xspi->rx_fn = xspi_rx32; - } else { - ret = -EINVAL; - goto put_master; - } - xspi->buffer_size = xilinx_spi_find_buffer_size(xspi); xspi->irq = platform_get_irq(pdev, 0);