aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHimbeer <himbeer@disroot.org>2024-05-11 12:13:31 +0200
committerHimbeer <himbeer@disroot.org>2024-05-11 12:13:31 +0200
commit5af20fef3504465ce5e28c277fbcd72da7b85c0e (patch)
tree8b21ba9668eeb8197777dfeb758da67ba947ca09
parent1e0b501526232e475cad852828b40a13e616d2f0 (diff)
fdt: Add node compatibility checker
-rw-r--r--src/fdt.zig6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/fdt.zig b/src/fdt.zig
index 3912833..8ae748a 100644
--- a/src/fdt.zig
+++ b/src/fdt.zig
@@ -42,7 +42,7 @@ pub const Node = struct {
}
pub fn preferredDriver(self: Node, drivers: []const []const u8) ?[]const u8 {
- const compatible_prop = self.props.get("compatible") orelse return false;
+ const compatible_prop = self.props.get("compatible") orelse return null;
for (std.mem.tokenizeScalar(u8, compatible_prop, '\x00')) |compatible| {
if (std.mem.containsAtLeast([]const u8, drivers, compatible)) return compatible;
@@ -50,6 +50,10 @@ pub const Node = struct {
return null;
}
+
+ pub fn isCompatible(self: Node, with: []const u8) bool {
+ return self.preferredDriver([]const u8{with}) != null;
+ }
};
pub const Property = struct {