aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmmanuel Vadot <manu@FreeBSD.org>2022-08-09 09:03:34 +0000
committerEmmanuel Vadot <manu@FreeBSD.org>2022-08-18 07:46:25 +0000
commit1a6874e3a411c7876bee55bc631119a2e1cd09a2 (patch)
treedcad2ebaedb650f12c613015943f733cbe9c898c
parent4370e9f1cfce6f43f170790be96b79f3da70be13 (diff)
downloadsrc-1a6874e3a411c7876bee55bc631119a2e1cd09a2.tar.gz
src-1a6874e3a411c7876bee55bc631119a2e1cd09a2.zip
linuxkpi: Add refcount_dec_and_test
In Linux this takes a refcount_t argument but in linuxkpi struct kref uses an atomic_t for the refcount and code in drm directly uses this function with a kref so use an atomic_t here. Reviewed by: bz Sponsored by: Beckhoff Automation GmbH & Co. KG Differential Revision: https://reviews.freebsd.org/D36099
-rw-r--r--sys/compat/linuxkpi/common/include/linux/kref.h1
-rw-r--r--sys/compat/linuxkpi/common/include/linux/refcount.h11
2 files changed, 12 insertions, 0 deletions
diff --git a/sys/compat/linuxkpi/common/include/linux/kref.h b/sys/compat/linuxkpi/common/include/linux/kref.h
index 2c59794f4ddc..3b5645bf139b 100644
--- a/sys/compat/linuxkpi/common/include/linux/kref.h
+++ b/sys/compat/linuxkpi/common/include/linux/kref.h
@@ -43,6 +43,7 @@
#include <asm/atomic.h>
struct kref {
+ /* XXX In Linux this is a refcount_t */
atomic_t refcount;
};
diff --git a/sys/compat/linuxkpi/common/include/linux/refcount.h b/sys/compat/linuxkpi/common/include/linux/refcount.h
index 7c055fb32029..6a49da530c0a 100644
--- a/sys/compat/linuxkpi/common/include/linux/refcount.h
+++ b/sys/compat/linuxkpi/common/include/linux/refcount.h
@@ -79,4 +79,15 @@ refcount_dec_and_lock_irqsave(refcount_t *ref, spinlock_t *lock,
return (false);
}
+/*
+ * struct kref uses atomic_t and not refcount_t so
+ * we differ from Linux here.
+ */
+static inline bool
+refcount_dec_and_test(atomic_t *r)
+{
+
+ return (atomic_dec_and_test(r));
+}
+
#endif /* __LINUXKPI_LINUX_REFCOUNT_H__ */