1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #ifndef __ASM_SPINLOCK_TYPES_H 3 #define __ASM_SPINLOCK_TYPES_H 4 5 typedef struct { 6 volatile unsigned int lock[4]; 7 # define __ARCH_SPIN_LOCK_UNLOCKED { { 1, 1, 1, 1 } } 8 } arch_spinlock_t; 9 10 11 /* counter: 12 * Unlocked : 0x0100_0000 13 * Read lock(s) : 0x00FF_FFFF to 0x01 (Multiple Readers decrement it) 14 * Write lock : 0x0, but only if prior value is "unlocked" 0x0100_0000 15 */ 16 typedef struct { 17 arch_spinlock_t lock_mutex; 18 volatile unsigned int counter; 19 } arch_rwlock_t; 20 21 #define __ARCH_RW_LOCK_UNLOCKED__ 0x01000000 22 #define __ARCH_RW_LOCK_UNLOCKED { .lock_mutex = __ARCH_SPIN_LOCK_UNLOCKED, \ 23 .counter = __ARCH_RW_LOCK_UNLOCKED__ } 24 25 #endif 26