14f084ca7SThomas Gleixner #ifndef __LINUX_SPINLOCK_TYPES_RAW_H 24f084ca7SThomas Gleixner #define __LINUX_SPINLOCK_TYPES_RAW_H 34f084ca7SThomas Gleixner 44f084ca7SThomas Gleixner #include <linux/types.h> 54f084ca7SThomas Gleixner 64f084ca7SThomas Gleixner #if defined(CONFIG_SMP) 74f084ca7SThomas Gleixner # include <asm/spinlock_types.h> 84f084ca7SThomas Gleixner #else 94f084ca7SThomas Gleixner # include <linux/spinlock_types_up.h> 104f084ca7SThomas Gleixner #endif 114f084ca7SThomas Gleixner 124f084ca7SThomas Gleixner #include <linux/lockdep_types.h> 134f084ca7SThomas Gleixner 144f084ca7SThomas Gleixner typedef struct raw_spinlock { 154f084ca7SThomas Gleixner arch_spinlock_t raw_lock; 164f084ca7SThomas Gleixner #ifdef CONFIG_DEBUG_SPINLOCK 174f084ca7SThomas Gleixner unsigned int magic, owner_cpu; 184f084ca7SThomas Gleixner void *owner; 194f084ca7SThomas Gleixner #endif 204f084ca7SThomas Gleixner #ifdef CONFIG_DEBUG_LOCK_ALLOC 214f084ca7SThomas Gleixner struct lockdep_map dep_map; 224f084ca7SThomas Gleixner #endif 234f084ca7SThomas Gleixner } raw_spinlock_t; 244f084ca7SThomas Gleixner 254f084ca7SThomas Gleixner #define SPINLOCK_MAGIC 0xdead4ead 264f084ca7SThomas Gleixner 274f084ca7SThomas Gleixner #define SPINLOCK_OWNER_INIT ((void *)-1L) 284f084ca7SThomas Gleixner 294f084ca7SThomas Gleixner #ifdef CONFIG_DEBUG_LOCK_ALLOC 304f084ca7SThomas Gleixner # define RAW_SPIN_DEP_MAP_INIT(lockname) \ 314f084ca7SThomas Gleixner .dep_map = { \ 324f084ca7SThomas Gleixner .name = #lockname, \ 334f084ca7SThomas Gleixner .wait_type_inner = LD_WAIT_SPIN, \ 344f084ca7SThomas Gleixner } 354f084ca7SThomas Gleixner # define SPIN_DEP_MAP_INIT(lockname) \ 364f084ca7SThomas Gleixner .dep_map = { \ 374f084ca7SThomas Gleixner .name = #lockname, \ 384f084ca7SThomas Gleixner .wait_type_inner = LD_WAIT_CONFIG, \ 394f084ca7SThomas Gleixner } 40*31552385SThomas Gleixner 41*31552385SThomas Gleixner # define LOCAL_SPIN_DEP_MAP_INIT(lockname) \ 42*31552385SThomas Gleixner .dep_map = { \ 43*31552385SThomas Gleixner .name = #lockname, \ 44*31552385SThomas Gleixner .wait_type_inner = LD_WAIT_CONFIG, \ 45*31552385SThomas Gleixner .lock_type = LD_LOCK_PERCPU, \ 46*31552385SThomas Gleixner } 474f084ca7SThomas Gleixner #else 484f084ca7SThomas Gleixner # define RAW_SPIN_DEP_MAP_INIT(lockname) 494f084ca7SThomas Gleixner # define SPIN_DEP_MAP_INIT(lockname) 50*31552385SThomas Gleixner # define LOCAL_SPIN_DEP_MAP_INIT(lockname) 514f084ca7SThomas Gleixner #endif 524f084ca7SThomas Gleixner 534f084ca7SThomas Gleixner #ifdef CONFIG_DEBUG_SPINLOCK 544f084ca7SThomas Gleixner # define SPIN_DEBUG_INIT(lockname) \ 554f084ca7SThomas Gleixner .magic = SPINLOCK_MAGIC, \ 564f084ca7SThomas Gleixner .owner_cpu = -1, \ 574f084ca7SThomas Gleixner .owner = SPINLOCK_OWNER_INIT, 584f084ca7SThomas Gleixner #else 594f084ca7SThomas Gleixner # define SPIN_DEBUG_INIT(lockname) 604f084ca7SThomas Gleixner #endif 614f084ca7SThomas Gleixner 624f084ca7SThomas Gleixner #define __RAW_SPIN_LOCK_INITIALIZER(lockname) \ 634f084ca7SThomas Gleixner { \ 644f084ca7SThomas Gleixner .raw_lock = __ARCH_SPIN_LOCK_UNLOCKED, \ 654f084ca7SThomas Gleixner SPIN_DEBUG_INIT(lockname) \ 664f084ca7SThomas Gleixner RAW_SPIN_DEP_MAP_INIT(lockname) } 674f084ca7SThomas Gleixner 684f084ca7SThomas Gleixner #define __RAW_SPIN_LOCK_UNLOCKED(lockname) \ 694f084ca7SThomas Gleixner (raw_spinlock_t) __RAW_SPIN_LOCK_INITIALIZER(lockname) 704f084ca7SThomas Gleixner 714f084ca7SThomas Gleixner #define DEFINE_RAW_SPINLOCK(x) raw_spinlock_t x = __RAW_SPIN_LOCK_UNLOCKED(x) 724f084ca7SThomas Gleixner 734f084ca7SThomas Gleixner #endif /* __LINUX_SPINLOCK_TYPES_RAW_H */ 74