File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 6565#include <linux/mdio.h>
6666#include <linux/mm.h>
6767#include <linux/miscdevice.h>
68+ #include <linux/of.h>
69+ #include <linux/of_address.h>
6870#include <linux/of_device.h>
6971#include <linux/pci.h>
7072#include <linux/phy.h>
Original file line number Diff line number Diff line change 11// SPDX-License-Identifier: GPL-2.0
22
33#include <linux/of.h>
4+ #include <linux/of_device.h>
45
56bool rust_helper_is_of_node (const struct fwnode_handle * fwnode )
67{
78 return is_of_node (fwnode );
89}
10+
11+ const struct of_device_id * rust_helper_of_match_device (
12+ const struct of_device_id * matches , const struct device * dev )
13+ {
14+ return of_match_device (matches , dev );
15+ }
16+
17+ #ifdef CONFIG_OF
18+ bool rust_helper_of_node_is_root (const struct device_node * np )
19+ {
20+ return of_node_is_root (np );
21+ }
22+ #endif
23+
24+ struct device_node * rust_helper_of_parse_phandle (const struct device_node * np ,
25+ const char * phandle_name ,
26+ int index )
27+ {
28+ return of_parse_phandle (np , phandle_name , index );
29+ }
Original file line number Diff line number Diff line change 44//!
55//! C header: [`include/linux/device.h`](srctree/include/linux/device.h)
66
7+ use crate :: of;
78use crate :: {
89 bindings, fmt,
910 prelude:: * ,
@@ -368,6 +369,13 @@ impl<Ctx: DeviceContext> Device<Ctx> {
368369 unsafe { & * ptr. cast ( ) }
369370 }
370371
372+ /// Gets the OpenFirmware node attached to this device
373+ pub fn of_node ( & self ) -> Option < of:: Node > {
374+ let ptr = self . 0 . get ( ) ;
375+ // SAFETY: This is safe as long as of_node is NULL or valid.
376+ unsafe { of:: Node :: get_from_raw ( ( * ptr) . of_node ) }
377+ }
378+
371379 /// Prints an emergency-level message (level 0) prefixed with device information.
372380 ///
373381 /// More details are available from [`dev_emerg`].
You can’t perform that action at this time.
0 commit comments