Skip to content

Commit

Permalink
of: Add device_type access helper functions
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Rob Herring committed Aug 31, 2018
1 parent f42b0e1 commit 0413bed
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions include/linux/of.h
Original file line number Diff line number Diff line change
Expand Up @@ -988,6 +988,18 @@ static inline struct device_node *of_find_matching_node(
return of_find_matching_node_and_match(from, matches, NULL);
}

static inline const char *of_node_get_device_type(const struct device_node *np)
{
return of_get_property(np, "type", NULL);
}

static inline bool of_node_is_type(const struct device_node *np, const char *type)
{
const char *match = of_node_get_device_type(np);

return np && match && type && !strcmp(match, type);
}

/**
* of_property_count_u8_elems - Count the number of u8 elements in a property
*
Expand Down

0 comments on commit 0413bed

Please sign in to comment.