aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/frv/lib/checksum.c24
-rw-r--r--include/asm-frv/checksum.h41
2 files changed, 31 insertions, 34 deletions
diff --git a/arch/frv/lib/checksum.c b/arch/frv/lib/checksum.c
index 2581a960d58f..44e16d59bc10 100644
--- a/arch/frv/lib/checksum.c
+++ b/arch/frv/lib/checksum.c
@@ -104,15 +104,15 @@ out:
104 * 104 *
105 * it's best to have buff aligned on a 32-bit boundary 105 * it's best to have buff aligned on a 32-bit boundary
106 */ 106 */
107unsigned int csum_partial(const unsigned char * buff, int len, unsigned int sum) 107__wsum csum_partial(const void *buff, int len, __wsum sum)
108{ 108{
109 unsigned int result = do_csum(buff, len); 109 unsigned int result = do_csum(buff, len);
110 110
111 /* add in old sum, and carry.. */ 111 /* add in old sum, and carry.. */
112 result += sum; 112 result += (__force u32)sum;
113 if (sum > result) 113 if ((__force u32)sum > result)
114 result += 1; 114 result += 1;
115 return result; 115 return (__force __wsum)result;
116} 116}
117 117
118EXPORT_SYMBOL(csum_partial); 118EXPORT_SYMBOL(csum_partial);
@@ -121,9 +121,9 @@ EXPORT_SYMBOL(csum_partial);
121 * this routine is used for miscellaneous IP-like checksums, mainly 121 * this routine is used for miscellaneous IP-like checksums, mainly
122 * in icmp.c 122 * in icmp.c
123 */ 123 */
124unsigned short ip_compute_csum(const unsigned char * buff, int len) 124__sum16 ip_compute_csum(const void *buff, int len)
125{ 125{
126 return ~do_csum(buff, len); 126 return (__force __sum16)~do_csum(buff, len);
127} 127}
128 128
129EXPORT_SYMBOL(ip_compute_csum); 129EXPORT_SYMBOL(ip_compute_csum);
@@ -131,9 +131,9 @@ EXPORT_SYMBOL(ip_compute_csum);
131/* 131/*
132 * copy from fs while checksumming, otherwise like csum_partial 132 * copy from fs while checksumming, otherwise like csum_partial
133 */ 133 */
134unsigned int 134__wsum
135csum_partial_copy_from_user(const char __user *src, char *dst, 135csum_partial_copy_from_user(const void __user *src, void *dst,
136 int len, int sum, int *csum_err) 136 int len, __wsum sum, int *csum_err)
137{ 137{
138 int rem; 138 int rem;
139 139
@@ -156,11 +156,11 @@ EXPORT_SYMBOL(csum_partial_copy_from_user);
156/* 156/*
157 * copy from ds while checksumming, otherwise like csum_partial 157 * copy from ds while checksumming, otherwise like csum_partial
158 */ 158 */
159unsigned int 159__wsum
160csum_partial_copy(const char *src, char *dst, int len, int sum) 160csum_partial_copy_nocheck(const void *src, void *dst, int len, __wsum sum)
161{ 161{
162 memcpy(dst, src, len); 162 memcpy(dst, src, len);
163 return csum_partial(dst, len, sum); 163 return csum_partial(dst, len, sum);
164} 164}
165 165
166EXPORT_SYMBOL(csum_partial_copy); 166EXPORT_SYMBOL(csum_partial_copy_nocheck);
diff --git a/include/asm-frv/checksum.h b/include/asm-frv/checksum.h
index 42bf0db2287a..9b1689850187 100644
--- a/include/asm-frv/checksum.h
+++ b/include/asm-frv/checksum.h
@@ -26,7 +26,7 @@
26 * 26 *
27 * it's best to have buff aligned on a 32-bit boundary 27 * it's best to have buff aligned on a 32-bit boundary
28 */ 28 */
29unsigned int csum_partial(const unsigned char * buff, int len, unsigned int sum); 29__wsum csum_partial(const void *buff, int len, __wsum sum);
30 30
31/* 31/*
32 * the same as csum_partial, but copies from src while it 32 * the same as csum_partial, but copies from src while it
@@ -35,7 +35,7 @@ unsigned int csum_partial(const unsigned char * buff, int len, unsigned int sum)
35 * here even more important to align src and dst on a 32-bit (or even 35 * here even more important to align src and dst on a 32-bit (or even
36 * better 64-bit) boundary 36 * better 64-bit) boundary
37 */ 37 */
38unsigned int csum_partial_copy(const char *src, char *dst, int len, int sum); 38__wsum csum_partial_copy_nocheck(const void *src, void *dst, int len, __wsum sum);
39 39
40/* 40/*
41 * the same as csum_partial_copy, but copies from user space. 41 * the same as csum_partial_copy, but copies from user space.
@@ -43,11 +43,8 @@ unsigned int csum_partial_copy(const char *src, char *dst, int len, int sum);
43 * here even more important to align src and dst on a 32-bit (or even 43 * here even more important to align src and dst on a 32-bit (or even
44 * better 64-bit) boundary 44 * better 64-bit) boundary
45 */ 45 */
46extern unsigned int csum_partial_copy_from_user(const char __user *src, char *dst, 46extern __wsum csum_partial_copy_from_user(const void __user *src, void *dst,
47 int len, int sum, int *csum_err); 47 int len, __wsum sum, int *csum_err);
48
49#define csum_partial_copy_nocheck(src, dst, len, sum) \
50 csum_partial_copy((src), (dst), (len), (sum))
51 48
52/* 49/*
53 * This is a version of ip_compute_csum() optimized for IP headers, 50 * This is a version of ip_compute_csum() optimized for IP headers,
@@ -55,7 +52,7 @@ extern unsigned int csum_partial_copy_from_user(const char __user *src, char *ds
55 * 52 *
56 */ 53 */
57static inline 54static inline
58unsigned short ip_fast_csum(unsigned char *iph, unsigned int ihl) 55__sum16 ip_fast_csum(const void *iph, unsigned int ihl)
59{ 56{
60 unsigned int tmp, inc, sum = 0; 57 unsigned int tmp, inc, sum = 0;
61 58
@@ -81,13 +78,13 @@ unsigned short ip_fast_csum(unsigned char *iph, unsigned int ihl)
81 : "icc0", "icc1" 78 : "icc0", "icc1"
82 ); 79 );
83 80
84 return ~sum; 81 return (__force __sum16)~sum;
85} 82}
86 83
87/* 84/*
88 * Fold a partial checksum 85 * Fold a partial checksum
89 */ 86 */
90static inline unsigned int csum_fold(unsigned int sum) 87static inline __sum16 csum_fold(__wsum sum)
91{ 88{
92 unsigned int tmp; 89 unsigned int tmp;
93 90
@@ -100,16 +97,16 @@ static inline unsigned int csum_fold(unsigned int sum)
100 : "0"(sum) 97 : "0"(sum)
101 ); 98 );
102 99
103 return ~sum; 100 return (__force __sum16)~sum;
104} 101}
105 102
106/* 103/*
107 * computes the checksum of the TCP/UDP pseudo-header 104 * computes the checksum of the TCP/UDP pseudo-header
108 * returns a 16-bit checksum, already complemented 105 * returns a 16-bit checksum, already complemented
109 */ 106 */
110static inline unsigned int 107static inline __wsum
111csum_tcpudp_nofold(unsigned long saddr, unsigned long daddr, unsigned short len, 108csum_tcpudp_nofold(__be32 saddr, __be32 daddr, unsigned short len,
112 unsigned short proto, unsigned int sum) 109 unsigned short proto, __wsum sum)
113{ 110{
114 asm(" addcc %1,%0,%0,icc0 \n" 111 asm(" addcc %1,%0,%0,icc0 \n"
115 " addxcc %2,%0,%0,icc0 \n" 112 " addxcc %2,%0,%0,icc0 \n"
@@ -122,9 +119,9 @@ csum_tcpudp_nofold(unsigned long saddr, unsigned long daddr, unsigned short len,
122 return sum; 119 return sum;
123} 120}
124 121
125static inline unsigned short int 122static inline __sum16
126csum_tcpudp_magic(unsigned long saddr, unsigned long daddr, unsigned short len, 123csum_tcpudp_magic(__be32 saddr, __be32 daddr, unsigned short len,
127 unsigned short proto, unsigned int sum) 124 unsigned short proto, __wsum sum)
128{ 125{
129 return csum_fold(csum_tcpudp_nofold(saddr,daddr,len,proto,sum)); 126 return csum_fold(csum_tcpudp_nofold(saddr,daddr,len,proto,sum));
130} 127}
@@ -133,12 +130,12 @@ csum_tcpudp_magic(unsigned long saddr, unsigned long daddr, unsigned short len,
133 * this routine is used for miscellaneous IP-like checksums, mainly 130 * this routine is used for miscellaneous IP-like checksums, mainly
134 * in icmp.c 131 * in icmp.c
135 */ 132 */
136extern unsigned short ip_compute_csum(const unsigned char * buff, int len); 133extern __sum16 ip_compute_csum(const void *buff, int len);
137 134
138#define _HAVE_ARCH_IPV6_CSUM 135#define _HAVE_ARCH_IPV6_CSUM
139static inline unsigned short int 136static inline __sum16
140csum_ipv6_magic(struct in6_addr *saddr, struct in6_addr *daddr, 137csum_ipv6_magic(const struct in6_addr *saddr, const struct in6_addr *daddr,
141 __u32 len, unsigned short proto, unsigned int sum) 138 __u32 len, unsigned short proto, __wsum sum)
142{ 139{
143 unsigned long tmp, tmp2; 140 unsigned long tmp, tmp2;
144 141
@@ -177,7 +174,7 @@ csum_ipv6_magic(struct in6_addr *saddr, struct in6_addr *daddr,
177 : "icc0" 174 : "icc0"
178 ); 175 );
179 176
180 return ~sum; 177 return (__force __sum16)~sum;
181} 178}
182 179
183#endif /* _ASM_CHECKSUM_H */ 180#endif /* _ASM_CHECKSUM_H */