treewide: remove redundant IS_ERR() before error code check
[linux/fpc-iii.git] / arch / csky / include / asm / checksum.h
blob7685824291b1dcebce99045b2c1e57f19e7f61d5
1 /* SPDX-License-Identifier: GPL-2.0 */
2 // Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
4 #ifndef __ASM_CSKY_CHECKSUM_H
5 #define __ASM_CSKY_CHECKSUM_H
7 #include <linux/in6.h>
8 #include <asm/byteorder.h>
10 static inline __sum16 csum_fold(__wsum csum)
12 u32 tmp;
14 asm volatile(
15 "mov %1, %0\n"
16 "rori %0, 16\n"
17 "addu %0, %1\n"
18 "lsri %0, 16\n"
19 : "=r"(csum), "=r"(tmp)
20 : "0"(csum));
22 return (__force __sum16) ~csum;
24 #define csum_fold csum_fold
26 static inline __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr,
27 unsigned short len, unsigned short proto, __wsum sum)
29 asm volatile(
30 "clrc\n"
31 "addc %0, %1\n"
32 "addc %0, %2\n"
33 "addc %0, %3\n"
34 "inct %0\n"
35 : "=r"(sum)
36 : "r"((__force u32)saddr), "r"((__force u32)daddr),
37 #ifdef __BIG_ENDIAN
38 "r"(proto + len),
39 #else
40 "r"((proto + len) << 8),
41 #endif
42 "0" ((__force unsigned long)sum)
43 : "cc");
44 return sum;
46 #define csum_tcpudp_nofold csum_tcpudp_nofold
48 #include <asm-generic/checksum.h>
50 #endif /* __ASM_CSKY_CHECKSUM_H */