drm: Add linux/rwlock.h
authorFrançois Tigeot <ftigeot@wolfpond.org>
Sat, 3 Nov 2018 13:07:50 +0000 (14:07 +0100)
committerFrançois Tigeot <ftigeot@wolfpond.org>
Sat, 3 Nov 2018 13:07:50 +0000 (14:07 +0100)
sys/dev/drm/include/linux/rwlock.h [copied from sys/dev/drm/include/linux/spinlock.h with 54% similarity]
sys/dev/drm/include/linux/sched.h
sys/dev/drm/include/linux/spinlock.h

similarity index 54%
copy from sys/dev/drm/include/linux/spinlock.h
copy to sys/dev/drm/include/linux/rwlock.h
index 199baf8..dd4e06f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015-2017 François Tigeot
+ * Copyright (c) 2018 François Tigeot <ftigeot@wolfpond.org>
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef _LINUX_SPINLOCK_H_
-#define _LINUX_SPINLOCK_H_
+#ifndef _LINUX_RWLOCK_H_
+#define _LINUX_RWLOCK_H_
 
-#include <sys/spinlock2.h>
-#include <sys/lock.h>
+#define write_lock(lock)       lockmgr((lock), LK_EXCLUSIVE)
+#define write_unlock(lock)     lockmgr((lock), LK_RELEASE)
 
-#include <linux/irqflags.h>
-#include <asm/barrier.h>
-
-#define spin_is_locked(x)      spin_held(x)
-
-#define assert_spin_locked(x)  KKASSERT(lockinuse(x))
-
-/*
- * The spin_lock_irq() family of functions stop hardware interrupts
- * from being delivered to the local CPU.
- * A crit_enter()/crit_exit() sequence does the same thing on the
- * DragonFly kernel
- */
-static inline void spin_lock_irq(struct lock *lock)
-{
-       crit_enter();
-       lockmgr(lock, LK_EXCLUSIVE);
-}
-
-static inline void spin_unlock_irq(struct lock *lock)
-{
-       lockmgr(lock, LK_RELEASE);
-       crit_exit();
-}
-
-#define spin_lock_irqsave(lock, flags)         do { flags = 0; spin_lock_irq(lock); } while(0)
-#define spin_unlock_irqrestore(lock, flags)    do { flags = 0; spin_unlock_irq(lock); } while(0)
-
-static inline void
-spin_lock_bh(struct lock *lock)
-{
-       spin_lock_irq(lock);
-}
-
-static inline void
-spin_unlock_bh(struct lock *lock)
-{
-       spin_unlock_irq(lock);
-}
-
-#endif /* _LINUX_SPINLOCK_H_ */
+#endif /* _LINUX_RWLOCK_H_ */
index 334150f..fd4b3a3 100644 (file)
@@ -49,6 +49,8 @@
 #include <linux/hrtimer.h>
 #include <linux/gfp.h>
 
+#include <linux/spinlock.h>
+
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/proc.h>
index 199baf8..e394b4d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015-2017 François Tigeot
+ * Copyright (c) 2015-2018 François Tigeot
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
 #ifndef _LINUX_SPINLOCK_H_
 #define _LINUX_SPINLOCK_H_
 
-#include <sys/spinlock2.h>
-#include <sys/lock.h>
-
+#include <linux/compiler.h>
 #include <linux/irqflags.h>
+#include <linux/kernel.h>
+#include <linux/stringify.h>
 #include <asm/barrier.h>
 
+#include <linux/rwlock.h>
+
+#include <sys/spinlock2.h>
+#include <sys/lock.h>
+
 #define spin_is_locked(x)      spin_held(x)
 
 #define assert_spin_locked(x)  KKASSERT(lockinuse(x))