diff options
Diffstat (limited to 'arch/cris/arch-v10/lib/old_checksum.c')
-rw-r--r-- | arch/cris/arch-v10/lib/old_checksum.c | 62 |
1 files changed, 32 insertions, 30 deletions
diff --git a/arch/cris/arch-v10/lib/old_checksum.c b/arch/cris/arch-v10/lib/old_checksum.c index 22a6f0aa9ce..497634a6482 100644 --- a/arch/cris/arch-v10/lib/old_checksum.c +++ b/arch/cris/arch-v10/lib/old_checksum.c | |||
@@ -47,39 +47,41 @@ | |||
47 | 47 | ||
48 | #include <asm/delay.h> | 48 | #include <asm/delay.h> |
49 | 49 | ||
50 | unsigned int csum_partial(const unsigned char * buff, int len, unsigned int sum) | 50 | __wsum csum_partial(const void *p, int len, __wsum __sum) |
51 | { | 51 | { |
52 | /* | 52 | u32 sum = (__force u32)__sum; |
53 | * Experiments with ethernet and slip connections show that buff | 53 | const u16 *buff = p; |
54 | * is aligned on either a 2-byte or 4-byte boundary. | 54 | /* |
55 | */ | 55 | * Experiments with ethernet and slip connections show that buff |
56 | const unsigned char *endMarker = buff + len; | 56 | * is aligned on either a 2-byte or 4-byte boundary. |
57 | const unsigned char *marker = endMarker - (len % 16); | 57 | */ |
58 | const void *endMarker = p + len; | ||
59 | const void *marker = endMarker - (len % 16); | ||
58 | #if 0 | 60 | #if 0 |
59 | if((int)buff & 0x3) | 61 | if((int)buff & 0x3) |
60 | printk("unaligned buff %p\n", buff); | 62 | printk("unaligned buff %p\n", buff); |
61 | __delay(900); /* extra delay of 90 us to test performance hit */ | 63 | __delay(900); /* extra delay of 90 us to test performance hit */ |
62 | #endif | 64 | #endif |
63 | BITON; | 65 | BITON; |
64 | while (buff < marker) { | 66 | while (buff < marker) { |
65 | sum += *((unsigned short *)buff)++; | 67 | sum += *buff++; |
66 | sum += *((unsigned short *)buff)++; | 68 | sum += *buff++; |
67 | sum += *((unsigned short *)buff)++; | 69 | sum += *buff++; |
68 | sum += *((unsigned short *)buff)++; | 70 | sum += *buff++; |
69 | sum += *((unsigned short *)buff)++; | 71 | sum += *buff++; |
70 | sum += *((unsigned short *)buff)++; | 72 | sum += *buff++; |
71 | sum += *((unsigned short *)buff)++; | 73 | sum += *buff++; |
72 | sum += *((unsigned short *)buff)++; | 74 | sum += *buff++; |
73 | } | 75 | } |
74 | marker = endMarker - (len % 2); | 76 | marker = endMarker - (len % 2); |
75 | while(buff < marker) { | 77 | while (buff < marker) |
76 | sum += *((unsigned short *)buff)++; | 78 | sum += *buff++; |
77 | } | 79 | |
78 | if(endMarker - buff > 0) { | 80 | if (endMarker > buff) |
79 | sum += *buff; /* add extra byte seperately */ | 81 | sum += *(const u8 *)buff; /* add extra byte seperately */ |
80 | } | 82 | |
81 | BITOFF; | 83 | BITOFF; |
82 | return(sum); | 84 | return (__force __wsum)sum; |
83 | } | 85 | } |
84 | 86 | ||
85 | EXPORT_SYMBOL(csum_partial); | 87 | EXPORT_SYMBOL(csum_partial); |