Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

fpga-manager: altera-ps-spi: use bitrev8x4

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@gmail.com>
Signed-off-by: Alan Tull <atull@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Joshua Clayton and committed by
Greg Kroah-Hartman
fcfe18f8 3b88da4a

+15 -4
+15 -4
drivers/fpga/altera-ps-spi.c
··· 149 149 150 150 static void rev_buf(char *buf, size_t len) 151 151 { 152 - const char *fw_end = (buf + len); 152 + u32 *fw32 = (u32 *)buf; 153 + size_t extra_bytes = (len & 0x03); 154 + const u32 *fw_end = (u32 *)(buf + len - extra_bytes); 153 155 154 156 /* set buffer to lsb first */ 155 - while (buf < fw_end) { 156 - *buf = bitrev8(*buf); 157 - buf++; 157 + while (fw32 < fw_end) { 158 + *fw32 = bitrev8x4(*fw32); 159 + fw32++; 160 + } 161 + 162 + if (extra_bytes) { 163 + buf = (char *)fw_end; 164 + while (extra_bytes) { 165 + *buf = bitrev8(*buf); 166 + buf++; 167 + extra_bytes--; 168 + } 158 169 } 159 170 } 160 171