From patchwork Sun Oct 19 18:43:37 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 400829 X-Patchwork-Delegate: jagannadh.teki@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 6049414007F for ; Mon, 20 Oct 2014 05:45:40 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 09B67A741D; Sun, 19 Oct 2014 20:44:36 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id tlDqia-07-di; Sun, 19 Oct 2014 20:44:35 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 9389FA73FD; Sun, 19 Oct 2014 20:44:35 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 4F7CA4B608 for ; Sun, 19 Oct 2014 20:43:56 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id y0Gsy4cPmmMg for ; Sun, 19 Oct 2014 20:43:56 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-out.m-online.net (mail-out.m-online.net [212.18.0.9]) by theia.denx.de (Postfix) with ESMTPS id 2BEA44B601 for ; Sun, 19 Oct 2014 20:43:52 +0200 (CEST) Received: from mail.nefkom.net (unknown [192.168.8.184]) by mail-out.m-online.net (Postfix) with ESMTP id 3jLVP11kQbz3hj7p; Sun, 19 Oct 2014 20:43:49 +0200 (CEST) X-Auth-Info: w3AuCzdD5gYfo14huzfc5EeALxOEVQslD4RspVKsCw0= Received: from chi.lan (host-82-135-33-74.customer.m-online.net [82.135.33.74]) by smtp-auth.mnet-online.de (Postfix) with ESMTPA id 3jLVP03SQqzvdWR; Sun, 19 Oct 2014 20:43:48 +0200 (CEST) From: Marek Vasut To: u-boot@lists.denx.de Date: Sun, 19 Oct 2014 20:43:37 +0200 Message-Id: <1413744219-6859-5-git-send-email-marex@denx.de> X-Mailer: git-send-email 2.0.0 In-Reply-To: <1413744219-6859-1-git-send-email-marex@denx.de> References: <1413744219-6859-1-git-send-email-marex@denx.de> Cc: Marek Vasut , Pavel Machek , Chin Liang See , Tom Rini , Dinh Nguyen Subject: [U-Boot] [PATCH 5/7] spi: altera: Clean up the use of variable d X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.13 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de The variable d is used in rather questionable way. Rework the code a bit so it's clearer what it does. Also, rename the variable from d to data to make it's name less mysterious. Finally, change it's data type to uint32_t , since it's accessed as a 32bit number. Signed-off-by: Marek Vasut Cc: Chin Liang See Cc: Dinh Nguyen Cc: Albert Aribaud Cc: Tom Rini Cc: Wolfgang Denk Cc: Pavel Machek Cc: Jagannadha Sutradharudu Teki --- drivers/spi/altera_spi.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/drivers/spi/altera_spi.c b/drivers/spi/altera_spi.c index ee65ec2..3065e96 100644 --- a/drivers/spi/altera_spi.c +++ b/drivers/spi/altera_spi.c @@ -126,11 +126,11 @@ int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout, { struct altera_spi_slave *altspi = to_altera_spi_slave(slave); /* assume spi core configured to do 8 bit transfers */ - uint bytes = bitlen / 8; - const uchar *txp = dout; - uchar *rxp = din; + unsigned int bytes = bitlen / 8; + const unsigned char *txp = dout; + unsigned char *rxp = din; int timeout = 10000; - uint32_t reg; + uint32_t reg, data; debug("%s: bus:%i cs:%i bitlen:%i bytes:%i flags:%lx\n", __func__, slave->bus, slave->cs, bitlen, bytes, flags); @@ -151,10 +151,13 @@ int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout, spi_cs_activate(slave); while (bytes--) { - uchar d = txp ? *txp++ : CONFIG_ALTERA_SPI_IDLE_VAL; + if (txp) + data = *txp++; + else + data = CONFIG_ALTERA_SPI_IDLE_VAL; - debug("%s: tx:%x ", __func__, d); - writel(d, &altspi->regs->txdata); + debug("%s: tx:%x ", __func__, data); + writel(data, &altspi->regs->txdata); while (--timeout) { reg = readl(&altspi->regs->status); @@ -167,11 +170,11 @@ int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout, goto done; } - d = readl(&altspi->regs->rxdata); + data = readl(&altspi->regs->rxdata); if (rxp) - *rxp++ = d; + *rxp++ = data & 0xff; - debug("rx:%x\n", d); + debug("rx:%x\n", data); } done: