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: <20211223011358.4031459-48-davidm@egauge.net>
Date:   Thu, 23 Dec 2021 01:14:07 +0000 (UTC)
From:   David Mosberger-Tang <davidm@...uge.net>
To:     Ajay Singh <ajay.kathat@...rochip.com>
Cc:     Claudiu Beznea <claudiu.beznea@...rochip.com>,
        Kalle Valo <kvalo@...nel.org>,
        "David S. Miller" <davem@...emloft.net>,
        Jakub Kicinski <kuba@...nel.org>,
        linux-wireless@...r.kernel.org, netdev@...r.kernel.org,
        linux-kernel@...r.kernel.org,
        David Mosberger-Tang <davidm@...uge.net>
Subject: [PATCH v2 47/50] wilc1000: factor SPI DMA command initialization code
 into a function

Introduce wilc_spi_dma_init_cmd() as a helper function as this will
come in handy later.

Signed-off-by: David Mosberger-Tang <davidm@...uge.net>
---
 drivers/net/wireless/microchip/wilc1000/spi.c | 41 +++++++++++++------
 1 file changed, 28 insertions(+), 13 deletions(-)

diff --git a/drivers/net/wireless/microchip/wilc1000/spi.c b/drivers/net/wireless/microchip/wilc1000/spi.c
index 189907580d921..3e2022b43ee70 100644
--- a/drivers/net/wireless/microchip/wilc1000/spi.c
+++ b/drivers/net/wireless/microchip/wilc1000/spi.c
@@ -650,21 +650,14 @@ static int wilc_spi_write_cmd(struct wilc *wilc, u8 cmd, u32 adr, u32 data,
 	return 0;
 }
 
-static int wilc_spi_dma_rw(struct wilc *wilc, u8 cmd, u32 adr, u8 *b, u32 sz)
+static int wilc_spi_dma_init_cmd(struct wilc *wilc, struct wilc_spi_cmd *c,
+				 u8 cmd, u32 adr, u32 sz)
 {
 	struct spi_device *spi = to_spi_device(wilc->dev);
 	struct wilc_spi *spi_priv = wilc->bus_data;
-	u16 crc_recv, crc_calc;
-	u8 wb[32], rb[32];
-	int cmd_len, resp_len;
-	int retry, ix = 0;
-	u8 crc[2], *crc7;
-	struct wilc_spi_cmd *c;
-	struct wilc_spi_rsp_data *r;
+	int cmd_len;
+	u8 *crc7;
 
-	memset(wb, 0x0, sizeof(wb));
-	memset(rb, 0x0, sizeof(rb));
-	c = (struct wilc_spi_cmd *)wb;
 	c->cmd_type = cmd;
 	if (cmd == CMD_DMA_WRITE || cmd == CMD_DMA_READ) {
 		c->u.dma_cmd.addr[0] = adr >> 16;
@@ -687,10 +680,32 @@ static int wilc_spi_dma_rw(struct wilc *wilc, u8 cmd, u32 adr, u8 *b, u32 sz)
 		return -EINVAL;
 	}
 	if (spi_priv->crc7_enabled) {
-		crc7 = wb + cmd_len;
-		*crc7 = wilc_get_crc7(wb, cmd_len);
+		crc7 = (u8 *)c + cmd_len;
+		*crc7 = wilc_get_crc7((u8 *)c, cmd_len);
 		cmd_len += 1;
 	}
+	return cmd_len;
+}
+
+static int wilc_spi_dma_rw(struct wilc *wilc, u8 cmd, u32 adr, u8 *b, u32 sz)
+{
+	struct spi_device *spi = to_spi_device(wilc->dev);
+	struct wilc_spi *spi_priv = wilc->bus_data;
+	u16 crc_recv, crc_calc;
+	u8 wb[32], rb[32];
+	int cmd_len, resp_len;
+	int retry, ix = 0;
+	u8 crc[2];
+	struct wilc_spi_cmd *c;
+	struct wilc_spi_rsp_data *r;
+
+	memset(wb, 0x0, sizeof(wb));
+	memset(rb, 0x0, sizeof(rb));
+	c = (struct wilc_spi_cmd *)wb;
+
+	cmd_len = wilc_spi_dma_init_cmd(wilc, c, cmd, adr, sz);
+	if (cmd_len < 0)
+		return -EINVAL;
 
 	resp_len = sizeof(*r);
 
-- 
2.25.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ