rust: adds bindings for bitmap.c and bitops.c
Subsystems (3)
PATCH 1/1 rust: adds bindings for bitmap.c and bitops.c
Adds bindings are for inline non-atomic methods __set_bit and __clear_bit (bitops) as well as bitmap_copy_and_extend.
Update MAINTAINERS.
These are needed for providing a Rust Bitmap API.
---
Part of a series that introduces Rust Bitmap API that has received a few rounds of review. Thanks for the helpful review comments.
Rebased on next-20250318 and split as requested in
https://lore.kernel.org/all/Z9nAVIokrWqoRiFR@thinkpad/
MAINTAINERS | 6 ++++++ rust/bindings/bindings_helper.h | 1 + rust/helpers/bitmap.c | 9 +++++++++ rust/helpers/bitops.c | 13 +++++++++++++ rust/helpers/helpers.c | 2 ++ 5 files changed, 31 insertions(+) create mode 100644 rust/helpers/bitmap.c create mode 100644 rust/helpers/bitops.c
MAINTAINERS +6 -0
@@ -4111,6 +4111,7 @@ F: tools/lib/find_bit.c BITMAP API BINDINGS [RUST] M: Yury Norov <[email protected]> S: Maintained +F: rust/helpers/bitmap.c F: rust/helpers/cpumask.c BITOPS API
@@ -4127,6 +4128,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
rust/bindings/bindings_helper.h +1 -0
@@ -7,6 +7,7 @@*/ #include <kunit/test.h> +#include <linux/bitmap.h> #include <linux/blk-mq.h> #include <linux/blk_types.h> #include <linux/blkdev.h>
rust/helpers/bitmap.c new file +9 -0
@@ -0,0 +1,9 @@ +// SPDX-License-Identifier: GPL-2.0 + +#include <linux/bitmap.h> + +void rust_helper_bitmap_copy_and_extend (unsigned long *to,const unsigned long *from, +unsigned int count,unsigned int size) +{ +bitmap_copy_and_extend (to, from, count, size); +}
rust/helpers/bitops.c new file +13 -0
@@ -0,0 +1,13 @@ +// SPDX-License-Identifier: GPL-2.0 + +#include <linux/bitops.h> + +void rust_helper___set_bit (unsigned int nr,unsigned long *addr) +{ +__set_bit (nr, addr); +} + +void rust_helper___clear_bit (unsigned int nr,unsigned long *addr) +{ +__clear_bit (nr, addr); +}
rust/helpers/helpers.c +2 -0
@@ -7,6 +7,8 @@* Sorted alphabetically. */ +#include "bitmap.c" +#include "bitops.c" #include "blk.c" #include "bug.c" #include "build_assert.c"
Signature · 1 line
2.49.0.395.g12beb8f557-goog
Quoted 6 lines · Burak Emir
Part of a series that introduces Rust Bitmap API that has received a few rounds of review. Thanks for the helpful review comments.
Rebased on next-20250318 and split as requested in
https://lore.kernel.org/all/Z9nAVIokrWqoRiFR@thinkpad/
I am not sure Yury meant to make it an independent patch, but rather a different patch in the series.
Doing it this way means we add helpers that are unused, which I don't think he would like, and we also normally don't do that either.
Cheers,
Miguel
Quoted 6 lines · Miguel Ojeda
Quoted 4 lines · Burak Emir
Part of a series that introduces Rust Bitmap API that has received a few rounds of review. Thanks for the helpful review comments.
Quoted 8 lines
Quoted 2 lines
Rebased on next-20250318 and split as requested in
https://lore.kernel.org/all/Z9nAVIokrWqoRiFR@thinkpad/I am not sure Yury meant to make it an independent patch, but rather a different patch in the series.
Doing it this way means we add helpers that are unused, which I don't think he would like, and we also normally don't do that either.
Thanks, I was unsure about this. I understand the desire to not add dead code. Yet, next-20250318 does now contain helpers for cpumask.c without corresponding cpumask.rs
So, I will include this in v5 of the rebased series, but with BITOPS API BINDINGS [RUST] in its own patch.
Thanks for bearing with me : )
- Burak
Quoted 8 lines · Burak Emir
Thanks, I was unsure about this. I understand the desire to not add dead code. Yet, next-20250318 does now contain helpers for
cpumask.cwithout correspondingcpumask.rsSo, I will include this in v5 of the rebased series, but with BITOPS API BINDINGS [RUST] in its own patch.
Thanks for bearing with me : )
No worries at all! Perhaps wait a bit in case I misunderstood and Yury wants to clarify.
Cheers,
Miguel
Yury Norov
maintainerQuoted 6 lines · Miguel Ojeda
Quoted 5 lines · Burak Emir
Thanks, I was unsure about this. I understand the desire to not add dead code. Yet, next-20250318 does now contain helpers for
cpumask.cwithout correspondingcpumask.rs
Quoted 6 lines
Quoted 3 lines
So, I will include this in v5 of the rebased series, but with BITOPS API BINDINGS [RUST] in its own patch.
Thanks for bearing with me : )No worries at all! Perhaps wait a bit in case I misunderstood and Yury wants to clarify.
Yes, the general idea is to be able look through the all software pieces in a single series - from C wrappers all the way down to rust end users.
This way I'll make sure you are using the API in a right way. And I think I already helped you in that department, right?
Quoted 12 lines · Yury Norov
Quoted 10 lines · Miguel Ojeda
Quoted 8 lines · Burak Emir
Thanks, I was unsure about this. I understand the desire to not add dead code. Yet, next-20250318 does now contain helpers for
cpumask.cwithout correspondingcpumask.rsSo, I will include this in v5 of the rebased series, but with BITOPS API BINDINGS [RUST] in its own patch.
Thanks for bearing with me : )
Quoted 8 lines
Quoted 2 lines
No worries at all! Perhaps wait a bit in case I misunderstood and Yury wants to clarify.
Yes, the general idea is to be able look through the all software pieces in a single series - from C wrappers all the way down to rust end users.
This way I'll make sure you are using the API in a right way. And I think I already helped you in that department, right?
Yep, thank you for the timely reviews with the comments. The series got quite a few better. I'd love to be as timely with sending back the new versions, still getting used to the conventions, workflow and limitations of the infrastructure.