mirror of
https://github.com/torvalds/linux.git
synced 2024-11-01 13:03:25 +01:00
m68k: cmpxchg: Use swap() to improve code
Remove the local variable tmp and use the swap() macro instead. Signed-off-by: Thorsten Blum <thorsten.blum@toblux.com> Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org> Link: https://lore.kernel.org/20240730234506.492743-2-thorsten.blum@toblux.com Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
This commit is contained in:
parent
8400291e28
commit
61eb040228
1 changed files with 5 additions and 10 deletions
|
@ -3,6 +3,7 @@
|
|||
#define __ARCH_M68K_CMPXCHG__
|
||||
|
||||
#include <linux/irqflags.h>
|
||||
#include <linux/minmax.h>
|
||||
|
||||
#define __xg(type, x) ((volatile type *)(x))
|
||||
|
||||
|
@ -11,25 +12,19 @@ extern unsigned long __invalid_xchg_size(unsigned long, volatile void *, int);
|
|||
#ifndef CONFIG_RMW_INSNS
|
||||
static inline unsigned long __arch_xchg(unsigned long x, volatile void * ptr, int size)
|
||||
{
|
||||
unsigned long flags, tmp;
|
||||
unsigned long flags;
|
||||
|
||||
local_irq_save(flags);
|
||||
|
||||
switch (size) {
|
||||
case 1:
|
||||
tmp = *(u8 *)ptr;
|
||||
*(u8 *)ptr = x;
|
||||
x = tmp;
|
||||
swap(*(u8 *)ptr, x);
|
||||
break;
|
||||
case 2:
|
||||
tmp = *(u16 *)ptr;
|
||||
*(u16 *)ptr = x;
|
||||
x = tmp;
|
||||
swap(*(u16 *)ptr, x);
|
||||
break;
|
||||
case 4:
|
||||
tmp = *(u32 *)ptr;
|
||||
*(u32 *)ptr = x;
|
||||
x = tmp;
|
||||
swap(*(u32 *)ptr, x);
|
||||
break;
|
||||
default:
|
||||
x = __invalid_xchg_size(x, ptr, size);
|
||||
|
|
Loading…
Reference in a new issue