]> git.kernelconcepts.de Git - karo-tx-linux.git/blob - drivers/staging/lustre/include/linux/libcfs/linux/linux-lock.h
staging: lustre: Fix typo in lustre/include
[karo-tx-linux.git] / drivers / staging / lustre / include / linux / libcfs / linux / linux-lock.h
1 /*
2  * GPL HEADER START
3  *
4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 only,
8  * as published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * General Public License version 2 for more details (a copy is included
14  * in the LICENSE file that accompanied this code).
15  *
16  * You should have received a copy of the GNU General Public License
17  * version 2 along with this program; If not, see
18  * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
19  *
20  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
21  * CA 95054 USA or visit www.sun.com if you need additional information or
22  * have any questions.
23  *
24  * GPL HEADER END
25  */
26 /*
27  * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
28  * Use is subject to license terms.
29  *
30  * Copyright (c) 2012, Intel Corporation.
31  */
32 /*
33  * This file is part of Lustre, http://www.lustre.org/
34  * Lustre is a trademark of Sun Microsystems, Inc.
35  *
36  * libcfs/include/libcfs/linux/linux-lock.h
37  *
38  * Basic library routines.
39  */
40
41 #ifndef __LIBCFS_LINUX_CFS_LOCK_H__
42 #define __LIBCFS_LINUX_CFS_LOCK_H__
43
44 #ifndef __LIBCFS_LIBCFS_H__
45 #error Do not #include this file directly. #include <linux/libcfs/libcfs.h> instead
46 #endif
47
48
49 #include <linux/mutex.h>
50
51 /*
52  * IMPORTANT !!!!!!!!
53  *
54  * All locks' declaration are not guaranteed to be initialized,
55  * although some of them are initialized in Linux. All locks
56  * declared by CFS_DECL_* should be initialized explicitly.
57  */
58
59 /*
60  * spin_lock "implementation" (use Linux kernel's primitives)
61  *
62  * - spin_lock_init(x)
63  * - spin_lock(x)
64  * - spin_lock_bh(x)
65  * - spin_lock_bh_init(x)
66  * - spin_unlock(x)
67  * - spin_unlock_bh(x)
68  * - spin_trylock(x)
69  * - spin_is_locked(x)
70  *
71  * - spin_lock_irq(x)
72  * - spin_lock_irqsave(x, f)
73  * - spin_unlock_irqrestore(x, f)
74  * - read_lock_irqsave(lock, f)
75  * - write_lock_irqsave(lock, f)
76  * - write_unlock_irqrestore(lock, f)
77  */
78
79 /*
80  * spinlock "implementation"
81  */
82
83
84
85
86 /*
87  * rw_semaphore "implementation" (use Linux kernel's primitives)
88  *
89  * - sema_init(x)
90  * - init_rwsem(x)
91  * - down_read(x)
92  * - up_read(x)
93  * - down_write(x)
94  * - up_write(x)
95  */
96
97
98 #define fini_rwsem(s)           do {} while (0)
99
100
101 /*
102  * rwlock_t "implementation" (use Linux kernel's primitives)
103  *
104  * - rwlock_init(x)
105  * - read_lock(x)
106  * - read_unlock(x)
107  * - write_lock(x)
108  * - write_unlock(x)
109  * - write_lock_bh(x)
110  * - write_unlock_bh(x)
111  *
112  * - RW_LOCK_UNLOCKED
113  */
114
115
116 #ifndef DEFINE_RWLOCK
117 #define DEFINE_RWLOCK(lock)     rwlock_t lock = __RW_LOCK_UNLOCKED(lock)
118 #endif
119
120 /*
121  * completion "implementation" (use Linux kernel's primitives)
122  *
123  * - DECLARE_COMPLETION(work)
124  * - INIT_COMPLETION(c)
125  * - COMPLETION_INITIALIZER(work)
126  * - init_completion(c)
127  * - complete(c)
128  * - wait_for_completion(c)
129  * - wait_for_completion_interruptible(c)
130  * - fini_completion(c)
131  */
132 #define fini_completion(c) do { } while (0)
133
134 /*
135  * semaphore "implementation" (use Linux kernel's primitives)
136  * - DEFINE_SEMAPHORE(name)
137  * - sema_init(sem, val)
138  * - up(sem)
139  * - down(sem)
140  * - down_interruptible(sem)
141  * - down_trylock(sem)
142  */
143
144 /*
145  * mutex "implementation" (use Linux kernel's primitives)
146  *
147  * - DEFINE_MUTEX(name)
148  * - mutex_init(x)
149  * - mutex_lock(x)
150  * - mutex_unlock(x)
151  * - mutex_trylock(x)
152  * - mutex_is_locked(x)
153  * - mutex_destroy(x)
154  */
155
156 #ifndef lockdep_set_class
157
158 /**************************************************************************
159  *
160  * Lockdep "implementation". Also see liblustre.h
161  *
162  **************************************************************************/
163
164 struct lock_class_key {
165         ;
166 };
167
168 #define lockdep_set_class(lock, key) \
169         do { (void)sizeof(lock); (void)sizeof(key); } while (0)
170 /* This has to be a macro, so that `subclass' can be undefined in kernels
171  * that do not support lockdep. */
172
173
174 static inline void lockdep_off(void)
175 {
176 }
177
178 static inline void lockdep_on(void)
179 {
180 }
181 #else
182
183 #endif /* lockdep_set_class */
184
185 #ifndef CONFIG_DEBUG_LOCK_ALLOC
186 #ifndef mutex_lock_nested
187 #define mutex_lock_nested(mutex, subclass) mutex_lock(mutex)
188 #endif
189
190 #ifndef spin_lock_nested
191 #define spin_lock_nested(lock, subclass) spin_lock(lock)
192 #endif
193
194 #ifndef down_read_nested
195 #define down_read_nested(lock, subclass) down_read(lock)
196 #endif
197
198 #ifndef down_write_nested
199 #define down_write_nested(lock, subclass) down_write(lock)
200 #endif
201 #endif /* CONFIG_DEBUG_LOCK_ALLOC */
202
203
204 #endif /* __LIBCFS_LINUX_CFS_LOCK_H__ */