diff options
-rw-r--r-- | arch/blackfin/lib/checksum.c | 21 | ||||
-rw-r--r-- | include/asm-blackfin/checksum.h | 29 |
2 files changed, 24 insertions, 26 deletions
diff --git a/arch/blackfin/lib/checksum.c b/arch/blackfin/lib/checksum.c index 42768e0c80ca..5c87505165d3 100644 --- a/arch/blackfin/lib/checksum.c +++ b/arch/blackfin/lib/checksum.c | |||
@@ -72,9 +72,9 @@ static unsigned short do_csum(const unsigned char *buff, int len) | |||
72 | * This is a version of ip_compute_csum() optimized for IP headers, | 72 | * This is a version of ip_compute_csum() optimized for IP headers, |
73 | * which always checksum on 4 octet boundaries. | 73 | * which always checksum on 4 octet boundaries. |
74 | */ | 74 | */ |
75 | unsigned short ip_fast_csum(unsigned char *iph, unsigned int ihl) | 75 | __sum16 ip_fast_csum(unsigned char *iph, unsigned int ihl) |
76 | { | 76 | { |
77 | return ~do_csum(iph, ihl * 4); | 77 | return (__force __sum16)~do_csum(iph, ihl * 4); |
78 | } | 78 | } |
79 | 79 | ||
80 | /* | 80 | /* |
@@ -89,7 +89,7 @@ unsigned short ip_fast_csum(unsigned char *iph, unsigned int ihl) | |||
89 | * | 89 | * |
90 | * it's best to have buff aligned on a 32-bit boundary | 90 | * it's best to have buff aligned on a 32-bit boundary |
91 | */ | 91 | */ |
92 | unsigned int csum_partial(const unsigned char *buff, int len, unsigned int sum) | 92 | __wsum csum_partial(const void *buff, int len, __wsum sum) |
93 | { | 93 | { |
94 | /* | 94 | /* |
95 | * Just in case we get nasty checksum data... | 95 | * Just in case we get nasty checksum data... |
@@ -109,22 +109,22 @@ unsigned int csum_partial(const unsigned char *buff, int len, unsigned int sum) | |||
109 | * this routine is used for miscellaneous IP-like checksums, mainly | 109 | * this routine is used for miscellaneous IP-like checksums, mainly |
110 | * in icmp.c | 110 | * in icmp.c |
111 | */ | 111 | */ |
112 | unsigned short ip_compute_csum(const unsigned char *buff, int len) | 112 | __sum16 ip_compute_csum(const void *buff, int len) |
113 | { | 113 | { |
114 | return ~do_csum(buff, len); | 114 | return (__force __sum16)~do_csum(buff, len); |
115 | } | 115 | } |
116 | 116 | ||
117 | /* | 117 | /* |
118 | * copy from fs while checksumming, otherwise like csum_partial | 118 | * copy from fs while checksumming, otherwise like csum_partial |
119 | */ | 119 | */ |
120 | 120 | ||
121 | unsigned int | 121 | __wsum |
122 | csum_partial_copy_from_user(const unsigned char *src, unsigned char *dst, | 122 | csum_partial_copy_from_user(const void __user *src, void *dst, |
123 | int len, int sum, int *csum_err) | 123 | int len, __wsum sum, int *csum_err) |
124 | { | 124 | { |
125 | if (csum_err) | 125 | if (csum_err) |
126 | *csum_err = 0; | 126 | *csum_err = 0; |
127 | memcpy(dst, src, len); | 127 | memcpy(dst, (__force void *)src, len); |
128 | return csum_partial(dst, len, sum); | 128 | return csum_partial(dst, len, sum); |
129 | } | 129 | } |
130 | 130 | ||
@@ -132,8 +132,7 @@ csum_partial_copy_from_user(const unsigned char *src, unsigned char *dst, | |||
132 | * copy from ds while checksumming, otherwise like csum_partial | 132 | * copy from ds while checksumming, otherwise like csum_partial |
133 | */ | 133 | */ |
134 | 134 | ||
135 | unsigned int csum_partial_copy(const unsigned char *src, unsigned char *dst, | 135 | __wsum csum_partial_copy(const void *src, void *dst, int len, __wsum sum) |
136 | int len, int sum) | ||
137 | { | 136 | { |
138 | memcpy(dst, src, len); | 137 | memcpy(dst, src, len); |
139 | return csum_partial(dst, len, sum); | 138 | return csum_partial(dst, len, sum); |
diff --git a/include/asm-blackfin/checksum.h b/include/asm-blackfin/checksum.h index 2638f2586d2f..6f6af2b8e9e0 100644 --- a/include/asm-blackfin/checksum.h +++ b/include/asm-blackfin/checksum.h | |||
@@ -15,7 +15,7 @@ | |||
15 | * | 15 | * |
16 | * it's best to have buff aligned on a 32-bit boundary | 16 | * it's best to have buff aligned on a 32-bit boundary |
17 | */ | 17 | */ |
18 | unsigned int csum_partial(const unsigned char *buff, int len, unsigned int sum); | 18 | __wsum csum_partial(const void *buff, int len, __wsum sum); |
19 | 19 | ||
20 | /* | 20 | /* |
21 | * the same as csum_partial, but copies from src while it | 21 | * the same as csum_partial, but copies from src while it |
@@ -25,8 +25,8 @@ unsigned int csum_partial(const unsigned char *buff, int len, unsigned int sum); | |||
25 | * better 64-bit) boundary | 25 | * better 64-bit) boundary |
26 | */ | 26 | */ |
27 | 27 | ||
28 | unsigned int csum_partial_copy(const unsigned char *src, unsigned char *dst, | 28 | __wsum csum_partial_copy(const void *src, void *dst, |
29 | int len, int sum); | 29 | int len, __wsum sum); |
30 | 30 | ||
31 | /* | 31 | /* |
32 | * the same as csum_partial_copy, but copies from user space. | 32 | * the same as csum_partial_copy, but copies from user space. |
@@ -35,20 +35,19 @@ unsigned int csum_partial_copy(const unsigned char *src, unsigned char *dst, | |||
35 | * better 64-bit) boundary | 35 | * better 64-bit) boundary |
36 | */ | 36 | */ |
37 | 37 | ||
38 | extern unsigned int csum_partial_copy_from_user(const unsigned char *src, | 38 | extern __wsum csum_partial_copy_from_user(const void __user *src, void *dst, |
39 | unsigned char *dst, int len, | 39 | int len, __wsum sum, int *csum_err); |
40 | int sum, int *csum_err); | ||
41 | 40 | ||
42 | #define csum_partial_copy_nocheck(src, dst, len, sum) \ | 41 | #define csum_partial_copy_nocheck(src, dst, len, sum) \ |
43 | csum_partial_copy((src), (dst), (len), (sum)) | 42 | csum_partial_copy((src), (dst), (len), (sum)) |
44 | 43 | ||
45 | unsigned short ip_fast_csum(unsigned char *iph, unsigned int ihl); | 44 | __sum16 ip_fast_csum(unsigned char *iph, unsigned int ihl); |
46 | 45 | ||
47 | /* | 46 | /* |
48 | * Fold a partial checksum | 47 | * Fold a partial checksum |
49 | */ | 48 | */ |
50 | 49 | ||
51 | static inline unsigned int csum_fold(unsigned int sum) | 50 | static inline __sum16 csum_fold(__wsum sum) |
52 | { | 51 | { |
53 | while (sum >> 16) | 52 | while (sum >> 16) |
54 | sum = (sum & 0xffff) + (sum >> 16); | 53 | sum = (sum & 0xffff) + (sum >> 16); |
@@ -60,9 +59,9 @@ static inline unsigned int csum_fold(unsigned int sum) | |||
60 | * returns a 16-bit checksum, already complemented | 59 | * returns a 16-bit checksum, already complemented |
61 | */ | 60 | */ |
62 | 61 | ||
63 | static inline unsigned int | 62 | static inline __wsum |
64 | csum_tcpudp_nofold(unsigned long saddr, unsigned long daddr, unsigned short len, | 63 | csum_tcpudp_nofold(__be32 saddr, __be32 daddr, unsigned short len, |
65 | unsigned short proto, unsigned int sum) | 64 | unsigned short proto, __wsum sum) |
66 | { | 65 | { |
67 | 66 | ||
68 | __asm__ ("%0 = %0 + %1;\n\t" | 67 | __asm__ ("%0 = %0 + %1;\n\t" |
@@ -84,9 +83,9 @@ csum_tcpudp_nofold(unsigned long saddr, unsigned long daddr, unsigned short len, | |||
84 | return (sum); | 83 | return (sum); |
85 | } | 84 | } |
86 | 85 | ||
87 | static inline unsigned short int | 86 | static inline __sum16 |
88 | csum_tcpudp_magic(unsigned long saddr, unsigned long daddr, unsigned short len, | 87 | csum_tcpudp_magic(__be32 saddr, __be32 daddr, unsigned short len, |
89 | unsigned short proto, unsigned int sum) | 88 | unsigned short proto, __wsum sum) |
90 | { | 89 | { |
91 | return csum_fold(csum_tcpudp_nofold(saddr, daddr, len, proto, sum)); | 90 | return csum_fold(csum_tcpudp_nofold(saddr, daddr, len, proto, sum)); |
92 | } | 91 | } |
@@ -96,6 +95,6 @@ csum_tcpudp_magic(unsigned long saddr, unsigned long daddr, unsigned short len, | |||
96 | * in icmp.c | 95 | * in icmp.c |
97 | */ | 96 | */ |
98 | 97 | ||
99 | extern unsigned short ip_compute_csum(const unsigned char *buff, int len); | 98 | extern __sum16 ip_compute_csum(const void *buff, int len); |
100 | 99 | ||
101 | #endif /* _BFIN_CHECKSUM_H */ | 100 | #endif /* _BFIN_CHECKSUM_H */ |