]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - fs/aufs/rwsem.h
rtc: pcf8523: set xtal load capacitance from DT
[mirror_ubuntu-bionic-kernel.git] / fs / aufs / rwsem.h
1 /*
2 * Copyright (C) 2005-2017 Junjiro R. Okajima
3 *
4 * This program, aufs is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18 /*
19 * simple read-write semaphore wrappers
20 */
21
22 #ifndef __AUFS_RWSEM_H__
23 #define __AUFS_RWSEM_H__
24
25 #ifdef __KERNEL__
26
27 #include "debug.h"
28
29 /* in the futre, the name 'au_rwsem' will be totally gone */
30 #define au_rwsem rw_semaphore
31
32 /* to debug easier, do not make them inlined functions */
33 #define AuRwMustNoWaiters(rw) AuDebugOn(rwsem_is_contended(rw))
34 /* rwsem_is_locked() is unusable */
35 #define AuRwMustReadLock(rw) AuDebugOn(!lockdep_recursing(current) \
36 && debug_locks \
37 && !lockdep_is_held_type(rw, 1))
38 #define AuRwMustWriteLock(rw) AuDebugOn(!lockdep_recursing(current) \
39 && debug_locks \
40 && !lockdep_is_held_type(rw, 0))
41 #define AuRwMustAnyLock(rw) AuDebugOn(!lockdep_recursing(current) \
42 && debug_locks \
43 && !lockdep_is_held(rw))
44 #define AuRwDestroy(rw) AuDebugOn(!lockdep_recursing(current) \
45 && debug_locks \
46 && lockdep_is_held(rw))
47
48 #define au_rw_init(rw) init_rwsem(rw)
49
50 #define au_rw_init_wlock(rw) do { \
51 au_rw_init(rw); \
52 down_write(rw); \
53 } while (0)
54
55 #define au_rw_init_wlock_nested(rw, lsc) do { \
56 au_rw_init(rw); \
57 down_write_nested(rw, lsc); \
58 } while (0)
59
60 #define au_rw_read_lock(rw) down_read(rw)
61 #define au_rw_read_lock_nested(rw, lsc) down_read_nested(rw, lsc)
62 #define au_rw_read_unlock(rw) up_read(rw)
63 #define au_rw_dgrade_lock(rw) downgrade_write(rw)
64 #define au_rw_write_lock(rw) down_write(rw)
65 #define au_rw_write_lock_nested(rw, lsc) down_write_nested(rw, lsc)
66 #define au_rw_write_unlock(rw) up_write(rw)
67 /* why is not _nested version defined? */
68 #define au_rw_read_trylock(rw) down_read_trylock(rw)
69 #define au_rw_write_trylock(rw) down_write_trylock(rw)
70
71 #endif /* __KERNEL__ */
72 #endif /* __AUFS_RWSEM_H__ */