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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230715010407.1751715-8-fabrizio.castro.jz@renesas.com>
Date:   Sat, 15 Jul 2023 02:04:04 +0100
From:   Fabrizio Castro <fabrizio.castro.jz@...esas.com>
To:     Mark Brown <broonie@...nel.org>,
        Geert Uytterhoeven <geert+renesas@...der.be>
Cc:     Fabrizio Castro <fabrizio.castro.jz@...esas.com>,
        Andy Shevchenko <andy.shevchenko@...il.com>,
        linux-spi@...r.kernel.org, linux-kernel@...r.kernel.org,
        Chris Paterson <Chris.Paterson2@...esas.com>,
        Biju Das <biju.das@...renesas.com>,
        Lad Prabhakar <prabhakar.mahadev-lad.rj@...renesas.com>,
        linux-renesas-soc@...r.kernel.org
Subject: [PATCH 07/10] spi: rzv2m-csi: Switch to using {read,write}s{b,w}

The RX/TX FIFOs implemented by the CSI IP are accessed by
repeatedly reading/writing the same memory address, and
therefore they are the ideal candidate for {read,write}s{b,w}.
The RZ/V2M CSI driver currently implements loops to fill up
the TX FIFO and empty the RX FIFO, differentiating between
8-bit and 16-bit word size.
Switch to using {read,write}s{b,w} to get rid of the bespoke
loops.

Signed-off-by: Fabrizio Castro <fabrizio.castro.jz@...esas.com>
---
 drivers/spi/spi-rzv2m-csi.c | 42 +++++++++++++------------------------
 1 file changed, 14 insertions(+), 28 deletions(-)

diff --git a/drivers/spi/spi-rzv2m-csi.c b/drivers/spi/spi-rzv2m-csi.c
index faf5898bc3e0..d0d6b183ffaf 100644
--- a/drivers/spi/spi-rzv2m-csi.c
+++ b/drivers/spi/spi-rzv2m-csi.c
@@ -86,8 +86,8 @@ struct rzv2m_csi_priv {
 	struct clk *pclk;
 	struct device *dev;
 	struct spi_controller *controller;
-	const u8 *txbuf;
-	u8 *rxbuf;
+	const void *txbuf;
+	void *rxbuf;
 	int buffer_len;
 	int bytes_sent;
 	int bytes_received;
@@ -157,22 +157,15 @@ static int rzv2m_csi_start_stop_operation(const struct rzv2m_csi_priv *csi,
 
 static int rzv2m_csi_fill_txfifo(struct rzv2m_csi_priv *csi)
 {
-	int i;
-
 	if (readl(csi->base + CSI_OFIFOL))
 		return -EIO;
 
-	if (csi->bytes_per_word == 2) {
-		u16 *buf = (u16 *)csi->txbuf;
-
-		for (i = 0; i < csi->words_to_transfer; i++)
-			writel(buf[i], csi->base + CSI_OFIFO);
-	} else {
-		u8 *buf = (u8 *)csi->txbuf;
-
-		for (i = 0; i < csi->words_to_transfer; i++)
-			writel(buf[i], csi->base + CSI_OFIFO);
-	}
+	if (csi->bytes_per_word == 2)
+		writesw(csi->base + CSI_OFIFO, csi->txbuf,
+			csi->words_to_transfer);
+	else
+		writesb(csi->base + CSI_OFIFO, csi->txbuf,
+			csi->words_to_transfer);
 
 	csi->txbuf += csi->bytes_to_transfer;
 	csi->bytes_sent += csi->bytes_to_transfer;
@@ -182,22 +175,15 @@ static int rzv2m_csi_fill_txfifo(struct rzv2m_csi_priv *csi)
 
 static int rzv2m_csi_read_rxfifo(struct rzv2m_csi_priv *csi)
 {
-	int i;
-
 	if (readl(csi->base + CSI_IFIFOL) != csi->bytes_to_transfer)
 		return -EIO;
 
-	if (csi->bytes_per_word == 2) {
-		u16 *buf = (u16 *)csi->rxbuf;
-
-		for (i = 0; i < csi->words_to_transfer; i++)
-			buf[i] = (u16)readl(csi->base + CSI_IFIFO);
-	} else {
-		u8 *buf = (u8 *)csi->rxbuf;
-
-		for (i = 0; i < csi->words_to_transfer; i++)
-			buf[i] = (u8)readl(csi->base + CSI_IFIFO);
-	}
+	if (csi->bytes_per_word == 2)
+		readsw(csi->base + CSI_IFIFO, csi->rxbuf,
+		       csi->words_to_transfer);
+	else
+		readsb(csi->base + CSI_IFIFO, csi->rxbuf,
+		       csi->words_to_transfer);
 
 	csi->rxbuf += csi->bytes_to_transfer;
 	csi->bytes_received += csi->bytes_to_transfer;
-- 
2.34.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ