From: wangrui <wangrui@xxxxxxxxxxx> Signed-by-off: Rui Wang <wangrui@xxxxxxxxxxx> Signed-by-off: hev <r@xxxxxx> --- arch/mips/kernel/cmpxchg.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/arch/mips/kernel/cmpxchg.c b/arch/mips/kernel/cmpxchg.c index ac9c8cfb2ba9..34ef35194cbe 100644 --- a/arch/mips/kernel/cmpxchg.c +++ b/arch/mips/kernel/cmpxchg.c @@ -9,7 +9,7 @@ unsigned long __xchg_small(volatile void *ptr, unsigned long val, unsigned int size) { - u32 old32, new32, load32, mask; + u32 old32, mask; volatile u32 *ptr32; unsigned int shift; @@ -36,15 +36,9 @@ unsigned long __xchg_small(volatile void *ptr, unsigned long val, unsigned int s * includes our byte of interest, and load its value. */ ptr32 = (volatile u32 *)((unsigned long)ptr & ~0x3); - load32 = *ptr32; - - do { - old32 = load32; - new32 = (load32 & ~mask) | (val << shift); - load32 = arch_cmpxchg(ptr32, old32, new32); - } while (load32 != old32); + old32 = atomic_fetch_and_or(ptr32, ~mask, val << shift); - return (load32 & mask) >> shift; + return (old32 & mask) >> shift; } unsigned long __cmpxchg_small(volatile void *ptr, unsigned long old, -- 2.32.0