1 #ifndef __ASM_SPINLOCK_H
2 #define __ASM_SPINLOCK_H
5 * Simple spin lock operations.
9 volatile unsigned long lock
;
10 volatile unsigned long owner_pc
;
11 volatile unsigned long owner_cpu
;
14 #define SPIN_LOCK_UNLOCKED (spinlock_t) { 0, 0, 0 }
15 #define spin_lock_init(lp) do { (lp)->lock = 0; } while(0)
16 #define spin_unlock_wait(lp) do { barrier(); } while((lp)->lock)
18 extern void _spin_lock(spinlock_t
*lock
);
19 extern void _spin_unlock(spinlock_t
*lock
);
20 extern int spin_trylock(spinlock_t
*lock
);
22 #define spin_lock(lp) _spin_lock(lp)
23 #define spin_unlock(lp) _spin_unlock(lp)
25 extern unsigned long __spin_trylock(volatile unsigned long *lock
);
28 * Read-write spinlocks, allowing multiple readers
29 * but only one writer.
31 * NOTE! it is quite common to have readers in interrupts
32 * but no interrupt writers. For those circumstances we
33 * can "mix" irq-safe locks - any writer needs to get a
34 * irq-safe write-lock, but readers can get non-irqsafe
38 volatile unsigned long lock
;
39 volatile unsigned long owner_pc
;
42 #define RW_LOCK_UNLOCKED (rwlock_t) { 0, 0 }
44 extern void _read_lock(rwlock_t
*rw
);
45 extern void _read_unlock(rwlock_t
*rw
);
46 extern void _write_lock(rwlock_t
*rw
);
47 extern void _write_unlock(rwlock_t
*rw
);
49 #define read_lock(rw) _read_lock(rw)
50 #define write_lock(rw) _write_lock(rw)
51 #define write_unlock(rw) _write_unlock(rw)
52 #define read_unlock(rw) _read_unlock(rw)
54 #endif /* __ASM_SPINLOCK_H */