Wed Jul 24 02:50:36 2013 UTC ()
Tag the spinlock struct in <linux/spinlock.h>.


(riastradh)
diff -r1.1.2.5 -r1.1.2.6 src/sys/external/bsd/drm2/include/linux/spinlock.h

cvs diff -r1.1.2.5 -r1.1.2.6 src/sys/external/bsd/drm2/include/linux/spinlock.h (switch to unified diff)

--- src/sys/external/bsd/drm2/include/linux/spinlock.h 2013/07/24 02:24:58 1.1.2.5
+++ src/sys/external/bsd/drm2/include/linux/spinlock.h 2013/07/24 02:50:36 1.1.2.6
@@ -1,91 +1,91 @@ @@ -1,91 +1,91 @@
1/* $NetBSD: spinlock.h,v 1.1.2.5 2013/07/24 02:24:58 riastradh Exp $ */ 1/* $NetBSD: spinlock.h,v 1.1.2.6 2013/07/24 02:50:36 riastradh Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2013 The NetBSD Foundation, Inc. 4 * Copyright (c) 2013 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Taylor R. Campbell. 8 * by Taylor R. Campbell.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright 15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the 16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution. 17 * documentation and/or other materials provided with the distribution.
18 * 18 *
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE. 29 * POSSIBILITY OF SUCH DAMAGE.
30 */ 30 */
31 31
32#ifndef _LINUX_SPINLOCK_H_ 32#ifndef _LINUX_SPINLOCK_H_
33#define _LINUX_SPINLOCK_H_ 33#define _LINUX_SPINLOCK_H_
34 34
35#include <sys/cdefs.h> 35#include <sys/cdefs.h>
36#include <sys/mutex.h> 36#include <sys/mutex.h>
37 37
38typedef struct { 38typedef struct spinlock {
39 kmutex_t sl_lock; 39 kmutex_t sl_lock;
40} spinlock_t; 40} spinlock_t;
41 41
42static inline int 42static inline int
43spin_is_locked(spinlock_t *spinlock) 43spin_is_locked(spinlock_t *spinlock)
44{ 44{
45 return mutex_owned(&spinlock->sl_lock); 45 return mutex_owned(&spinlock->sl_lock);
46} 46}
47 47
48static inline void 48static inline void
49spin_lock(spinlock_t *spinlock) 49spin_lock(spinlock_t *spinlock)
50{ 50{
51 mutex_enter(&spinlock->sl_lock); 51 mutex_enter(&spinlock->sl_lock);
52} 52}
53 53
54static inline void 54static inline void
55spin_unlock(spinlock_t *spinlock) 55spin_unlock(spinlock_t *spinlock)
56{ 56{
57 mutex_exit(&spinlock->sl_lock); 57 mutex_exit(&spinlock->sl_lock);
58} 58}
59 59
60/* Must be a macro because the second argument is to be assigned. */ 60/* Must be a macro because the second argument is to be assigned. */
61#define spin_lock_irqsave(SPINLOCK, FLAGS) \ 61#define spin_lock_irqsave(SPINLOCK, FLAGS) \
62 do { \ 62 do { \
63 (FLAGS) = 0; \ 63 (FLAGS) = 0; \
64 mutex_enter(&((spinlock_t *)(SPINLOCK))->sl_lock); \ 64 mutex_enter(&((spinlock_t *)(SPINLOCK))->sl_lock); \
65 } while (0) 65 } while (0)
66 66
67static inline void 67static inline void
68spin_unlock_irqrestore(spinlock_t *spinlock, unsigned long __unused flags) 68spin_unlock_irqrestore(spinlock_t *spinlock, unsigned long __unused flags)
69{ 69{
70 mutex_exit(&spinlock->sl_lock); 70 mutex_exit(&spinlock->sl_lock);
71} 71}
72 72
73static inline void 73static inline void
74spin_lock_init(spinlock_t *spinlock) 74spin_lock_init(spinlock_t *spinlock)
75{ 75{
76 /* XXX Need to identify which need to block intrs. */ 76 /* XXX Need to identify which need to block intrs. */
77 mutex_init(&spinlock->sl_lock, MUTEX_DEFAULT, IPL_NONE); 77 mutex_init(&spinlock->sl_lock, MUTEX_DEFAULT, IPL_NONE);
78} 78}
79 79
80/* 80/*
81 * XXX Linux doesn't ever destroy spin locks, it seems. We'll have to 81 * XXX Linux doesn't ever destroy spin locks, it seems. We'll have to
82 * kludge it up. 82 * kludge it up.
83 */ 83 */
84 84
85static inline void 85static inline void
86spin_lock_destroy(spinlock_t *spinlock) 86spin_lock_destroy(spinlock_t *spinlock)
87{ 87{
88 mutex_destroy(&spinlock->sl_lock); 88 mutex_destroy(&spinlock->sl_lock);
89} 89}
90 90
91#endif /* _LINUX_SPINLOCK_H_ */ 91#endif /* _LINUX_SPINLOCK_H_ */