sparc: Provide cmpxchg64 for 32-bit builds
PATCH v2 1/1 sparc: Provide cmpxchg64 for 32-bit builds
Fix the following build error, seen when building sparc32:allmodconfig.
drivers/net/ethernet/intel/i40e/i40e_ethtool.c:
In function 'i40e_set_priv_flags':drivers/net/ethernet/intel/i40e/i40e_ethtool.c:4150:2: error:
implicit declaration of function 'cmpxchg64'
---
v2: Actually implement cmpxchg64 with code snippet provided by Dave Miller
Note: I am aware that this doesn't pass checkpatch; I found it more important to be in line with __cmpxchg_u32().
arch/sparc/include/asm/cmpxchg_32.h | 2 ++ arch/sparc/lib/atomic32.c | 14 ++++++++++++++ 2 files changed, 16 insertions(+)
arch/sparc/include/asm/cmpxchg_32.h +2 -0
@@ -62,6 +62,8 @@ __cmpxchg(volatile void *ptr, unsigned long old, unsigned long new_, int size) (unsigned long)_n_, sizeof(*(ptr))); \ }) +extern u64 cmpxchg64 (u64 *ptr,u64 old,u64 new); +#include <asm-generic/cmpxchg-local.h> /*
arch/sparc/lib/atomic32.c +14 -0
@@ -172,6 +172,20 @@ unsigned long __cmpxchg_u32(volatile u32 *ptr, u32 old, u32 new) }EXPORT_SYMBOL (__cmpxchg_u32); +u64 cmpxchg64 (u64 *ptr,u64 old,u64 new) +{ +unsigned long flags; +u64 prev; + +spin_lock_irqsave (ATOMIC_HASH (ptr), flags); +if ((prev = *ptr) = old) + *ptr = new; +spin_unlock_irqrestore (ATOMIC_HASH (ptr), flags); + +return prev; +} +EXPORT_SYMBOL (cmpxchg64); +unsigned long __xchg_u32 (volatile u32 *ptr,u32 new) {unsigned long flags;
Signature · 1 line
2.7.4
Quoted 22 lines · Guenter Roeck
Fix the following build error, seen when building sparc32:allmodconfig.
drivers/net/ethernet/intel/i40e/i40e_ethtool.c:
In function 'i40e_set_priv_flags':drivers/net/ethernet/intel/i40e/i40e_ethtool.c:4150:2: error:
implicit declaration of function 'cmpxchg64'Signed-off-by Guenter Roeck <[email protected]>---
v2: Actually implement cmpxchg64 with code snippet provided by Dave Miller
Note: I am aware that this doesn't pass checkpatch; I found it more important to be in line with__cmpxchg_u32().arch/sparc/include/asm/cmpxchg_32.h | 2 ++ arch/sparc/lib/atomic32.c | 14 ++++++++++++++ 2 files changed, 16 insertions(+)arch/sparc/include/asm/cmpxchg_32.h +0
-0
arch/sparc/include/asm/cmpxchg_32.h __cmpxchg(volatile void *ptr, unsigned long old, unsigned long new_, int size) · line 65
Quoted 4 lines
arch/sparc/include/asm/cmpxchg_32.h +1
-0@@ -62,6 +62,8 @@ __cmpxchg(volatile void *ptr, unsigned long old, unsigned long new_, int size) (unsigned long)_n_, sizeof(*(ptr))); \ }) +extern u64 cmpxchg64 (u64 *ptr,u64 old,u64 new);
This extern is unusual style for sparc function declarations.
Quoted 29 lines
arch/sparc/include/asm/cmpxchg_32.h +1
-0+#include <asm-generic/cmpxchg-local.h> /* arch/sparc/lib/atomic32.c +14
-0@@ -172,6 +172,20 @@ unsigned long __cmpxchg_u32(volatile u32 *ptr, u32 old, u32 new) }EXPORT_SYMBOL (__cmpxchg_u32); +u64 cmpxchg64 (u64 *ptr,u64 old,u64 new) +{ +unsigned long flags; +u64 prev; + +spin_lock_irqsave (ATOMIC_HASH (ptr), flags); +if ((prev = *ptr) = old) + *ptr = new; +spin_unlock_irqrestore (ATOMIC_HASH (ptr), flags); + +return prev; +} +EXPORT_SYMBOL (cmpxchg64); +unsigned long __xchg_u32 (volatile u32 *ptr,u32 new) {unsigned long flags;