diff options
author | Rob Herring <robh@kernel.org> | 2017-09-29 03:20:32 +0300 |
---|---|---|
committer | Rob Herring <robh@kernel.org> | 2017-10-16 21:43:21 +0300 |
commit | ecc8a96e251dc43d13841bac44fbfa34ec20fc52 (patch) | |
tree | 983b430099a97fc350ccc2ff4e799490fd9a4d9f /drivers/of/fdt.c | |
parent | b56b5528f5b3c3d47e7c0ca67318c45e980d93f0 (diff) | |
download | linux-ecc8a96e251dc43d13841bac44fbfa34ec20fc52.tar.xz |
of/fdt: add of_fdt_device_is_available function
Add an equivalent function to of_device_is_available for flattened DT, and
convert the one existing open coded occurrence.
Tested-by: Nicolas Pitre <nico@linaro.org>
Reviewed-by: Frank Rowand <frowand.list@gmail.com>
Signed-off-by: Rob Herring <robh@kernel.org>
Diffstat (limited to 'drivers/of/fdt.c')
-rw-r--r-- | drivers/of/fdt.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index 27c535af0be8..f8c39705418b 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c @@ -132,6 +132,19 @@ bool of_fdt_is_big_endian(const void *blob, unsigned long node) return false; } +static bool of_fdt_device_is_available(const void *blob, unsigned long node) +{ + const char *status = fdt_getprop(blob, node, "status", NULL); + + if (!status) + return true; + + if (!strcmp(status, "ok") || !strcmp(status, "okay")) + return true; + + return false; +} + /** * of_fdt_match - Return true if node matches a list of compatible values */ @@ -605,7 +618,6 @@ static int __init __fdt_scan_reserved_mem(unsigned long node, const char *uname, int depth, void *data) { static int found; - const char *status; int err; if (!found && depth == 1 && strcmp(uname, "reserved-memory") == 0) { @@ -625,8 +637,7 @@ static int __init __fdt_scan_reserved_mem(unsigned long node, const char *uname, return 1; } - status = of_get_flat_dt_prop(node, "status", NULL); - if (status && strcmp(status, "okay") != 0 && strcmp(status, "ok") != 0) + if (!of_fdt_device_is_available(initial_boot_params, node)) return 0; err = __reserved_mem_reserve_reg(node, uname); |