summaryrefslogtreecommitdiff
path: root/sys/dev/pci/drm/include/linux/spinlock.h
blob: acf04cd96b956103dc95aff8a4cb837b80a0758f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/* Public domain. */

#ifndef _LINUX_SPINLOCK_H
#define _LINUX_SPINLOCK_H

#include <linux/kernel.h>
#include <linux/spinlock_types.h>
#include <linux/preempt.h>
#include <linux/bottom_half.h>

static inline void
_spin_lock_irqsave(struct mutex *mtxp, __unused unsigned long flags
    LOCK_FL_VARS)
{
	_mtx_enter(mtxp LOCK_FL_ARGS);
}
static inline void
_spin_lock_irqsave_nested(struct mutex *mtxp, __unused unsigned long flags,
    __unused int subclass LOCK_FL_VARS)
{
	_mtx_enter(mtxp LOCK_FL_ARGS);
}
static inline void
_spin_unlock_irqrestore(struct mutex *mtxp, __unused unsigned long flags
    LOCK_FL_VARS)
{
	_mtx_leave(mtxp LOCK_FL_ARGS);
}
#define spin_lock_irqsave(m, fl)	\
	_spin_lock_irqsave(m, fl LOCK_FILE_LINE)
#define spin_lock_irqsave_nested(m, fl, subc)	\
	_spin_lock_irqsave_nested(m, fl, subc LOCK_FILE_LINE)
#define spin_unlock_irqrestore(m, fl)	\
	_spin_unlock_irqrestore(m, fl LOCK_FILE_LINE)

#define spin_lock(mtxp)			mtx_enter(mtxp)
#define spin_lock_nested(mtxp, l)	mtx_enter(mtxp)
#define spin_unlock(mtxp)		mtx_leave(mtxp)
#define spin_lock_irq(mtxp)		mtx_enter(mtxp)
#define spin_unlock_irq(mtxp)		mtx_leave(mtxp)
#define assert_spin_locked(mtxp)	MUTEX_ASSERT_LOCKED(mtxp)
#define spin_trylock_irq(mtxp)		mtx_enter_try(mtxp)

#define down_read(rwl)			rw_enter_read(rwl)
#define down_read_trylock(rwl)		(rw_enter(rwl, RW_READ | RW_NOSLEEP) == 0)
#define up_read(rwl)			rw_exit_read(rwl)
#define down_write(rwl)			rw_enter_write(rwl)
#define up_write(rwl)			rw_exit_write(rwl)
#define downgrade_write(rwl)		rw_enter(rwl, RW_DOWNGRADE)
#define read_lock(rwl)			rw_enter_read(rwl)
#define read_unlock(rwl)		rw_exit_read(rwl)
#define write_lock(rwl)			rw_enter_write(rwl)
#define write_unlock(rwl)		rw_exit_write(rwl)

#endif