Skip to content

Commit 69f6ac7

Browse files
hoshinolinajannau
authored andcommitted
rust: of: Add OF node abstraction
This abstraction enables Rust drivers to walk Device Tree nodes and query their properties. Signed-off-by: Asahi Lina <lina@asahilina.net>
1 parent c888310 commit 69f6ac7

3 files changed

Lines changed: 485 additions & 0 deletions

File tree

rust/bindings/bindings_helper.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
#include <linux/ktime.h>
2626
#include <linux/lockdep.h>
2727
#include <linux/mdio.h>
28+
#include <linux/of.h>
29+
#include <linux/of_address.h>
2830
#include <linux/of_device.h>
2931
#include <linux/pci.h>
3032
#include <linux/phy.h>

rust/helpers/of.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
3+
#include <linux/of.h>
4+
#include <linux/of_device.h>
5+
6+
const struct of_device_id *rust_helper_of_match_device(
7+
const struct of_device_id *matches, const struct device *dev)
8+
{
9+
return of_match_device(matches, dev);
10+
}
11+
bool rust_helper_of_node_is_root(const struct device_node *np)
12+
{
13+
return of_node_is_root(np);
14+
}
15+
16+
struct device_node *rust_helper_of_parse_phandle(const struct device_node *np,
17+
const char *phandle_name,
18+
int index)
19+
{
20+
return of_parse_phandle(np, phandle_name, index);
21+
}

0 commit comments

Comments
 (0)