summary refs log tree commit diff
path: root/drivers/staging
diff options
context:
space:
mode:
authorAlan Cox <alan@linux.intel.com>2009-10-12 15:38:17 +0100
committerGreg Kroah-Hartman <gregkh@suse.de>2009-10-14 14:14:38 -0700
commitb9d2dde0556cde38105033cb39841658d81921d2 (patch)
tree98f07129cd2329adbbaba6839e32e4a7d7619a8d /drivers/staging
parent4439c9353589f4def506b94f8f6344433333a4b9 (diff)
downloadlinux-b9d2dde0556cde38105033cb39841658d81921d2.tar.gz
Staging: et131x: Correct WRAP bit handling
add_10bit loses the existing wrap value

Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

Diffstat (limited to 'drivers/staging')
-rw-r--r--drivers/staging/et131x/et1310_rx.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/drivers/staging/et131x/et1310_rx.c b/drivers/staging/et131x/et1310_rx.c
index 8f2e91fa0a86..10e21db57ac3 100644
--- a/drivers/staging/et131x/et1310_rx.c
+++ b/drivers/staging/et131x/et1310_rx.c
@@ -1177,12 +1177,20 @@ void et131x_handle_recv_interrupt(struct et131x_adapter *etdev)
 
 static inline u32 bump_fbr(u32 *fbr, u32 limit)
 {
-	u32 v = *fbr;
-	add_10bit(&v, 1);
-	if (v > limit)
-		v = (*fbr & ~ET_DMA10_MASK) ^ ET_DMA10_WRAP;
-	*fbr = v;
-	return v;
+        u32 v = *fbr;
+        v++;
+        /* This works for all cases where limit < 1024. The 1023 case
+           works because 1023++ is 1024 which means the if condition is not
+           taken but the carry of the bit into the wrap bit toggles the wrap
+           value correctly */
+        if ((v & ET_DMA10_MASK) > limit) {
+                v &= ~ET_DMA10_MASK;
+                v ^= ET_DMA10_WRAP;
+        }
+        /* For the 1023 case */
+        v &= (ET_DMA10_MASK|ET_DMA10_WRAP);
+        *fbr = v;
+        return v;
 }
 
 /**