1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Port on Texas Instruments TMS320C6x architecture
5 * Copyright (C) 2004, 2009, 2010, 2011 Texas Instruments Incorporated
6 * Author: Aurelien Jacquiot (aurelien.jacquiot@jaluna.com)
8 #ifndef _ASM_C6X_CMPXCHG_H
9 #define _ASM_C6X_CMPXCHG_H
11 #include <linux/irqflags.h>
16 static inline unsigned int __xchg(unsigned int x
, volatile void *ptr
, int size
)
21 local_irq_save(flags
);
26 tmp
= *((unsigned char *) ptr
);
27 *((unsigned char *) ptr
) = (unsigned char) x
;
31 tmp
= *((unsigned short *) ptr
);
32 *((unsigned short *) ptr
) = x
;
36 tmp
= *((unsigned int *) ptr
);
37 *((unsigned int *) ptr
) = x
;
40 local_irq_restore(flags
);
44 #define xchg(ptr, x) \
45 ((__typeof__(*(ptr)))__xchg((unsigned int)(x), (void *) (ptr), \
48 #include <asm-generic/cmpxchg-local.h>
51 * cmpxchg_local and cmpxchg64_local are atomic wrt current CPU. Always make
54 #define cmpxchg_local(ptr, o, n) \
55 ((__typeof__(*(ptr)))__cmpxchg_local_generic((ptr), \
59 #define cmpxchg64_local(ptr, o, n) __cmpxchg64_local_generic((ptr), (o), (n))
61 #include <asm-generic/cmpxchg.h>
63 #endif /* _ASM_C6X_CMPXCHG_H */