[PATCH v2 2/4] rust: add kref bindings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Introduce kref bindings for use in the Rust HID abstractions. Needed for
implementing the AlwaysRefCounted trait for kernel::hid::Device. Add rust
helpers for binding the kref_get and kref_put static inline C functions.

Signed-off-by: Rahul Rameshbabu <sergeantsagara@xxxxxxxxxxxxxx>
---
 rust/bindings/bindings_helper.h |  1 +
 rust/helpers/helpers.c          |  1 +
 rust/helpers/kref.c             | 13 +++++++++++++
 3 files changed, 15 insertions(+)
 create mode 100644 rust/helpers/kref.c

diff --git a/rust/bindings/bindings_helper.h b/rust/bindings/bindings_helper.h
index 8cbb660e2ec2..41a98d5b6521 100644
--- a/rust/bindings/bindings_helper.h
+++ b/rust/bindings/bindings_helper.h
@@ -54,6 +54,7 @@
 #include <linux/fs.h>
 #include <linux/jiffies.h>
 #include <linux/jump_label.h>
+#include <linux/kref.h>
 #include <linux/mdio.h>
 #include <linux/miscdevice.h>
 #include <linux/of_device.h>
diff --git a/rust/helpers/helpers.c b/rust/helpers/helpers.c
index b15b3cddad4e..7f5403d6c51c 100644
--- a/rust/helpers/helpers.c
+++ b/rust/helpers/helpers.c
@@ -25,6 +25,7 @@
 #include "fs.c"
 #include "io.c"
 #include "jump_label.c"
+#include "kref.c"
 #include "kunit.c"
 #include "mm.c"
 #include "mutex.c"
diff --git a/rust/helpers/kref.c b/rust/helpers/kref.c
new file mode 100644
index 000000000000..25eeb0a724ac
--- /dev/null
+++ b/rust/helpers/kref.c
@@ -0,0 +1,13 @@
+// SPDX-License-Identifier: GPL-2.0
+
+#include <linux/kref.h>
+
+void rust_helper_kref_get(struct kref *kref)
+{
+	kref_get(kref);
+}
+
+void rust_helper_kref_put(struct kref *kref, void (*release)(struct kref *kref))
+{
+	kref_put(kref, release);
+}
-- 
2.47.2







[Index of Archives]     [Linux Media Devel]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Linux Wireless Networking]     [Linux Omap]

  Powered by Linux