Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Waiman Long | 70af2f8 | 2014-02-03 13:18:49 +0100 | [diff] [blame] | 2 | #ifndef __ASM_GENERIC_QRWLOCK_TYPES_H |
| 3 | #define __ASM_GENERIC_QRWLOCK_TYPES_H |
| 4 | |
| 5 | #include <linux/types.h> |
Arnd Bergmann | ca66e79 | 2018-02-02 16:40:44 +0100 | [diff] [blame] | 6 | #include <asm/byteorder.h> |
Waiman Long | 70af2f8 | 2014-02-03 13:18:49 +0100 | [diff] [blame] | 7 | #include <asm/spinlock_types.h> |
| 8 | |
| 9 | /* |
| 10 | * The queue read/write lock data structure |
| 11 | */ |
| 12 | |
| 13 | typedef struct qrwlock { |
Will Deacon | e0d0228 | 2017-10-12 13:20:47 +0100 | [diff] [blame] | 14 | union { |
| 15 | atomic_t cnts; |
| 16 | struct { |
| 17 | #ifdef __LITTLE_ENDIAN |
Will Deacon | d133166 | 2017-10-12 13:20:51 +0100 | [diff] [blame] | 18 | u8 wlocked; /* Locked for write? */ |
| 19 | u8 __lstate[3]; |
Will Deacon | e0d0228 | 2017-10-12 13:20:47 +0100 | [diff] [blame] | 20 | #else |
Will Deacon | d133166 | 2017-10-12 13:20:51 +0100 | [diff] [blame] | 21 | u8 __lstate[3]; |
| 22 | u8 wlocked; /* Locked for write? */ |
Will Deacon | e0d0228 | 2017-10-12 13:20:47 +0100 | [diff] [blame] | 23 | #endif |
| 24 | }; |
| 25 | }; |
Davidlohr Bueso | 6e1e519 | 2015-09-14 00:37:22 -0700 | [diff] [blame] | 26 | arch_spinlock_t wait_lock; |
Waiman Long | 70af2f8 | 2014-02-03 13:18:49 +0100 | [diff] [blame] | 27 | } arch_rwlock_t; |
| 28 | |
| 29 | #define __ARCH_RW_LOCK_UNLOCKED { \ |
Will Deacon | e0d0228 | 2017-10-12 13:20:47 +0100 | [diff] [blame] | 30 | { .cnts = ATOMIC_INIT(0), }, \ |
Davidlohr Bueso | 6e1e519 | 2015-09-14 00:37:22 -0700 | [diff] [blame] | 31 | .wait_lock = __ARCH_SPIN_LOCK_UNLOCKED, \ |
Waiman Long | 70af2f8 | 2014-02-03 13:18:49 +0100 | [diff] [blame] | 32 | } |
| 33 | |
| 34 | #endif /* __ASM_GENERIC_QRWLOCK_TYPES_H */ |