Skip to content

Commit f5a2ea2

Browse files
committed
rust: Add new abstraction for regmap
Add an abstraction to regmap for Rust. Signed-off-by: Fabien Parent <[email protected]>
1 parent 563d61a commit f5a2ea2

File tree

5 files changed

+926
-0
lines changed

5 files changed

+926
-0
lines changed

rust/bindings/bindings_helper.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <linux/mdio.h>
1919
#include <linux/phy.h>
2020
#include <linux/refcount.h>
21+
#include <linux/regmap.h>
2122
#include <linux/sched.h>
2223
#include <linux/slab.h>
2324
#include <linux/wait.h>

rust/helpers/helpers.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "rbtree.c"
2222
#include "rcu.c"
2323
#include "refcount.c"
24+
#include "regmap.c"
2425
#include "signal.c"
2526
#include "slab.c"
2627
#include "spinlock.c"

rust/helpers/regmap.c

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
3+
#include <linux/i2c.h>
4+
#include <linux/regmap.h>
5+
6+
#if IS_BUILTIN(CONFIG_REGMAP_I2C)
7+
struct regmap *rust_helper_regmap_init_i2c(struct i2c_client *i2c,
8+
const struct regmap_config *config)
9+
{
10+
return regmap_init_i2c(i2c, config);
11+
}
12+
#endif
13+
14+
int rust_helper_regmap_field_write(struct regmap_field *field, unsigned int val)
15+
{
16+
return regmap_field_write(field, val);
17+
}
18+
19+
int rust_helper_regmap_field_force_write(struct regmap_field *field,
20+
unsigned int val)
21+
{
22+
return regmap_field_force_write(field, val);
23+
}
24+
25+
int rust_helper_regmap_field_update_bits(struct regmap_field *field,
26+
unsigned int mask, unsigned int val)
27+
{
28+
return regmap_field_update_bits(field, mask, val);
29+
}
30+
31+
int rust_helper_regmap_field_set_bits(struct regmap_field *field,
32+
unsigned int bits)
33+
{
34+
return regmap_field_set_bits(field, bits);
35+
}
36+
37+
int rust_helper_regmap_field_clear_bits(struct regmap_field *field,
38+
unsigned int bits)
39+
{
40+
return regmap_field_clear_bits(field, bits);
41+
}
42+
43+
int rust_helper_regmap_field_force_update_bits(struct regmap_field *field,
44+
unsigned int mask,
45+
unsigned int val)
46+
{
47+
return regmap_field_force_update_bits(field, mask, val);
48+
}

rust/kernel/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ pub mod page;
6060
pub mod prelude;
6161
pub mod print;
6262
pub mod rbtree;
63+
#[cfg(CONFIG_REGMAP)]
64+
pub mod regmap;
6365
pub mod revocable;
6466
pub mod sizes;
6567
mod static_assert;

0 commit comments

Comments
 (0)