diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2016-03-11 10:49:50 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2016-03-11 10:49:50 +0100 |
commit | 034d4ddcb6dfc7f72cb5076807e93a7bb7e4636b (patch) | |
tree | a8912608d1b8f1614e58c94f67e0b9f1801018e6 /common | |
parent | 7991fe1b8eb057c6d7acc5c91f10108c1ee10a52 (diff) | |
parent | 092479d7da288479eb99362b4e852948b1de6de9 (diff) | |
download | barebox-034d4ddcb6dfc7f72cb5076807e93a7bb7e4636b.tar.gz barebox-034d4ddcb6dfc7f72cb5076807e93a7bb7e4636b.tar.xz |
Merge branch 'for-next/misc'
Diffstat (limited to 'common')
-rw-r--r-- | common/oftree.c | 36 | ||||
-rw-r--r-- | common/state.c | 1 |
2 files changed, 37 insertions, 0 deletions
diff --git a/common/oftree.c b/common/oftree.c index d408f14e66..e98b908738 100644 --- a/common/oftree.c +++ b/common/oftree.c @@ -139,6 +139,42 @@ static int of_register_bootargs_fixup(void) } late_initcall(of_register_bootargs_fixup); +struct of_fixup_status_data { + const char *path; + bool status; +}; + +static int of_fixup_status(struct device_node *root, void *context) +{ + const struct of_fixup_status_data *data = context; + struct device_node *node; + + node = of_find_node_by_path_or_alias(root, data->path); + if (!node) + return -ENODEV; + + if (data->status) + return of_device_enable(node); + else + return of_device_disable(node); +} + +/** + * of_register_set_status_fixup - register fix up to set status of nodes + * Register a fixup to enable or disable a node in the devicet tree by + * passing the path or alias. + */ +int of_register_set_status_fixup(const char *path, bool status) +{ + struct of_fixup_status_data *data; + + data = xzalloc(sizeof(*data)); + data->path = path; + data->status = status; + + return of_register_fixup(of_fixup_status, (void *)data); +} + struct of_fixup { int (*fixup)(struct device_node *, void *); void *context; diff --git a/common/state.c b/common/state.c index 3e95efd911..b55b1503bd 100644 --- a/common/state.c +++ b/common/state.c @@ -999,6 +999,7 @@ static int of_state_fixup(struct device_node *root, void *ctx) return 0; out: + dev_err(&state->dev, "error fixing up device tree with boot state\n"); of_delete_node(new_node); return ret; } |