fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / arch / cris / arch-v10 / lib / old_checksum.c
index 22a6f0a..497634a 100644 (file)
 
 #include <asm/delay.h>
 
-unsigned int csum_partial(const unsigned char * buff, int len, unsigned int sum)
+__wsum csum_partial(const void *p, int len, __wsum __sum)
 {
-  /*
-   * Experiments with ethernet and slip connections show that buff
-   * is aligned on either a 2-byte or 4-byte boundary.
-   */
-  const unsigned char *endMarker = buff + len;
-  const unsigned char *marker = endMarker - (len % 16);
+       u32 sum = (__force u32)__sum;
+       const u16 *buff = p;
+       /*
+       * Experiments with ethernet and slip connections show that buff
+       * is aligned on either a 2-byte or 4-byte boundary.
+       */
+       const void *endMarker = p + len;
+       const void *marker = endMarker - (len % 16);
 #if 0
-  if((int)buff & 0x3)
-    printk("unaligned buff %p\n", buff);
-  __delay(900); /* extra delay of 90 us to test performance hit */
+       if((int)buff & 0x3)
+               printk("unaligned buff %p\n", buff);
+       __delay(900); /* extra delay of 90 us to test performance hit */
 #endif
-  BITON;
-  while (buff < marker) {
-    sum += *((unsigned short *)buff)++;
-    sum += *((unsigned short *)buff)++;
-    sum += *((unsigned short *)buff)++;
-    sum += *((unsigned short *)buff)++;
-    sum += *((unsigned short *)buff)++;
-    sum += *((unsigned short *)buff)++;
-    sum += *((unsigned short *)buff)++;
-    sum += *((unsigned short *)buff)++;
-  }
-  marker = endMarker - (len % 2);
-  while(buff < marker) {
-    sum += *((unsigned short *)buff)++;
-  }
-  if(endMarker - buff > 0) {
-    sum += *buff;                 /* add extra byte seperately */
-  }
-  BITOFF;
-  return(sum);
+       BITON;
+       while (buff < marker) {
+               sum += *buff++;
+               sum += *buff++;
+               sum += *buff++;
+               sum += *buff++;
+               sum += *buff++;
+               sum += *buff++;
+               sum += *buff++;
+               sum += *buff++;
+       }
+       marker = endMarker - (len % 2);
+       while (buff < marker)
+               sum += *buff++;
+
+       if (endMarker > buff)
+               sum += *(const u8 *)buff;       /* add extra byte seperately */
+
+       BITOFF;
+       return (__force __wsum)sum;
 }
 
 EXPORT_SYMBOL(csum_partial);