]> git.proxmox.com Git - mirror_ubuntu-disco-kernel.git/commitdiff
MIPS: Rewrite csum_fold to plain C.
authorRalf Baechle <ralf@linux-mips.org>
Wed, 17 Dec 2014 13:06:00 +0000 (14:06 +0100)
committerRalf Baechle <ralf@linux-mips.org>
Tue, 13 Jan 2015 15:04:27 +0000 (16:04 +0100)
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>
arch/mips/include/asm/checksum.h

index 3418c51e11512ed2a3957448fbb68d83ebac1858..ac0f55cc6e7893347b6dc0f2b7ed912a52ed2e29 100644 (file)
@@ -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;
 }
 
 /*