]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
rust: add bindings for bitops.h
authorBurak Emir <bqe@google.com>
Mon, 8 Sep 2025 07:21:52 +0000 (07:21 +0000)
committerYury Norov (NVIDIA) <yury.norov@gmail.com>
Mon, 22 Sep 2025 19:52:44 +0000 (15:52 -0400)
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 <aliceryhl@google.com>
Suggested-by: Yury Norov <yury.norov@gmail.com>
Signed-off-by: Burak Emir <bqe@google.com>
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Acked-by: Yury Norov (NVIDIA) <yury.norov@gmail.com>
Signed-off-by: Yury Norov (NVIDIA) <yury.norov@gmail.com>
MAINTAINERS
rust/helpers/bitops.c [new file with mode: 0644]
rust/helpers/helpers.c

index 543e4e8571247172a2bd93de99628ebbadabb1ac..3719eb3d6cb03a510860e79b33aad8cea7ceda5d 100644 (file)
@@ -4316,6 +4316,11 @@ F:       include/linux/bitops.h
 F:     lib/test_bitops.c
 F:     tools/*/bitops*
 
+BITOPS API BINDINGS [RUST]
+M:     Yury Norov <yury.norov@gmail.com>
+S:     Maintained
+F:     rust/helpers/bitops.c
+
 BLINKM RGB LED DRIVER
 M:     Jan-Simon Moeller <jansimon.moeller@gmx.de>
 S:     Maintained
diff --git a/rust/helpers/bitops.c b/rust/helpers/bitops.c
new file mode 100644 (file)
index 0000000..5d0861d
--- /dev/null
@@ -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);
+}
index 8437736fdf28442372c743933b060ad07bee946e..abff1ef14d8138eb44db1ba0cf9460d4d935ed58 100644 (file)
@@ -9,6 +9,7 @@
 
 #include "auxiliary.c"
 #include "bitmap.c"
+#include "bitops.c"
 #include "blk.c"
 #include "bug.c"
 #include "build_assert.c"