Commit d0f0f63a authored by Ralf Baechle's avatar Ralf Baechle

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: default avatarRalf Baechle <ralf@linux-mips.org>
parent eaa27f34
...@@ -103,22 +103,16 @@ __wsum csum_partial_copy_nocheck(const void *src, void *dst, ...@@ -103,22 +103,16 @@ __wsum csum_partial_copy_nocheck(const void *src, void *dst,
/* /*
* Fold a partial checksum without adding pseudo headers * Fold a partial checksum without adding pseudo headers
*/ */
static inline __sum16 csum_fold(__wsum sum) static inline __sum16 csum_fold(__wsum csum)
{ {
__asm__( u32 sum = (__force u32)csum;;
" .set push # csum_fold\n"
" .set noat \n" sum += (sum << 16);
" sll $1, %0, 16 \n" csum = (sum < csum);
" addu %0, $1 \n" sum >>= 16;
" sltu $1, %0, $1 \n" sum += csum;
" srl %0, %0, 16 \n"
" addu %0, $1 \n"
" xori %0, 0xffff \n"
" .set pop"
: "=r" (sum)
: "0" (sum));
return (__force __sum16)sum; return (__force __sum16)~sum;
} }
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment