M7350/kernel/arch/sh/include/asm/atomic-irq.h

64 lines
1.4 KiB
C
Raw Permalink Normal View History

2024-09-09 08:52:07 +00:00
#ifndef __ASM_SH_ATOMIC_IRQ_H
#define __ASM_SH_ATOMIC_IRQ_H
#include <linux/irqflags.h>
/*
* To get proper branch prediction for the main line, we must branch
* forward to code at the end of this object's .text section, then
* branch back to restart the operation.
*/
2024-09-09 08:57:42 +00:00
#define ATOMIC_OP(op, c_op) \
static inline void atomic_##op(int i, atomic_t *v) \
{ \
unsigned long flags; \
\
raw_local_irq_save(flags); \
v->counter c_op i; \
raw_local_irq_restore(flags); \
2024-09-09 08:52:07 +00:00
}
2024-09-09 08:57:42 +00:00
#define ATOMIC_OP_RETURN(op, c_op) \
static inline int atomic_##op##_return(int i, atomic_t *v) \
{ \
unsigned long temp, flags; \
\
raw_local_irq_save(flags); \
temp = v->counter; \
temp c_op i; \
v->counter = temp; \
raw_local_irq_restore(flags); \
\
return temp; \
2024-09-09 08:52:07 +00:00
}
2024-09-09 08:57:42 +00:00
#define ATOMIC_OPS(op, c_op) ATOMIC_OP(op, c_op) ATOMIC_OP_RETURN(op, c_op)
2024-09-09 08:52:07 +00:00
2024-09-09 08:57:42 +00:00
ATOMIC_OPS(add, +=)
ATOMIC_OPS(sub, -=)
2024-09-09 08:52:07 +00:00
2024-09-09 08:57:42 +00:00
#undef ATOMIC_OPS
#undef ATOMIC_OP_RETURN
#undef ATOMIC_OP
2024-09-09 08:52:07 +00:00
static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
{
unsigned long flags;
raw_local_irq_save(flags);
v->counter &= ~mask;
raw_local_irq_restore(flags);
}
static inline void atomic_set_mask(unsigned int mask, atomic_t *v)
{
unsigned long flags;
raw_local_irq_save(flags);
v->counter |= mask;
raw_local_irq_restore(flags);
}
#endif /* __ASM_SH_ATOMIC_IRQ_H */