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

Configure Feed

Select the types of activity you want to include in your feed.

powerpc: Use rol32() instead of opencoding in csum_fold()

rol32(x, 16) will do the rotate using rlwinm.

No need to open code using inline assembly.

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/794337eff7bb803d2c4e67d9eee635390c4c48fe.1646812553.git.christophe.leroy@csgroup.eu

authored by

Christophe Leroy and committed by
Michael Ellerman
a1ae4317 e6f6390a

+8 -7
+8 -7
arch/powerpc/include/asm/checksum.h
··· 38 38 */ 39 39 static inline __sum16 csum_fold(__wsum sum) 40 40 { 41 - unsigned int tmp; 41 + u32 tmp = (__force u32)sum; 42 42 43 - /* swap the two 16-bit halves of sum */ 44 - __asm__("rlwinm %0,%1,16,0,31" : "=r" (tmp) : "r" (sum)); 45 - /* if there is a carry from adding the two 16-bit halves, 46 - it will carry from the lower half into the upper half, 47 - giving us the correct sum in the upper half. */ 48 - return (__force __sum16)(~((__force u32)sum + tmp) >> 16); 43 + /* 44 + * swap the two 16-bit halves of sum 45 + * if there is a carry from adding the two 16-bit halves, 46 + * it will carry from the lower half into the upper half, 47 + * giving us the correct sum in the upper half. 48 + */ 49 + return (__force __sum16)(~(tmp + rol32(tmp, 16)) >> 16); 49 50 } 50 51 51 52 static inline u32 from64to32(u64 x)