Skip to content

Commit 6cf93a9

Browse files
Burak EmirYuryNorov
authored andcommitted
rust: add bindings for bitops.h
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>
1 parent 0452b4a commit 6cf93a9

3 files changed

Lines changed: 29 additions & 0 deletions

File tree

MAINTAINERS

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4316,6 +4316,11 @@ F: include/linux/bitops.h
43164316
F: lib/test_bitops.c
43174317
F: tools/*/bitops*
43184318

4319+
BITOPS API BINDINGS [RUST]
4320+
M: Yury Norov <yury.norov@gmail.com>
4321+
S: Maintained
4322+
F: rust/helpers/bitops.c
4323+
43194324
BLINKM RGB LED DRIVER
43204325
M: Jan-Simon Moeller <jansimon.moeller@gmx.de>
43214326
S: Maintained

rust/helpers/bitops.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
3+
#include <linux/bitops.h>
4+
5+
void rust_helper___set_bit(unsigned long nr, unsigned long *addr)
6+
{
7+
__set_bit(nr, addr);
8+
}
9+
10+
void rust_helper___clear_bit(unsigned long nr, unsigned long *addr)
11+
{
12+
__clear_bit(nr, addr);
13+
}
14+
15+
void rust_helper_set_bit(unsigned long nr, volatile unsigned long *addr)
16+
{
17+
set_bit(nr, addr);
18+
}
19+
20+
void rust_helper_clear_bit(unsigned long nr, volatile unsigned long *addr)
21+
{
22+
clear_bit(nr, addr);
23+
}

rust/helpers/helpers.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
#include "auxiliary.c"
1111
#include "bitmap.c"
12+
#include "bitops.c"
1213
#include "blk.c"
1314
#include "bug.c"
1415
#include "build_assert.c"

0 commit comments

Comments
 (0)