aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/v850/kernel/v850_ksyms.c2
-rw-r--r--arch/v850/lib/checksum.c26
-rw-r--r--include/asm-v850/checksum.h38
3 files changed, 31 insertions, 35 deletions
diff --git a/arch/v850/kernel/v850_ksyms.c b/arch/v850/kernel/v850_ksyms.c
index 67bc48e57c60..93575fdc874d 100644
--- a/arch/v850/kernel/v850_ksyms.c
+++ b/arch/v850/kernel/v850_ksyms.c
@@ -24,7 +24,7 @@ EXPORT_SYMBOL (kernel_thread);
24EXPORT_SYMBOL (__bug); 24EXPORT_SYMBOL (__bug);
25 25
26/* Networking helper routines. */ 26/* Networking helper routines. */
27EXPORT_SYMBOL (csum_partial_copy); 27EXPORT_SYMBOL (csum_partial_copy_nocheck);
28EXPORT_SYMBOL (csum_partial_copy_from_user); 28EXPORT_SYMBOL (csum_partial_copy_from_user);
29EXPORT_SYMBOL (ip_compute_csum); 29EXPORT_SYMBOL (ip_compute_csum);
30EXPORT_SYMBOL (ip_fast_csum); 30EXPORT_SYMBOL (ip_fast_csum);
diff --git a/arch/v850/lib/checksum.c b/arch/v850/lib/checksum.c
index fa5872633075..042158dfe17a 100644
--- a/arch/v850/lib/checksum.c
+++ b/arch/v850/lib/checksum.c
@@ -88,32 +88,32 @@ out:
88 * This is a version of ip_compute_csum() optimized for IP headers, 88 * This is a version of ip_compute_csum() optimized for IP headers,
89 * which always checksum on 4 octet boundaries. 89 * which always checksum on 4 octet boundaries.
90 */ 90 */
91unsigned short ip_fast_csum(unsigned char * iph, unsigned int ihl) 91__sum16 ip_fast_csum(const void *iph, unsigned int ihl)
92{ 92{
93 return ~do_csum(iph,ihl*4); 93 return (__force __sum16)~do_csum(iph,ihl*4);
94} 94}
95 95
96/* 96/*
97 * this routine is used for miscellaneous IP-like checksums, mainly 97 * this routine is used for miscellaneous IP-like checksums, mainly
98 * in icmp.c 98 * in icmp.c
99 */ 99 */
100unsigned short ip_compute_csum(const unsigned char * buff, int len) 100__sum16 ip_compute_csum(const void *buff, int len)
101{ 101{
102 return ~do_csum(buff,len); 102 return (__force __sum16)~do_csum(buff,len);
103} 103}
104 104
105/* 105/*
106 * computes a partial checksum, e.g. for TCP/UDP fragments 106 * computes a partial checksum, e.g. for TCP/UDP fragments
107 */ 107 */
108unsigned int csum_partial(const unsigned char *buff, int len, unsigned int sum) 108__wsum csum_partial(const void *buff, int len, __wsum sum)
109{ 109{
110 unsigned int result = do_csum(buff, len); 110 unsigned int result = do_csum(buff, len);
111 111
112 /* add in old sum, and carry.. */ 112 /* add in old sum, and carry.. */
113 result += sum; 113 result += (__force u32)sum;
114 if(sum > result) 114 if ((__force u32)sum > result)
115 result += 1; 115 result += 1;
116 return result; 116 return (__force __wsum)result;
117} 117}
118 118
119EXPORT_SYMBOL(csum_partial); 119EXPORT_SYMBOL(csum_partial);
@@ -121,8 +121,8 @@ EXPORT_SYMBOL(csum_partial);
121/* 121/*
122 * copy while checksumming, otherwise like csum_partial 122 * copy while checksumming, otherwise like csum_partial
123 */ 123 */
124unsigned int csum_partial_copy(const unsigned char *src, unsigned char *dst, 124__wsum csum_partial_copy_nocheck(const void *src, void *dst,
125 int len, unsigned int sum) 125 int len, __wsum sum)
126{ 126{
127 /* 127 /*
128 * It's 2:30 am and I don't feel like doing it real ... 128 * It's 2:30 am and I don't feel like doing it real ...
@@ -138,9 +138,9 @@ unsigned int csum_partial_copy(const unsigned char *src, unsigned char *dst,
138 * Copy from userspace and compute checksum. If we catch an exception 138 * Copy from userspace and compute checksum. If we catch an exception
139 * then zero the rest of the buffer. 139 * then zero the rest of the buffer.
140 */ 140 */
141unsigned int csum_partial_copy_from_user (const unsigned char *src, 141__wsum csum_partial_copy_from_user (const void *src,
142 unsigned char *dst, 142 void *dst,
143 int len, unsigned int sum, 143 int len, __wsum sum,
144 int *err_ptr) 144 int *err_ptr)
145{ 145{
146 int missing; 146 int missing;
diff --git a/include/asm-v850/checksum.h b/include/asm-v850/checksum.h
index 4df5e71098f9..d1dddd938262 100644
--- a/include/asm-v850/checksum.h
+++ b/include/asm-v850/checksum.h
@@ -26,8 +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 */
29extern unsigned int csum_partial (const unsigned char * buff, int len, 29extern __wsum csum_partial(const void *buff, int len, __wsum sum);
30 unsigned int sum);
31 30
32/* 31/*
33 * the same as csum_partial, but copies from src while it 32 * the same as csum_partial, but copies from src while it
@@ -36,8 +35,8 @@ extern unsigned int csum_partial (const unsigned char * buff, int len,
36 * 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
37 * better 64-bit) boundary 36 * better 64-bit) boundary
38 */ 37 */
39extern unsigned csum_partial_copy (const unsigned char *src, 38extern __wsum csum_partial_copy_nocheck(const void *src,
40 unsigned char *dst, int len, unsigned sum); 39 void *dst, int len, __wsum sum);
41 40
42 41
43/* 42/*
@@ -46,20 +45,17 @@ extern unsigned csum_partial_copy (const unsigned char *src,
46 * here even more important to align src and dst on a 32-bit (or even 45 * here even more important to align src and dst on a 32-bit (or even
47 * better 64-bit) boundary 46 * better 64-bit) boundary
48 */ 47 */
49extern unsigned csum_partial_copy_from_user (const unsigned char *src, 48extern __wsum csum_partial_copy_from_user (const void *src,
50 unsigned char *dst, 49 void *dst,
51 int len, unsigned sum, 50 int len, __wsum sum,
52 int *csum_err); 51 int *csum_err);
53 52
54#define csum_partial_copy_nocheck(src, dst, len, sum) \ 53__sum16 ip_fast_csum(const void *iph, unsigned int ihl);
55 csum_partial_copy ((src), (dst), (len), (sum))
56
57unsigned short ip_fast_csum (unsigned char *iph, unsigned int ihl);
58 54
59/* 55/*
60 * Fold a partial checksum 56 * Fold a partial checksum
61 */ 57 */
62static inline unsigned int csum_fold (unsigned long sum) 58static inline __sum16 csum_fold (__wsum sum)
63{ 59{
64 unsigned int result; 60 unsigned int result;
65 /* 61 /*
@@ -68,7 +64,7 @@ static inline unsigned int csum_fold (unsigned long sum)
68 add %1, %0 H L H+L+C H+L 64 add %1, %0 H L H+L+C H+L
69 */ 65 */
70 asm ("hsw %1, %0; add %1, %0" : "=&r" (result) : "r" (sum)); 66 asm ("hsw %1, %0; add %1, %0" : "=&r" (result) : "r" (sum));
71 return (~result) >> 16; 67 return (__force __sum16)(~result >> 16);
72} 68}
73 69
74 70
@@ -76,10 +72,10 @@ static inline unsigned int csum_fold (unsigned long sum)
76 * computes the checksum of the TCP/UDP pseudo-header 72 * computes the checksum of the TCP/UDP pseudo-header
77 * returns a 16-bit checksum, already complemented 73 * returns a 16-bit checksum, already complemented
78 */ 74 */
79static inline unsigned int 75static inline __wsum
80csum_tcpudp_nofold (unsigned long saddr, unsigned long daddr, 76csum_tcpudp_nofold (__be32 saddr, __be32 daddr,
81 unsigned short len, 77 unsigned short len,
82 unsigned short proto, unsigned int sum) 78 unsigned short proto, __wsum sum)
83{ 79{
84 int __carry; 80 int __carry;
85 __asm__ ("add %2, %0;" 81 __asm__ ("add %2, %0;"
@@ -93,15 +89,15 @@ csum_tcpudp_nofold (unsigned long saddr, unsigned long daddr,
93 "add %1, %0" 89 "add %1, %0"
94 : "=&r" (sum), "=&r" (__carry) 90 : "=&r" (sum), "=&r" (__carry)
95 : "r" (daddr), "r" (saddr), 91 : "r" (daddr), "r" (saddr),
96 "r" (ntohs (len) + (proto << 8)), 92 "r" ((len + proto) << 8),
97 "0" (sum)); 93 "0" (sum));
98 return sum; 94 return sum;
99} 95}
100 96
101static inline unsigned short int 97static inline __sum16
102csum_tcpudp_magic (unsigned long saddr, unsigned long daddr, 98csum_tcpudp_magic (__be32 saddr, __be32 daddr,
103 unsigned short len, 99 unsigned short len,
104 unsigned short proto, unsigned int sum) 100 unsigned short proto, __wsum sum)
105{ 101{
106 return csum_fold (csum_tcpudp_nofold (saddr, daddr, len, proto, sum)); 102 return csum_fold (csum_tcpudp_nofold (saddr, daddr, len, proto, sum));
107} 103}
@@ -110,7 +106,7 @@ csum_tcpudp_magic (unsigned long saddr, unsigned long daddr,
110 * this routine is used for miscellaneous IP-like checksums, mainly 106 * this routine is used for miscellaneous IP-like checksums, mainly
111 * in icmp.c 107 * in icmp.c
112 */ 108 */
113extern unsigned short ip_compute_csum (const unsigned char * buff, int len); 109extern __sum16 ip_compute_csum(const void *buff, int len);
114 110
115 111
116#endif /* __V850_CHECKSUM_H__ */ 112#endif /* __V850_CHECKSUM_H__ */