From patchwork Mon Jun 3 12:03:49 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerhard Sittig X-Patchwork-Id: 2652081 Return-Path: X-Original-To: patchwork-spi-devel-general@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from lists.sourceforge.net (lists.sourceforge.net [216.34.181.88]) by patchwork2.kernel.org (Postfix) with ESMTP id 8C6B3DF24C for ; Mon, 3 Jun 2013 12:04:56 +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 1UjTVQ-0006xt-7F; Mon, 03 Jun 2013 12:04:56 +0000 Received: from sog-mx-1.v43.ch3.sourceforge.com ([172.29.43.191] helo=mx.sourceforge.net) by sfs-ml-1.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1UjTVO-0006xm-MM for spi-devel-general@lists.sourceforge.net; Mon, 03 Jun 2013 12:04:54 +0000 X-ACL-Warn: Received: from mail-out.m-online.net ([212.18.0.9]) by sog-mx-1.v43.ch3.sourceforge.com with esmtps (TLSv1:AES256-SHA:256) (Exim 4.76) id 1UjTVN-0007hd-N4 for spi-devel-general@lists.sourceforge.net; Mon, 03 Jun 2013 12:04:54 +0000 Received: from frontend1.mail.m-online.net (unknown [192.168.8.180]) by mail-out.m-online.net (Postfix) with ESMTP id 3bPFLl0LkFz4KKYd; Mon, 3 Jun 2013 14:04:47 +0200 (CEST) Received: from localhost (dynscan1.mnet-online.de [192.168.6.68]) by mail.m-online.net (Postfix) with ESMTP id 3bPFLl01VYzbblv; Mon, 3 Jun 2013 14:04:46 +0200 (CEST) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.180]) by localhost (dynscan1.mail.m-online.net [192.168.6.68]) (amavisd-new, port 10024) with ESMTP id 9d0O39LGSXMI; Mon, 3 Jun 2013 14:04:45 +0200 (CEST) X-Auth-Info: 56RVgFK025oBmS25jCe0x5A6XPFMMyNztFaZDurOFeI= Received: from localhost (kons-4d03cb5c.pool.mediaWays.net [77.3.203.92]) by mail.mnet-online.de (Postfix) with ESMTPA; Mon, 3 Jun 2013 14:04:45 +0200 (CEST) From: Gerhard Sittig To: spi-devel-general@lists.sourceforge.net Subject: [PATCH v1 1/3] spi: mpc512x: minor prep before feature change Date: Mon, 3 Jun 2013 14:03:49 +0200 Message-Id: <1370261031-28572-2-git-send-email-gsi@denx.de> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1370261031-28572-1-git-send-email-gsi@denx.de> References: <1370261031-28572-1-git-send-email-gsi@denx.de> X-Spam-Score: 0.0 (/) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [212.18.0.9 listed in list.dnswl.org] X-Headers-End: 1UjTVN-0007hd-N4 Cc: Grant Likely , Gerhard Sittig , Mark Brown , dzu@denx.de 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: , MIME-Version: 1.0 Errors-To: spi-devel-general-bounces@lists.sourceforge.net mechanical edits before changing functionality, to reduce diffs - rename variables to later tell remaining TX and RX apart - use size_t for the current TX and RX length (for better compatibility with the min() macro) - remove unused members from the master data (sysclk, eofbyte) - silence a checkpatch warning (braces around single statement) Signed-off-by: Gerhard Sittig --- drivers/spi/spi-mpc512x-psc.c | 43 ++++++++++++++++++----------------------- 1 file changed, 19 insertions(+), 24 deletions(-) this patch triggers a checkpatch warning which IMO is acceptable (see the cover letter for the details) diff --git a/drivers/spi/spi-mpc512x-psc.c b/drivers/spi/spi-mpc512x-psc.c index dfddf33..759a937 100644 --- a/drivers/spi/spi-mpc512x-psc.c +++ b/drivers/spi/spi-mpc512x-psc.c @@ -33,7 +33,6 @@ struct mpc512x_psc_spi { void (*cs_control)(struct spi_device *spi, bool on); - u32 sysclk; /* driver internal data */ struct mpc52xx_psc __iomem *psc; @@ -42,7 +41,6 @@ struct mpc512x_psc_spi { u8 bits_per_word; u8 busy; u32 mclk; - u8 eofbyte; struct workqueue_struct *workqueue; struct work_struct work; @@ -50,7 +48,7 @@ struct mpc512x_psc_spi { struct list_head queue; spinlock_t lock; /* Message queue lock */ - struct completion done; + struct completion txisrdone; }; /* controller state */ @@ -138,7 +136,7 @@ static int mpc512x_psc_spi_transfer_rxtx(struct spi_device *spi, struct mpc512x_psc_spi *mps = spi_master_get_devdata(spi->master); struct mpc52xx_psc __iomem *psc = mps->psc; struct mpc512x_psc_fifo __iomem *fifo = mps->fifo; - size_t len = t->len; + size_t tx_len = t->len; u8 *tx_buf = (u8 *)t->tx_buf; u8 *rx_buf = (u8 *)t->rx_buf; @@ -152,58 +150,57 @@ static int mpc512x_psc_spi_transfer_rxtx(struct spi_device *spi, /* enable transmiter/receiver */ out_8(&psc->command, MPC52xx_PSC_TX_ENABLE | MPC52xx_PSC_RX_ENABLE); - while (len) { - int count; + while (tx_len) { + size_t txcount; int i; u8 data; size_t fifosz; - int rxcount; + size_t rxcount; /* * The number of bytes that can be sent at a time * depends on the fifo size. */ fifosz = MPC512x_PSC_FIFO_SZ(in_be32(&fifo->txsz)); - count = min(fifosz, len); + txcount = min(fifosz, tx_len); - for (i = count; i > 0; i--) { + for (i = txcount; i > 0; i--) { data = tx_buf ? *tx_buf++ : 0; - if (len == EOFBYTE && t->cs_change) + if (tx_len == EOFBYTE && t->cs_change) setbits32(&fifo->txcmd, MPC512x_PSC_FIFO_EOF); out_8(&fifo->txdata_8, data); - len--; + tx_len--; } - INIT_COMPLETION(mps->done); + INIT_COMPLETION(mps->txisrdone); /* interrupt on tx fifo empty */ out_be32(&fifo->txisr, MPC512x_PSC_FIFO_EMPTY); out_be32(&fifo->tximr, MPC512x_PSC_FIFO_EMPTY); - wait_for_completion(&mps->done); + wait_for_completion(&mps->txisrdone); mdelay(1); - /* rx fifo should have count bytes in it */ + /* rx fifo should have txcount bytes in it */ rxcount = in_be32(&fifo->rxcnt); - if (rxcount != count) + if (rxcount != txcount) mdelay(1); rxcount = in_be32(&fifo->rxcnt); - if (rxcount != count) { + if (rxcount != txcount) { dev_warn(&spi->dev, "expected %d bytes in rx fifo " - "but got %d\n", count, rxcount); + "but got %d\n", txcount, rxcount); } - rxcount = min(rxcount, count); + rxcount = min(rxcount, txcount); for (i = rxcount; i > 0; i--) { data = in_8(&fifo->rxdata_8); if (rx_buf) *rx_buf++ = data; } - while (in_be32(&fifo->rxcnt)) { + while (in_be32(&fifo->rxcnt)) in_8(&fifo->rxdata_8); - } } /* disable transmiter/receiver and fifo interrupt */ out_8(&psc->command, MPC52xx_PSC_TX_DISABLE | MPC52xx_PSC_RX_DISABLE); @@ -412,7 +409,7 @@ static irqreturn_t mpc512x_psc_spi_isr(int irq, void *dev_id) in_be32(&fifo->tximr) & MPC512x_PSC_FIFO_EMPTY) { out_be32(&fifo->txisr, MPC512x_PSC_FIFO_EMPTY); out_be32(&fifo->tximr, 0); - complete(&mps->done); + complete(&mps->txisrdone); return IRQ_HANDLED; } return IRQ_NONE; @@ -444,11 +441,9 @@ static int mpc512x_psc_spi_do_probe(struct device *dev, u32 regaddr, if (pdata == NULL) { mps->cs_control = mpc512x_spi_cs_control; - mps->sysclk = 0; master->bus_num = bus_num; } else { mps->cs_control = pdata->cs_control; - mps->sysclk = pdata->sysclk; master->bus_num = pdata->bus_num; master->num_chipselect = pdata->max_chipselect; } @@ -479,7 +474,7 @@ static int mpc512x_psc_spi_do_probe(struct device *dev, u32 regaddr, goto free_irq; spin_lock_init(&mps->lock); - init_completion(&mps->done); + init_completion(&mps->txisrdone); INIT_WORK(&mps->work, mpc512x_psc_spi_work); INIT_LIST_HEAD(&mps->queue);