Skip to contentSkip to conversation

spi: zynq_spi.c:Optmizations done in spi_xfer func

PATCH New Chakra Divi 1 participant 1 message Jun 20, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 spi: zynq_spi.c:Optmizations done in spi_xfer func

This Patch replaces the arithmatic operators with bitwise operators for optimizations hoping it would save some cycles

---
Note: Jagan or anyone please test this patch, I don't have hardware with me.

---
 drivers/spi/zynq_spi.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/spi/zynq_spi.c +2 -2
index e9129da..a8a160b 100644
@@ -218,7 +218,7 @@ int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout,
 		void *din, unsigned long flags)
 {
 	struct zynq_spi_slave *zslave = to_zynq_spi_slave(slave);
-	u32 len = bitlen / 8;
+	u32 len = bitlen >> 3;
 	u32 tx_len = len, rx_len = len, tx_tvl;
 	const u8 *tx_buf = dout;
 	u8 *rx_buf = din, buf;
@@ -227,7 +227,7 @@ int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout,
 	debug("spi_xfer: bus:%i cs:%i bitlen:%i len:%i flags:%lx\n",
 	      slave->bus, slave->cs, bitlen, len, flags);
 
-	if (bitlen % 8) {
+	if (bitlen & 0x7) {
 		debug("spi_xfer: Non byte aligned SPI transfer\n");
 		return -1;
 	}
Signature · 1 line
1.7.9.5