forked from mirrors/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>
This commit is contained in:
		
							parent
							
								
									3b88da4aba
								
							
						
					
					
						commit
						fcfe18f885
					
				
					 1 changed files with 15 additions and 4 deletions
				
			
		| 
						 | 
					@ -149,12 +149,23 @@ static int altera_ps_write_init(struct fpga_manager *mgr,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void rev_buf(char *buf, size_t len)
 | 
					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 */
 | 
						/* set buffer to lsb first */
 | 
				
			||||||
	while (buf < fw_end) {
 | 
						while (fw32 < fw_end) {
 | 
				
			||||||
		*buf = bitrev8(*buf);
 | 
							*fw32 = bitrev8x4(*fw32);
 | 
				
			||||||
		buf++;
 | 
							fw32++;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (extra_bytes) {
 | 
				
			||||||
 | 
							buf = (char *)fw_end;
 | 
				
			||||||
 | 
							while (extra_bytes) {
 | 
				
			||||||
 | 
								*buf = bitrev8(*buf);
 | 
				
			||||||
 | 
								buf++;
 | 
				
			||||||
 | 
								extra_bytes--;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue