From patchwork Thu Jun 23 02:00:07 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: dirk.brandewie@gmail.com X-Patchwork-Id: 907722 Received: from lists.sourceforge.net (lists.sourceforge.net [216.34.181.88]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p5N20wdU002404 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 23 Jun 2011 02:01:19 GMT Received: from localhost ([127.0.0.1] helo=sfs-ml-4.v29.ch3.sourceforge.com) by sfs-ml-4.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1QZZE2-0006J0-O5; Thu, 23 Jun 2011 02:00:58 +0000 Received: from sog-mx-3.v43.ch3.sourceforge.com ([172.29.43.193] helo=mx.sourceforge.net) by sfs-ml-4.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1QZZE2-0006If-0w for spi-devel-general@lists.sourceforge.net; Thu, 23 Jun 2011 02:00:58 +0000 Received-SPF: pass (sog-mx-3.v43.ch3.sourceforge.com: domain of gmail.com designates 209.85.210.47 as permitted sender) client-ip=209.85.210.47; envelope-from=dirk.brandewie@gmail.com; helo=mail-pz0-f47.google.com; Received: from mail-pz0-f47.google.com ([209.85.210.47]) by sog-mx-3.v43.ch3.sourceforge.com with esmtps (TLSv1:RC4-SHA:128) (Exim 4.76) id 1QZZE1-0007cj-7i for spi-devel-general@lists.sourceforge.net; Thu, 23 Jun 2011 02:00:58 +0000 Received: by pzk36 with SMTP id 36so1176434pzk.34 for ; Wed, 22 Jun 2011 19:00:51 -0700 (PDT) Received: by 10.142.143.5 with SMTP id q5mr323382wfd.163.1308794451277; Wed, 22 Jun 2011 19:00:51 -0700 (PDT) Received: from localhost.localdomain (static-50-43-44-248.bvtn.or.frontiernet.net [50.43.44.248]) by mx.google.com with ESMTPS id u6sm846417pbh.80.2011.06.22.19.00.50 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 22 Jun 2011 19:00:50 -0700 (PDT) From: dirk.brandewie@gmail.com To: linux-kernel@vger.kernel.org, spi-devel-general@lists.sourceforge.net Subject: [PATCH 05/11] spi-dw: split spi_dw_enable_chip() into spi_dw_enable()/spi_dw_disable() Date: Wed, 22 Jun 2011 19:00:07 -0700 Message-Id: <1308794413-11069-6-git-send-email-dirk.brandewie@gmail.com> X-Mailer: git-send-email 1.7.3.4 In-Reply-To: <1308794413-11069-1-git-send-email-dirk.brandewie@gmail.com> References: <1308794413-11069-1-git-send-email-dirk.brandewie@gmail.com> X-Spam-Score: -1.6 (-) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -1.5 SPF_CHECK_PASS SPF reports sender host as permitted sender for sender-domain 0.0 FREEMAIL_FROM Sender email is freemail (dirk.brandewie[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.0 RFC_ABUSE_POST Both abuse and postmaster missing on sender domain 0.0 T_TO_NO_BRKTS_FREEMAIL T_TO_NO_BRKTS_FREEMAIL -0.0 AWL AWL: From: address is in the auto white-list X-Headers-End: 1QZZE1-0007cj-7i Cc: Dirk Brandewie 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 X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Thu, 23 Jun 2011 02:01:19 +0000 (UTC) From: Dirk Brandewie Split spi_dw_enable_chip() into two inline functions for readabilty. Signed-off-by: Dirk Brandewie --- drivers/spi/spi-dw-mid.c | 4 ++-- drivers/spi/spi-dw.c | 16 ++++++++-------- drivers/spi/spi-dw.h | 9 +++++++-- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/drivers/spi/spi-dw-mid.c b/drivers/spi/spi-dw-mid.c index 7659cef..78e64d3 100644 --- a/drivers/spi/spi-dw-mid.c +++ b/drivers/spi/spi-dw-mid.c @@ -115,7 +115,7 @@ static int mid_spi_dma_transfer(struct spi_dw *dws, int cs_change) /* 1. setup DMA related registers */ if (cs_change) { - spi_dw_enable_chip(dws, 0); + spi_dw_disable(dws); dw_writew(dws, dmardlr, 0xf); dw_writew(dws, dmatdlr, 0x10); if (dws->tx_dma) @@ -123,7 +123,7 @@ static int mid_spi_dma_transfer(struct spi_dw *dws, int cs_change) if (dws->rx_dma) dma_ctrl |= 0x1; dw_writew(dws, dmacr, dma_ctrl); - spi_dw_enable_chip(dws, 1); + spi_dw_enable(dws); } dws->dma_chan_done = 0; diff --git a/drivers/spi/spi-dw.c b/drivers/spi/spi-dw.c index 3d98e4c..ad92826 100644 --- a/drivers/spi/spi-dw.c +++ b/drivers/spi/spi-dw.c @@ -293,7 +293,7 @@ static void spi_dw_giveback(struct spi_dw *dws) static void spi_dw_int_error_stop(struct spi_dw *dws, const char *msg) { /* Stop the hw */ - spi_dw_enable_chip(dws, 0); + spi_dw_disable(dws); dev_err(&dws->master->dev, "%s\n", msg); dws->cur_msg->state = ERROR_STATE; @@ -518,7 +518,7 @@ static void spi_dw_pump_transfers(unsigned long data) * 3. control value changes */ if (dw_readw(dws, ctrl0) != cr0 || cs_change || clk_div || imask) { - spi_dw_enable_chip(dws, 0); + spi_dw_disable(dws); if (dw_readw(dws, ctrl0) != cr0) dw_writew(dws, ctrl0, cr0); @@ -533,7 +533,7 @@ static void spi_dw_pump_transfers(unsigned long data) if (txint_level) dw_writew(dws, txfltr, txint_level); - spi_dw_enable_chip(dws, 1); + spi_dw_enable(dws); if (cs_change) dws->prev_chip = chip; } @@ -776,9 +776,9 @@ static int destroy_queue(struct spi_dw *dws) /* Restart the controller, disable all interrupts, clean rx fifo */ static void spi_dw_hw_init(struct spi_dw *dws) { - spi_dw_enable_chip(dws, 0); + spi_dw_disable(dws); spi_dw_mask_intr(dws, 0xff); - spi_dw_enable_chip(dws, 1); + spi_dw_enable(dws); /* * Try to detect the FIFO depth if not set by interface driver, @@ -868,7 +868,7 @@ err_queue_alloc: if (dws->dma_ops && dws->dma_ops->dma_exit) dws->dma_ops->dma_exit(dws); err_diable_hw: - spi_dw_enable_chip(dws, 0); + spi_dw_disable(dws); free_irq(dws->irq, dws); err_free_master: spi_master_put(master); @@ -893,7 +893,7 @@ void __devexit spi_dw_remove_host(struct spi_dw *dws) if (dws->dma_ops && dws->dma_ops->dma_exit) dws->dma_ops->dma_exit(dws); - spi_dw_enable_chip(dws, 0); + spi_dw_disable(dws); /* Disable clk */ spi_dw_set_clk(dws, 0); free_irq(dws->irq, dws); @@ -910,7 +910,7 @@ int spi_dw_suspend_host(struct spi_dw *dws) ret = spi_dw_stop_queue(dws); if (ret) return ret; - spi_dw_enable_chip(dws, 0); + spi_dw_disable(dws); spi_dw_set_clk(dws, 0); return ret; } diff --git a/drivers/spi/spi-dw.h b/drivers/spi/spi-dw.h index 6a1ee63..860bc34 100644 --- a/drivers/spi/spi-dw.h +++ b/drivers/spi/spi-dw.h @@ -161,9 +161,14 @@ struct spi_dw { #define dw_writew(dw, name, val) \ __raw_writew((val), &(((struct spi_dw_reg *)dw->regs)->name)) -static inline void spi_dw_enable_chip(struct spi_dw *dws, int enable) +static inline void spi_dw_enable(struct spi_dw *dws) { - dw_writel(dws, ssienr, (enable ? 1 : 0)); + dw_writel(dws, ssienr, 1); +} + +static inline void spi_dw_disable(struct spi_dw *dws) +{ + dw_writel(dws, ssienr, 0); } static inline void spi_dw_set_clk(struct spi_dw *dws, u16 div)