[parisc-linux-cvs] linux-2.6 tausq

Randolph Chung randolph at tausq.org
Sat Oct 9 10:20:30 MDT 2004


> Modified files:
> 	arch/parisc/lib: checksum.c 
> 
> Log message:
> one more small opt + fix a corner case in csum_partial

we can save a couple of insns in the unaligned case, but we shouldn't
hit that anyway.

in csum_partial(), if the calculated csum is 0xffff, then adding the
partial sum will spill over to 32-bits. the existing logic takes care of
32-bit carry, but we really care about 16-bit carry here. we don't
usually see this case because sum is almost always 0.

Index: arch/parisc/lib/checksum.c
===================================================================
RCS file: /var/cvs/linux-2.6/arch/parisc/lib/checksum.c,v
retrieving revision 1.5
diff -u -p -r1.5 checksum.c
--- arch/parisc/lib/checksum.c	9 Oct 2004 00:35:41 -0000	1.5
+++ arch/parisc/lib/checksum.c	9 Oct 2004 16:16:36 -0000
@@ -93,7 +93,7 @@ static inline unsigned int do_csum(const
 		result += le16_to_cpu(*buff);
 	result = from32to16(result);
 	if (odd)
-		result = ((result >> 8) & 0xff) | ((result & 0xff) << 8);
+		result = swab16(result);
 out:
 	return result;
 }
@@ -105,7 +105,7 @@ unsigned int csum_partial(const unsigned
 {
 	unsigned int result = do_csum(buff, len);
 	addc(result, sum);
-	return result;
+	return from32to16(result);
 }
 
 EXPORT_SYMBOL(csum_partial);


More information about the parisc-linux-cvs mailing list