diff mbox series

[v2,46/50] wilc1000: remove duplicate CRC calculation code

Message ID 20211223011358.4031459-47-davidm@egauge.net (mailing list archive)
State Changes Requested
Delegated to: Kalle Valo
Headers show
Series wilc1000: rework tx path to use sk_buffs throughout | expand

Commit Message

David Mosberger-Tang Dec. 23, 2021, 1:14 a.m. UTC
Factor two copies of the same calculation into a single instance.

Signed-off-by: David Mosberger-Tang <davidm@egauge.net>
---
 drivers/net/wireless/microchip/wilc1000/spi.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/drivers/net/wireless/microchip/wilc1000/spi.c b/drivers/net/wireless/microchip/wilc1000/spi.c
index 5f73b3d2d2112..189907580d921 100644
--- a/drivers/net/wireless/microchip/wilc1000/spi.c
+++ b/drivers/net/wireless/microchip/wilc1000/spi.c
@@ -658,7 +658,7 @@  static int wilc_spi_dma_rw(struct wilc *wilc, u8 cmd, u32 adr, u8 *b, u32 sz)
 	u8 wb[32], rb[32];
 	int cmd_len, resp_len;
 	int retry, ix = 0;
-	u8 crc[2];
+	u8 crc[2], *crc7;
 	struct wilc_spi_cmd *c;
 	struct wilc_spi_rsp_data *r;
 
@@ -673,8 +673,6 @@  static int wilc_spi_dma_rw(struct wilc *wilc, u8 cmd, u32 adr, u8 *b, u32 sz)
 		c->u.dma_cmd.size[0] = sz >> 8;
 		c->u.dma_cmd.size[1] = sz;
 		cmd_len = offsetof(struct wilc_spi_cmd, u.dma_cmd.crc);
-		if (spi_priv->crc7_enabled)
-			c->u.dma_cmd.crc[0] = wilc_get_crc7(wb, cmd_len);
 	} else if (cmd == CMD_DMA_EXT_WRITE || cmd == CMD_DMA_EXT_READ) {
 		c->u.dma_cmd_ext.addr[0] = adr >> 16;
 		c->u.dma_cmd_ext.addr[1] = adr >> 8;
@@ -683,15 +681,16 @@  static int wilc_spi_dma_rw(struct wilc *wilc, u8 cmd, u32 adr, u8 *b, u32 sz)
 		c->u.dma_cmd_ext.size[1] = sz >> 8;
 		c->u.dma_cmd_ext.size[2] = sz;
 		cmd_len = offsetof(struct wilc_spi_cmd, u.dma_cmd_ext.crc);
-		if (spi_priv->crc7_enabled)
-			c->u.dma_cmd_ext.crc[0] = wilc_get_crc7(wb, cmd_len);
 	} else {
 		dev_err(&spi->dev, "dma read write cmd [%x] not supported\n",
 			cmd);
 		return -EINVAL;
 	}
-	if (spi_priv->crc7_enabled)
+	if (spi_priv->crc7_enabled) {
+		crc7 = wb + cmd_len;
+		*crc7 = wilc_get_crc7(wb, cmd_len);
 		cmd_len += 1;
+	}
 
 	resp_len = sizeof(*r);