[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20170614153635.2763-9-atull@kernel.org>
Date: Wed, 14 Jun 2017 10:36:32 -0500
From: Alan Tull <atull@...nel.org>
To: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc: Moritz Fischer <moritz.fischer@...us.com>,
Alan Tull <atull@...nel.org>, linux-kernel@...r.kernel.org,
linux-fpga@...r.kernel.org,
Joshua Clayton <stillcompiling@...il.com>
Subject: [PATCH v2 08/11] fpga-manager: altera-ps-spi: use bitrev8x4
From: Joshua Clayton <stillcompiling@...il.com>
Speed up bit reversal by using hardware bit reversal
Add extra code to handle less than 4byte remnants, if any
Signed-off-by: Joshua Clayton <stillcompiling@...il.com>
Signed-off-by: Alan Tull <atull@...nel.org>
---
drivers/fpga/altera-ps-spi.c | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
diff --git a/drivers/fpga/altera-ps-spi.c b/drivers/fpga/altera-ps-spi.c
index 0db8def..14f14ef 100644
--- a/drivers/fpga/altera-ps-spi.c
+++ b/drivers/fpga/altera-ps-spi.c
@@ -149,12 +149,23 @@ static int altera_ps_write_init(struct fpga_manager *mgr,
static void rev_buf(char *buf, size_t len)
{
- const char *fw_end = (buf + len);
+ u32 *fw32 = (u32 *)buf;
+ size_t extra_bytes = (len & 0x03);
+ const u32 *fw_end = (u32 *)(buf + len - extra_bytes);
/* set buffer to lsb first */
- while (buf < fw_end) {
- *buf = bitrev8(*buf);
- buf++;
+ while (fw32 < fw_end) {
+ *fw32 = bitrev8x4(*fw32);
+ fw32++;
+ }
+
+ if (extra_bytes) {
+ buf = (char *)fw_end;
+ while (extra_bytes) {
+ *buf = bitrev8(*buf);
+ buf++;
+ extra_bytes--;
+ }
}
}
--
2.7.4
Powered by blists - more mailing lists