summaryrefslogtreecommitdiffstats
path: root/arch/tile/include/asm/checksum.h
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2012-07-25 14:33:45 +0200
committerArnd Bergmann <arnd@arndb.de>2012-07-25 14:35:04 +0200
commit8cef081c71dd4e16a01a1e63cedab21eef8b5735 (patch)
treeb5b0fb5ab09dc60dee5fc8fd8e980359abbd1b1e /arch/tile/include/asm/checksum.h
parent3d55c29fb24286f350f04021bef2dd799e25dd20 (diff)
parent9161c3b796a2841a9a7be3d9c9dd121269ce90e8 (diff)
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux into fixes
The merge of the 'clk-for-linus' branch caused an automated merge failure. Pull that in here so we can fix the problem. Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Diffstat (limited to 'arch/tile/include/asm/checksum.h')
-rw-r--r--arch/tile/include/asm/checksum.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/arch/tile/include/asm/checksum.h b/arch/tile/include/asm/checksum.h
index a120766c726..b21a2fdec9f 100644
--- a/arch/tile/include/asm/checksum.h
+++ b/arch/tile/include/asm/checksum.h
@@ -21,4 +21,22 @@
__wsum do_csum(const unsigned char *buff, int len);
#define do_csum do_csum
+/*
+ * Return the sum of all the 16-bit subwords in a long.
+ * This sums two subwords on a 32-bit machine, and four on 64 bits.
+ * The implementation does two vector adds to capture any overflow.
+ */
+static inline unsigned int csum_long(unsigned long x)
+{
+ unsigned long ret;
+#ifdef __tilegx__
+ ret = __insn_v2sadu(x, 0);
+ ret = __insn_v2sadu(ret, 0);
+#else
+ ret = __insn_sadh_u(x, 0);
+ ret = __insn_sadh_u(ret, 0);
+#endif
+ return ret;
+}
+
#endif /* _ASM_TILE_CHECKSUM_H */