Skip to content

Commit d0f0f63

Browse files
committed
MIPS: Rewrite csum_fold to plain C.
This isn't only short and easier to read and fully portable but also shrinks a Malta kernel's by 160 bytes. Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
1 parent eaa27f3 commit d0f0f63

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

arch/mips/include/asm/checksum.h

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -103,22 +103,16 @@ __wsum csum_partial_copy_nocheck(const void *src, void *dst,
103103
/*
104104
* Fold a partial checksum without adding pseudo headers
105105
*/
106-
static inline __sum16 csum_fold(__wsum sum)
106+
static inline __sum16 csum_fold(__wsum csum)
107107
{
108-
__asm__(
109-
" .set push # csum_fold\n"
110-
" .set noat \n"
111-
" sll $1, %0, 16 \n"
112-
" addu %0, $1 \n"
113-
" sltu $1, %0, $1 \n"
114-
" srl %0, %0, 16 \n"
115-
" addu %0, $1 \n"
116-
" xori %0, 0xffff \n"
117-
" .set pop"
118-
: "=r" (sum)
119-
: "0" (sum));
108+
u32 sum = (__force u32)csum;;
109+
110+
sum += (sum << 16);
111+
csum = (sum < csum);
112+
sum >>= 16;
113+
sum += csum;
120114

121-
return (__force __sum16)sum;
115+
return (__force __sum16)~sum;
122116
}
123117

124118
/*

0 commit comments

Comments
 (0)