Skip to content

Commit 0413bed

Browse files
committed
of: Add device_type access helper functions
In preparation to remove direct access to device_node.type, add of_node_is_type() and of_node_get_device_type() helpers to check and retrieve the device type. Cc: Frank Rowand <frowand.list@gmail.com> Signed-off-by: Rob Herring <robh@kernel.org>
1 parent f42b0e1 commit 0413bed

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

include/linux/of.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -988,6 +988,18 @@ static inline struct device_node *of_find_matching_node(
988988
return of_find_matching_node_and_match(from, matches, NULL);
989989
}
990990

991+
static inline const char *of_node_get_device_type(const struct device_node *np)
992+
{
993+
return of_get_property(np, "type", NULL);
994+
}
995+
996+
static inline bool of_node_is_type(const struct device_node *np, const char *type)
997+
{
998+
const char *match = of_node_get_device_type(np);
999+
1000+
return np && match && type && !strcmp(match, type);
1001+
}
1002+
9911003
/**
9921004
* of_property_count_u8_elems - Count the number of u8 elements in a property
9931005
*

0 commit comments

Comments
 (0)