summaryrefslogtreecommitdiff
path: root/arch/mips/include/asm/checksum.h
diff options
context:
space:
mode:
authorRalf Baechle <ralf@linux-mips.org>2014-12-17 14:06:00 +0100
committerRalf Baechle <ralf@linux-mips.org>2015-01-13 16:04:27 +0100
commitd0f0f63ac1374c13b7862b48bd7d6514913dbcad (patch)
treed83a6c15cab7497d224dde1fc7016963921a93f0 /arch/mips/include/asm/checksum.h
parenteaa27f34e91a14cdceed26ed6c6793ec1d186115 (diff)
downloadlinux-next-d0f0f63ac1374c13b7862b48bd7d6514913dbcad.tar.gz
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>
Diffstat (limited to 'arch/mips/include/asm/checksum.h')
-rw-r--r--arch/mips/include/asm/checksum.h22
1 files changed, 8 insertions, 14 deletions
diff --git a/arch/mips/include/asm/checksum.h b/arch/mips/include/asm/checksum.h
index 3418c51e1151..ac0f55cc6e78 100644
--- a/arch/mips/include/asm/checksum.h
+++ b/arch/mips/include/asm/checksum.h
@@ -103,22 +103,16 @@ __wsum csum_partial_copy_nocheck(const void *src, void *dst,
/*
* Fold a partial checksum without adding pseudo headers
*/
-static inline __sum16 csum_fold(__wsum sum)
+static inline __sum16 csum_fold(__wsum csum)
{
- __asm__(
- " .set push # csum_fold\n"
- " .set noat \n"
- " sll $1, %0, 16 \n"
- " addu %0, $1 \n"
- " sltu $1, %0, $1 \n"
- " srl %0, %0, 16 \n"
- " addu %0, $1 \n"
- " xori %0, 0xffff \n"
- " .set pop"
- : "=r" (sum)
- : "0" (sum));
+ u32 sum = (__force u32)csum;;
+
+ sum += (sum << 16);
+ csum = (sum < csum);
+ sum >>= 16;
+ sum += csum;
- return (__force __sum16)sum;
+ return (__force __sum16)~sum;
}
/*