aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-sh
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2006-11-15 00:22:35 -0500
committerDavid S. Miller <davem@sunset.davemloft.net>2006-12-03 00:23:22 -0500
commit7c73a746ba726faa5ab12981b4b192768eb439de (patch)
treeabe01077bb01b4cdff0e653674cfa85c2ec6c813 /include/asm-sh
parentf994aae1bd8e4813d59a2ed64d17585fe42d03fc (diff)
[NET]: SH checksum annotations and cleanups.
* sanitize prototypes, annotate * kill useless shifts * usual ntohs->shift Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/asm-sh')
-rw-r--r--include/asm-sh/checksum.h59
1 files changed, 29 insertions, 30 deletions
diff --git a/include/asm-sh/checksum.h b/include/asm-sh/checksum.h
index 08168afe6746..d44344c88e73 100644
--- a/include/asm-sh/checksum.h
+++ b/include/asm-sh/checksum.h
@@ -23,7 +23,7 @@
23 * 23 *
24 * it's best to have buff aligned on a 32-bit boundary 24 * it's best to have buff aligned on a 32-bit boundary
25 */ 25 */
26asmlinkage unsigned int csum_partial(const unsigned char * buff, int len, unsigned int sum); 26asmlinkage __wsum csum_partial(const void *buff, int len, __wsum sum);
27 27
28/* 28/*
29 * the same as csum_partial, but copies from src while it 29 * the same as csum_partial, but copies from src while it
@@ -33,8 +33,8 @@ asmlinkage unsigned int csum_partial(const unsigned char * buff, int len, unsign
33 * better 64-bit) boundary 33 * better 64-bit) boundary
34 */ 34 */
35 35
36asmlinkage unsigned int csum_partial_copy_generic(const unsigned char *src, unsigned char *dst, 36asmlinkage __wsum csum_partial_copy_generic(const void *src, void *dst,
37 int len, int sum, int *src_err_ptr, int *dst_err_ptr); 37 int len, __wsum sum, int *src_err_ptr, int *dst_err_ptr);
38 38
39/* 39/*
40 * Note: when you get a NULL pointer exception here this means someone 40 * Note: when you get a NULL pointer exception here this means someone
@@ -44,24 +44,25 @@ asmlinkage unsigned int csum_partial_copy_generic(const unsigned char *src, unsi
44 * access_ok(). 44 * access_ok().
45 */ 45 */
46static __inline__ 46static __inline__
47unsigned int csum_partial_copy_nocheck (const unsigned char *src, unsigned char *dst, 47__wsum csum_partial_copy_nocheck(const void *src, void *dst,
48 int len, int sum) 48 int len, __wsum sum)
49{ 49{
50 return csum_partial_copy_generic ( src, dst, len, sum, NULL, NULL); 50 return csum_partial_copy_generic ( src, dst, len, sum, NULL, NULL);
51} 51}
52 52
53static __inline__ 53static __inline__
54unsigned int csum_partial_copy_from_user (const unsigned char *src, unsigned char *dst, 54__wsum csum_partial_copy_from_user(const void __user *src, void *dst,
55 int len, int sum, int *err_ptr) 55 int len, __wsum sum, int *err_ptr)
56{ 56{
57 return csum_partial_copy_generic ( src, dst, len, sum, err_ptr, NULL); 57 return csum_partial_copy_generic((__force const void *)src, dst,
58 len, sum, err_ptr, NULL);
58} 59}
59 60
60/* 61/*
61 * Fold a partial checksum 62 * Fold a partial checksum
62 */ 63 */
63 64
64static __inline__ unsigned int csum_fold(unsigned int sum) 65static __inline__ __sum16 csum_fold(__wsum sum)
65{ 66{
66 unsigned int __dummy; 67 unsigned int __dummy;
67 __asm__("swap.w %0, %1\n\t" 68 __asm__("swap.w %0, %1\n\t"
@@ -74,7 +75,7 @@ static __inline__ unsigned int csum_fold(unsigned int sum)
74 : "=r" (sum), "=&r" (__dummy) 75 : "=r" (sum), "=&r" (__dummy)
75 : "0" (sum) 76 : "0" (sum)
76 : "t"); 77 : "t");
77 return sum; 78 return (__force __sum16)sum;
78} 79}
79 80
80/* 81/*
@@ -84,7 +85,7 @@ static __inline__ unsigned int csum_fold(unsigned int sum)
84 * i386 version by Jorge Cwik <jorge@laser.satlink.net>, adapted 85 * i386 version by Jorge Cwik <jorge@laser.satlink.net>, adapted
85 * for linux by * Arnt Gulbrandsen. 86 * for linux by * Arnt Gulbrandsen.
86 */ 87 */
87static __inline__ unsigned short ip_fast_csum(unsigned char * iph, unsigned int ihl) 88static __inline__ __sum16 ip_fast_csum(const void *iph, unsigned int ihl)
88{ 89{
89 unsigned int sum, __dummy0, __dummy1; 90 unsigned int sum, __dummy0, __dummy1;
90 91
@@ -112,16 +113,15 @@ static __inline__ unsigned short ip_fast_csum(unsigned char * iph, unsigned int
112 return csum_fold(sum); 113 return csum_fold(sum);
113} 114}
114 115
115static __inline__ unsigned long csum_tcpudp_nofold(unsigned long saddr, 116static __inline__ __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr,
116 unsigned long daddr,
117 unsigned short len, 117 unsigned short len,
118 unsigned short proto, 118 unsigned short proto,
119 unsigned int sum) 119 __wsum sum)
120{ 120{
121#ifdef __LITTLE_ENDIAN__ 121#ifdef __LITTLE_ENDIAN__
122 unsigned long len_proto = (ntohs(len)<<16)+proto*256; 122 unsigned long len_proto = (proto + len) << 8;
123#else 123#else
124 unsigned long len_proto = (proto<<16)+len; 124 unsigned long len_proto = proto + len;
125#endif 125#endif
126 __asm__("clrt\n\t" 126 __asm__("clrt\n\t"
127 "addc %0, %1\n\t" 127 "addc %0, %1\n\t"
@@ -139,11 +139,10 @@ static __inline__ unsigned long csum_tcpudp_nofold(unsigned long saddr,
139 * computes the checksum of the TCP/UDP pseudo-header 139 * computes the checksum of the TCP/UDP pseudo-header
140 * returns a 16-bit checksum, already complemented 140 * returns a 16-bit checksum, already complemented
141 */ 141 */
142static __inline__ unsigned short int csum_tcpudp_magic(unsigned long saddr, 142static __inline__ __sum16 csum_tcpudp_magic(__be32 saddr, __be32 daddr,
143 unsigned long daddr,
144 unsigned short len, 143 unsigned short len,
145 unsigned short proto, 144 unsigned short proto,
146 unsigned int sum) 145 __wsum sum)
147{ 146{
148 return csum_fold(csum_tcpudp_nofold(saddr,daddr,len,proto,sum)); 147 return csum_fold(csum_tcpudp_nofold(saddr,daddr,len,proto,sum));
149} 148}
@@ -153,18 +152,17 @@ static __inline__ unsigned short int csum_tcpudp_magic(unsigned long saddr,
153 * in icmp.c 152 * in icmp.c
154 */ 153 */
155 154
156static __inline__ unsigned short ip_compute_csum(unsigned char * buff, int len) 155static __inline__ __sum16 ip_compute_csum(const void *buff, int len)
157{ 156{
158 return csum_fold (csum_partial(buff, len, 0)); 157 return csum_fold (csum_partial(buff, len, 0));
159} 158}
160 159
161#define _HAVE_ARCH_IPV6_CSUM 160#define _HAVE_ARCH_IPV6_CSUM
162#ifdef CONFIG_IPV6 161#ifdef CONFIG_IPV6
163static __inline__ unsigned short int csum_ipv6_magic(struct in6_addr *saddr, 162static __inline__ __sum16 csum_ipv6_magic(const struct in6_addr *saddr,
164 struct in6_addr *daddr, 163 const struct in6_addr *daddr,
165 __u32 len, 164 __u32 len, unsigned short proto,
166 unsigned short proto, 165 __wsum sum)
167 unsigned int sum)
168{ 166{
169 unsigned int __dummy; 167 unsigned int __dummy;
170 __asm__("clrt\n\t" 168 __asm__("clrt\n\t"
@@ -201,17 +199,18 @@ static __inline__ unsigned short int csum_ipv6_magic(struct in6_addr *saddr,
201 * Copy and checksum to user 199 * Copy and checksum to user
202 */ 200 */
203#define HAVE_CSUM_COPY_USER 201#define HAVE_CSUM_COPY_USER
204static __inline__ unsigned int csum_and_copy_to_user (const unsigned char *src, 202static __inline__ __wsum csum_and_copy_to_user (const void *src,
205 unsigned char __user *dst, 203 void __user *dst,
206 int len, int sum, 204 int len, __wsum sum,
207 int *err_ptr) 205 int *err_ptr)
208{ 206{
209 if (access_ok(VERIFY_WRITE, dst, len)) 207 if (access_ok(VERIFY_WRITE, dst, len))
210 return csum_partial_copy_generic(src, dst, len, sum, NULL, err_ptr); 208 return csum_partial_copy_generic((__force const void *)src,
209 dst, len, sum, NULL, err_ptr);
211 210
212 if (len) 211 if (len)
213 *err_ptr = -EFAULT; 212 *err_ptr = -EFAULT;
214 213
215 return -1; /* invalid checksum */ 214 return (__force __wsum)-1; /* invalid checksum */
216} 215}
217#endif /* __ASM_SH_CHECKSUM_H */ 216#endif /* __ASM_SH_CHECKSUM_H */