[U-Boot] [PATCH] spi: zynq_spi.c:Optmizations done in spi_xfer func

Chakra Divi cdivi at openedev.com
Sat Jun 20 17:57:49 CEST 2015


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

Signed-off-by: Chakra Divi <cdivi at openedev.com>
---
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(-)

diff --git a/drivers/spi/zynq_spi.c b/drivers/spi/zynq_spi.c
index e9129da..a8a160b 100644
--- a/drivers/spi/zynq_spi.c
+++ b/drivers/spi/zynq_spi.c
@@ -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;
 	}
-- 
1.7.9.5



More information about the U-Boot mailing list