git: 37e07609505e - stable/13 - linuxkpi: Add refcount_dec_and_test
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 07 Sep 2022 15:10:25 UTC
The branch stable/13 has been updated by manu:
URL: https://cgit.FreeBSD.org/src/commit/?id=37e07609505e869831753bc7b25976c09bc3b52a
commit 37e07609505e869831753bc7b25976c09bc3b52a
Author: Emmanuel Vadot <manu@FreeBSD.org>
AuthorDate: 2022-08-09 09:03:34 +0000
Commit: Emmanuel Vadot <manu@FreeBSD.org>
CommitDate: 2022-09-07 15:09:05 +0000
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
(cherry picked from commit 1a6874e3a411c7876bee55bc631119a2e1cd09a2)
---
sys/compat/linuxkpi/common/include/linux/kref.h | 1 +
sys/compat/linuxkpi/common/include/linux/refcount.h | 11 +++++++++++
2 files changed, 12 insertions(+)
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__ */