1 #ifndef __ASM_SPINLOCK_H 2 #define __ASM_SPINLOCK_H 4 /* Simple spin lock operations. There are two variants, one clears IRQ's 5 * on the local processor, one does not. 7 * We make no fairness assumptions. They have a cost. 11 volatileunsigned long lock
; 12 volatileunsigned long owner_pc
; 13 volatileunsigned long owner_cpu
; 16 #define SPIN_LOCK_UNLOCKED (spinlock_t) { 0, 0, 0 } 17 #define spin_lock_init(lp) do { (lp)->lock = 0; } while(0) 18 #define spin_unlock_wait(lp) do { barrier(); } while((lp)->lock) 20 externvoid_spin_lock(spinlock_t
*lock
); 21 externvoid_spin_unlock(spinlock_t
*lock
); 22 externintspin_trylock(spinlock_t
*lock
); 24 #define spin_lock(lp) _spin_lock(lp) 25 #define spin_unlock(lp) _spin_unlock(lp) 27 #define spin_lock_irq(lock) \ 28 do { __cli(); spin_lock(lock); } while (0) 29 #define spin_lock_bh(___lk) do { local_bh_disable(); spin_lock(___lk); } while(0) 31 #define spin_unlock_irq(lock) \ 32 do { spin_unlock(lock); __sti(); } while (0) 33 #define spin_unlock_bh(___lk) do { spin_unlock(___lk); local_bh_enable(); } while(0) 35 #define spin_lock_irqsave(lock, flags) \ 36 do { __save_flags(flags); __cli(); spin_lock(lock); } while (0) 37 #define spin_unlock_irqrestore(lock, flags) \ 38 do { spin_unlock(lock); __restore_flags(flags); } while (0) 40 externunsigned long__spin_trylock(volatileunsigned long*lock
); 43 * Read-write spinlocks, allowing multiple readers 44 * but only one writer. 46 * NOTE! it is quite common to have readers in interrupts 47 * but no interrupt writers. For those circumstances we 48 * can "mix" irq-safe locks - any writer needs to get a 49 * irq-safe write-lock, but readers can get non-irqsafe 53 volatileunsigned long lock
; 54 volatileunsigned long owner_pc
; 57 #define RW_LOCK_UNLOCKED (rwlock_t) { 0, 0 } 59 externvoid_read_lock(rwlock_t
*rw
); 60 externvoid_read_unlock(rwlock_t
*rw
); 61 externvoid_write_lock(rwlock_t
*rw
); 62 externvoid_write_unlock(rwlock_t
*rw
); 64 #define read_lock(rw) _read_lock(rw) 65 #define write_lock(rw) _write_lock(rw) 66 #define write_unlock(rw) _write_unlock(rw) 67 #define read_unlock(rw) _read_unlock(rw) 69 #endif/* __ASM_SPINLOCK_H */