lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1308794413-11069-6-git-send-email-dirk.brandewie@gmail.com>
Date:	Wed, 22 Jun 2011 19:00:07 -0700
From:	dirk.brandewie@...il.com
To:	linux-kernel@...r.kernel.org,
	spi-devel-general@...ts.sourceforge.net
Cc:	Dirk Brandewie <dirk.brandewie@...il.com>
Subject: [PATCH 05/11] spi-dw: split spi_dw_enable_chip() into spi_dw_enable()/spi_dw_disable()

From: Dirk Brandewie <dirk.brandewie@...il.com>

Split spi_dw_enable_chip() into two inline functions for readabilty.

Signed-off-by: Dirk Brandewie <dirk.brandewie@...il.com>
---
 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)
-- 
1.7.3.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ