Subject: [PATCH] fix atomic_sub_if_positive() and atomic64_sub_if_positive()

From: Yoichi Yuasa <[email-masked]>
Date: Thu, 3 Jun 2004 23:13:31 +0900

Hi Ralf,

I found the mistake about return value of atomic_sub_if_positive()  and atomic64_sub_if_positive().

Please apply this patch to v2.6 CVS tree.

Yoichi

diff -urN -X dontdiff linux-orig/include/asm-mips/atomic.h linux/include/asm-mips/atomic.h
--- linux-orig/include/asm-mips/atomic.h	Fri May 28 23:44:14 2004
+++ linux/include/asm-mips/atomic.h	Sun May 30 12:06:20 2004
@@ -228,7 +228,7 @@
 static __inline__ int atomic_sub_if_positive(int i, atomic_t * v)
 {
 	unsigned long flags;
-	int temp, result;
+	int temp;
 
 	spin_lock_irqsave(&atomic_lock, flags);
 	temp = v->counter;
@@ -237,7 +237,7 @@
 		v->counter = temp;
 	spin_unlock_irqrestore(&atomic_lock, flags);
 
-	return result;
+	return temp;
 }
 
 #endif /* CONFIG_CPU_HAS_LLSC */
@@ -511,7 +511,7 @@
 static __inline__ long atomic64_sub_if_positive(long i, atomic64_t * v)
 {
 	unsigned long flags;
-	long temp, result;
+	long temp;
 
 	spin_lock_irqsave(&atomic_lock, flags);
 	temp = v->counter;
@@ -520,7 +520,7 @@
 		v->counter = temp;
 	spin_unlock_irqrestore(&atomic_lock, flags);
 
-	return result;
+	return temp;
 }
 
 #endif /* CONFIG_CPU_HAS_LLDSCD */

---

From: Ralf Baechle <[email-masked]>
Date: Thu, 3 Jun 2004 16:21:58 +0200

> and atomic64_sub_if_positive().

Applied,

  Ralf