diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2013-07-16 15:36:40 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2013-07-18 13:54:23 +0200 |
commit | 3ae902ed7f06e9392624dad1ed23fd4f0dc9c38b (patch) | |
tree | 322e8f463088923fe7bc32bc92735291ab36db1a /drivers | |
parent | 9cb5f51d0aeca9b2f18019d05b7b09884809037d (diff) | |
download | barebox-3ae902ed7f06e9392624dad1ed23fd4f0dc9c38b.tar.gz barebox-3ae902ed7f06e9392624dad1ed23fd4f0dc9c38b.tar.xz |
of: Add convenience functions to en/disable devicenodes
These functions allow to manipulate the "status" property of
devicenodes effectively enabling/disabling devices.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/of/base.c | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/drivers/of/base.c b/drivers/of/base.c index e9f1f79324..0b1a8a2fa8 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -1739,3 +1739,68 @@ int of_add_initrd(struct device_node *root, resource_size_t start, return 0; } + +/** + * of_device_enable - enable a devicenode device + * @node - the node to enable + * + * This deletes the status property of a devicenode effectively + * enabling the device. + */ +int of_device_enable(struct device_node *node) +{ + struct property *pp; + + pp = of_find_property(node, "status", NULL); + if (!pp) + return 0; + + of_delete_property(pp); + + return 0; +} + +/** + * of_device_enable_path - enable a devicenode + * @path - the nodepath to enable + * + * wrapper around of_device_enable taking the nodepath as argument + */ +int of_device_enable_path(const char *path) +{ + struct device_node *node; + + node = of_find_node_by_path(path); + if (!node) + return -ENODEV; + + return of_device_enable(node); +} + +/** + * of_device_enable - disable a devicenode device + * @node - the node to disable + * + * This sets the status of a devicenode to "disabled" + */ +int of_device_disable(struct device_node *node) +{ + return of_set_property(node, "status", "disabled", sizeof("disabled"), 1); +} + +/** + * of_device_disable_path - disable a devicenode + * @path - the nodepath to disable + * + * wrapper around of_device_disable taking the nodepath as argument + */ +int of_device_disable_path(const char *path) +{ + struct device_node *node; + + node = of_find_node_by_path(path); + if (!node) + return -ENODEV; + + return of_device_disable(node); +} |