Makes atomic set_bit and clear_bit inline functions as well as the
non-atomic variants __set_bit and __clear_bit available to Rust.
Adds a new MAINTAINERS section BITOPS API BINDINGS [RUST].

Suggested-by: Alice Ryhl <[email protected]>
Suggested-by: Yury Norov <[email protected]>
Signed-off-by: Burak Emir <[email protected]>
Acked-by: Yury Norov [NVIDIA] <[email protected]>
---
 MAINTAINERS            |  5 +++++
 rust/helpers/bitops.c  | 23 +++++++++++++++++++++++
 rust/helpers/helpers.c |  1 +
 3 files changed, 29 insertions(+)
 create mode 100644 rust/helpers/bitops.c

diff --git a/MAINTAINERS b/MAINTAINERS
index f83386712a2d..8acc32a59ff5 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -4217,6 +4217,11 @@ F:       include/linux/bitops.h
 F:     lib/test_bitops.c
 F:     tools/*/bitops*
 
+BITOPS API BINDINGS [RUST]
+M:     Yury Norov <[email protected]>
+S:     Maintained
+F:     rust/helpers/bitops.c
+
 BLINKM RGB LED DRIVER
 M:     Jan-Simon Moeller <[email protected]>
 S:     Maintained
diff --git a/rust/helpers/bitops.c b/rust/helpers/bitops.c
new file mode 100644
index 000000000000..5d0861d29d3f
--- /dev/null
+++ b/rust/helpers/bitops.c
@@ -0,0 +1,23 @@
+// SPDX-License-Identifier: GPL-2.0
+
+#include <linux/bitops.h>
+
+void rust_helper___set_bit(unsigned long nr, unsigned long *addr)
+{
+       __set_bit(nr, addr);
+}
+
+void rust_helper___clear_bit(unsigned long nr, unsigned long *addr)
+{
+       __clear_bit(nr, addr);
+}
+
+void rust_helper_set_bit(unsigned long nr, volatile unsigned long *addr)
+{
+       set_bit(nr, addr);
+}
+
+void rust_helper_clear_bit(unsigned long nr, volatile unsigned long *addr)
+{
+       clear_bit(nr, addr);
+}
diff --git a/rust/helpers/helpers.c b/rust/helpers/helpers.c
index cb47c4708a3b..63dc1ffd31e1 100644
--- a/rust/helpers/helpers.c
+++ b/rust/helpers/helpers.c
@@ -9,6 +9,7 @@
 
 #include "auxiliary.c"
 #include "bitmap.c"
+#include "bitops.c"
 #include "blk.c"
 #include "bug.c"
 #include "build_assert.c"
-- 
2.50.0.rc2.761.g2dc52ea45b-goog


Reply via email to