Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[NET]: S390 checksum annotations and cleanups.

* sanitize prototypes, annotate
* kill useless shifts

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Al Viro and committed by
David S. Miller
f994aae1 879178cf

+21 -24
+21 -24
include/asm-s390/checksum.h
··· 27 27 * 28 28 * it's best to have buff aligned on a 32-bit boundary 29 29 */ 30 - static inline unsigned int 31 - csum_partial(const unsigned char * buff, int len, unsigned int sum) 30 + static inline __wsum 31 + csum_partial(const void *buff, int len, __wsum sum) 32 32 { 33 33 register unsigned long reg2 asm("2") = (unsigned long) buff; 34 34 register unsigned long reg3 asm("3") = (unsigned long) len; ··· 49 49 * Copy from userspace and compute checksum. If we catch an exception 50 50 * then zero the rest of the buffer. 51 51 */ 52 - static inline unsigned int 53 - csum_partial_copy_from_user(const char __user *src, char *dst, 54 - int len, unsigned int sum, 52 + static inline __wsum 53 + csum_partial_copy_from_user(const void __user *src, void *dst, 54 + int len, __wsum sum, 55 55 int *err_ptr) 56 56 { 57 57 int missing; ··· 66 66 } 67 67 68 68 69 - static inline unsigned int 70 - csum_partial_copy_nocheck (const char *src, char *dst, int len, unsigned int sum) 69 + static inline __wsum 70 + csum_partial_copy_nocheck (const void *src, void *dst, int len, __wsum sum) 71 71 { 72 72 memcpy(dst,src,len); 73 73 return csum_partial(dst, len, sum); ··· 76 76 /* 77 77 * Fold a partial checksum without adding pseudo headers 78 78 */ 79 - static inline unsigned short 80 - csum_fold(unsigned int sum) 79 + static inline __sum16 csum_fold(__wsum sum) 81 80 { 82 81 #ifndef __s390x__ 83 82 register_pair rp; ··· 99 100 " srl %0,16\n" /* %0 = H+L+C */ 100 101 : "+&d" (sum) : : "cc", "2", "3"); 101 102 #endif /* __s390x__ */ 102 - return ((unsigned short) ~sum); 103 + return (__force __sum16) ~sum; 103 104 } 104 105 105 106 /* ··· 107 108 * which always checksum on 4 octet boundaries. 108 109 * 109 110 */ 110 - static inline unsigned short 111 - ip_fast_csum(unsigned char *iph, unsigned int ihl) 111 + static inline __sum16 ip_fast_csum(const void *iph, unsigned int ihl) 112 112 { 113 113 return csum_fold(csum_partial(iph, ihl*4, 0)); 114 114 } ··· 116 118 * computes the checksum of the TCP/UDP pseudo-header 117 119 * returns a 32-bit checksum 118 120 */ 119 - static inline unsigned int 120 - csum_tcpudp_nofold(unsigned long saddr, unsigned long daddr, 121 + static inline __wsum 122 + csum_tcpudp_nofold(__be32 saddr, __be32 daddr, 121 123 unsigned short len, unsigned short proto, 122 - unsigned int sum) 124 + __wsum sum) 123 125 { 124 126 #ifndef __s390x__ 125 127 asm volatile( ··· 135 137 "1:" 136 138 : "+&d" (sum) : "d" (daddr) : "cc"); 137 139 asm volatile( 138 - " alr %0,%1\n" /* sum += (len<<16) + (proto<<8) */ 140 + " alr %0,%1\n" /* sum += len + proto */ 139 141 " brc 12,2f\n" 140 142 " ahi %0,1\n" /* add carry */ 141 143 "2:" 142 144 : "+&d" (sum) 143 - : "d" (((unsigned int) len<<16) + (unsigned int) proto) 145 + : "d" (len + proto) 144 146 : "cc"); 145 147 #else /* __s390x__ */ 146 148 asm volatile( ··· 151 153 "0: algr %0,%2\n" /* sum += daddr */ 152 154 " brc 12,1f\n" 153 155 " aghi %0,1\n" /* add carry */ 154 - "1: algfr %0,%3\n" /* sum += (len<<16) + proto */ 156 + "1: algfr %0,%3\n" /* sum += len + proto */ 155 157 " brc 12,2f\n" 156 158 " aghi %0,1\n" /* add carry */ 157 159 "2: srlg 0,%0,32\n" ··· 161 163 "3: llgfr %0,%0" 162 164 : "+&d" (sum) 163 165 : "d" (saddr), "d" (daddr), 164 - "d" (((unsigned int) len<<16) + (unsigned int) proto) 166 + "d" (len + proto) 165 167 : "cc", "0"); 166 168 #endif /* __s390x__ */ 167 169 return sum; ··· 172 174 * returns a 16-bit checksum, already complemented 173 175 */ 174 176 175 - static inline unsigned short int 176 - csum_tcpudp_magic(unsigned long saddr, unsigned long daddr, 177 + static inline __sum16 178 + csum_tcpudp_magic(__be32 saddr, __be32 daddr, 177 179 unsigned short len, unsigned short proto, 178 - unsigned int sum) 180 + __wsum sum) 179 181 { 180 182 return csum_fold(csum_tcpudp_nofold(saddr,daddr,len,proto,sum)); 181 183 } ··· 185 187 * in icmp.c 186 188 */ 187 189 188 - static inline unsigned short 189 - ip_compute_csum(unsigned char * buff, int len) 190 + static inline __sum16 ip_compute_csum(const void *buff, int len) 190 191 { 191 192 return csum_fold(csum_partial(buff, len, 0)); 192 193 }