blob: c36f1d5a2572cdbc01106730a815637419acbf35 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Waiman Long70af2f82014-02-03 13:18:49 +01002#ifndef __ASM_GENERIC_QRWLOCK_TYPES_H
3#define __ASM_GENERIC_QRWLOCK_TYPES_H
4
5#include <linux/types.h>
Arnd Bergmannca66e792018-02-02 16:40:44 +01006#include <asm/byteorder.h>
Waiman Long70af2f82014-02-03 13:18:49 +01007#include <asm/spinlock_types.h>
8
9/*
10 * The queue read/write lock data structure
11 */
12
13typedef struct qrwlock {
Will Deacone0d02282017-10-12 13:20:47 +010014 union {
15 atomic_t cnts;
16 struct {
17#ifdef __LITTLE_ENDIAN
Will Deacond1331662017-10-12 13:20:51 +010018 u8 wlocked; /* Locked for write? */
19 u8 __lstate[3];
Will Deacone0d02282017-10-12 13:20:47 +010020#else
Will Deacond1331662017-10-12 13:20:51 +010021 u8 __lstate[3];
22 u8 wlocked; /* Locked for write? */
Will Deacone0d02282017-10-12 13:20:47 +010023#endif
24 };
25 };
Davidlohr Bueso6e1e5192015-09-14 00:37:22 -070026 arch_spinlock_t wait_lock;
Waiman Long70af2f82014-02-03 13:18:49 +010027} arch_rwlock_t;
28
29#define __ARCH_RW_LOCK_UNLOCKED { \
Will Deacone0d02282017-10-12 13:20:47 +010030 { .cnts = ATOMIC_INIT(0), }, \
Davidlohr Bueso6e1e5192015-09-14 00:37:22 -070031 .wait_lock = __ARCH_SPIN_LOCK_UNLOCKED, \
Waiman Long70af2f82014-02-03 13:18:49 +010032}
33
34#endif /* __ASM_GENERIC_QRWLOCK_TYPES_H */