Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 41686
b: refs/heads/master
c: 8042c44
h: refs/heads/master
v: v3
  • Loading branch information
Al Viro authored and David S. Miller committed Dec 3, 2006
1 parent c2819da commit f205913
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 35 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 3532010bcf7699f2ce9a2baab58b4b9a5426d97e
refs/heads/master: 8042c44b8a6171ed75b7dd6a224df18d993f6094
24 changes: 12 additions & 12 deletions trunk/arch/frv/lib/checksum.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,15 @@ static unsigned long do_csum(const unsigned char * buff, int len)
*
* it's best to have buff aligned on a 32-bit boundary
*/
unsigned int csum_partial(const unsigned char * buff, int len, unsigned int sum)
__wsum csum_partial(const void *buff, int len, __wsum sum)
{
unsigned int result = do_csum(buff, len);

/* add in old sum, and carry.. */
result += sum;
if (sum > result)
result += (__force u32)sum;
if ((__force u32)sum > result)
result += 1;
return result;
return (__force __wsum)result;
}

EXPORT_SYMBOL(csum_partial);
Expand All @@ -121,19 +121,19 @@ EXPORT_SYMBOL(csum_partial);
* this routine is used for miscellaneous IP-like checksums, mainly
* in icmp.c
*/
unsigned short ip_compute_csum(const unsigned char * buff, int len)
__sum16 ip_compute_csum(const void *buff, int len)
{
return ~do_csum(buff, len);
return (__force __sum16)~do_csum(buff, len);
}

EXPORT_SYMBOL(ip_compute_csum);

/*
* copy from fs while checksumming, otherwise like csum_partial
*/
unsigned int
csum_partial_copy_from_user(const char __user *src, char *dst,
int len, int sum, int *csum_err)
__wsum
csum_partial_copy_from_user(const void __user *src, void *dst,
int len, __wsum sum, int *csum_err)
{
int rem;

Expand All @@ -156,11 +156,11 @@ EXPORT_SYMBOL(csum_partial_copy_from_user);
/*
* copy from ds while checksumming, otherwise like csum_partial
*/
unsigned int
csum_partial_copy(const char *src, char *dst, int len, int sum)
__wsum
csum_partial_copy_nocheck(const void *src, void *dst, int len, __wsum sum)
{
memcpy(dst, src, len);
return csum_partial(dst, len, sum);
}

EXPORT_SYMBOL(csum_partial_copy);
EXPORT_SYMBOL(csum_partial_copy_nocheck);
41 changes: 19 additions & 22 deletions trunk/include/asm-frv/checksum.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
*
* it's best to have buff aligned on a 32-bit boundary
*/
unsigned int csum_partial(const unsigned char * buff, int len, unsigned int sum);
__wsum csum_partial(const void *buff, int len, __wsum sum);

/*
* the same as csum_partial, but copies from src while it
Expand All @@ -35,27 +35,24 @@ unsigned int csum_partial(const unsigned char * buff, int len, unsigned int sum)
* here even more important to align src and dst on a 32-bit (or even
* better 64-bit) boundary
*/
unsigned int csum_partial_copy(const char *src, char *dst, int len, int sum);
__wsum csum_partial_copy_nocheck(const void *src, void *dst, int len, __wsum sum);

/*
* the same as csum_partial_copy, but copies from user space.
*
* here even more important to align src and dst on a 32-bit (or even
* better 64-bit) boundary
*/
extern unsigned int csum_partial_copy_from_user(const char __user *src, char *dst,
int len, int sum, int *csum_err);

#define csum_partial_copy_nocheck(src, dst, len, sum) \
csum_partial_copy((src), (dst), (len), (sum))
extern __wsum csum_partial_copy_from_user(const void __user *src, void *dst,
int len, __wsum sum, int *csum_err);

/*
* This is a version of ip_compute_csum() optimized for IP headers,
* which always checksum on 4 octet boundaries.
*
*/
static inline
unsigned short ip_fast_csum(unsigned char *iph, unsigned int ihl)
__sum16 ip_fast_csum(const void *iph, unsigned int ihl)
{
unsigned int tmp, inc, sum = 0;

Expand All @@ -81,13 +78,13 @@ unsigned short ip_fast_csum(unsigned char *iph, unsigned int ihl)
: "icc0", "icc1"
);

return ~sum;
return (__force __sum16)~sum;
}

/*
* Fold a partial checksum
*/
static inline unsigned int csum_fold(unsigned int sum)
static inline __sum16 csum_fold(__wsum sum)
{
unsigned int tmp;

Expand All @@ -100,16 +97,16 @@ static inline unsigned int csum_fold(unsigned int sum)
: "0"(sum)
);

return ~sum;
return (__force __sum16)~sum;
}

/*
* computes the checksum of the TCP/UDP pseudo-header
* returns a 16-bit checksum, already complemented
*/
static inline unsigned int
csum_tcpudp_nofold(unsigned long saddr, unsigned long daddr, unsigned short len,
unsigned short proto, unsigned int sum)
static inline __wsum
csum_tcpudp_nofold(__be32 saddr, __be32 daddr, unsigned short len,
unsigned short proto, __wsum sum)
{
asm(" addcc %1,%0,%0,icc0 \n"
" addxcc %2,%0,%0,icc0 \n"
Expand All @@ -122,9 +119,9 @@ csum_tcpudp_nofold(unsigned long saddr, unsigned long daddr, unsigned short len,
return sum;
}

static inline unsigned short int
csum_tcpudp_magic(unsigned long saddr, unsigned long daddr, unsigned short len,
unsigned short proto, unsigned int sum)
static inline __sum16
csum_tcpudp_magic(__be32 saddr, __be32 daddr, unsigned short len,
unsigned short proto, __wsum sum)
{
return csum_fold(csum_tcpudp_nofold(saddr,daddr,len,proto,sum));
}
Expand All @@ -133,12 +130,12 @@ csum_tcpudp_magic(unsigned long saddr, unsigned long daddr, unsigned short len,
* this routine is used for miscellaneous IP-like checksums, mainly
* in icmp.c
*/
extern unsigned short ip_compute_csum(const unsigned char * buff, int len);
extern __sum16 ip_compute_csum(const void *buff, int len);

#define _HAVE_ARCH_IPV6_CSUM
static inline unsigned short int
csum_ipv6_magic(struct in6_addr *saddr, struct in6_addr *daddr,
__u32 len, unsigned short proto, unsigned int sum)
static inline __sum16
csum_ipv6_magic(const struct in6_addr *saddr, const struct in6_addr *daddr,
__u32 len, unsigned short proto, __wsum sum)
{
unsigned long tmp, tmp2;

Expand Down Expand Up @@ -177,7 +174,7 @@ csum_ipv6_magic(struct in6_addr *saddr, struct in6_addr *daddr,
: "icc0"
);

return ~sum;
return (__force __sum16)~sum;
}

#endif /* _ASM_CHECKSUM_H */

0 comments on commit f205913

Please sign in to comment.