diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2022-02-18 12:59:22 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2022-02-18 12:59:22 +0100 |
commit | f9375977a24c276a9cee2b95d72fa3f3acc371a3 (patch) | |
tree | 6a0a80a0d7ec472eb8b708e8e71571726f4d6791 /common | |
parent | ba8b2f8a2955585d217af4ef45e70a8787be61bb (diff) | |
parent | 92489ea9cce3b892d3deefe21cfa2cf1a4f870ac (diff) | |
download | barebox-f9375977a24c276a9cee2b95d72fa3f3acc371a3.tar.gz barebox-f9375977a24c276a9cee2b95d72fa3f3acc371a3.tar.xz |
Merge branch 'for-next/state'
Diffstat (limited to 'common')
-rw-r--r-- | common/state/state.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/common/state/state.c b/common/state/state.c index 8c34ae83e5..a614c849c7 100644 --- a/common/state/state.c +++ b/common/state/state.c @@ -704,10 +704,12 @@ struct state *state_by_name(const char *name) * * @node The of node of the state instance */ -struct state *state_by_node(const struct device_node *node) +struct state *state_by_node(struct device_node *node) { struct state *state; + of_device_ensure_probed(node); + list_for_each_entry(state, &state_list, list) { if (!strcmp(state->of_path, node->full_name)) return state; @@ -716,6 +718,22 @@ struct state *state_by_node(const struct device_node *node) return NULL; } +/* + * state_by_alias - find a state instance by alias + * + * @name The DT alias of the state instance + */ +struct state *state_by_alias(const char *alias) +{ + struct device_node *node; + + node = of_find_node_by_alias(NULL, alias); + if (!node) + return NULL; + + return state_by_node(node); +} + int state_read_mac(struct state *state, const char *name, u8 *buf) { struct state_variable *svar; |