[PATCH] fixup! of: add function to read a file as unflattened device tree
Ahmad Fatoum
a.fatoum at pengutronix.de
Fri May 19 00:19:39 PDT 2023
of: tidy up of_read_file a bit
- change a single instance of space indentation to tabs
- use %m instead of unwieldy strerror(errno)
- add documentation
Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
drivers/of/base.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/drivers/of/base.c b/drivers/of/base.c
index 918d5e0c5348..5da188115547 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -2893,6 +2893,12 @@ int of_device_disable_by_alias(const char *alias)
return of_device_disable(node);
}
+/**
+ * of_read_file - unflatten oftree file
+ * @filename - path to file to unflatten its contents
+ *
+ * Returns the root node of the tree or an error pointer on error.
+ */
struct device_node *of_read_file(const char *filename)
{
void *fdt;
@@ -2901,8 +2907,7 @@ struct device_node *of_read_file(const char *filename)
fdt = read_file(filename, &size);
if (!fdt) {
- pr_err("unable to read %s: %s\n", filename,
- strerror(errno));
+ pr_err("unable to read %s: %m\n", filename);
return ERR_PTR(-errno);
}
@@ -2916,7 +2921,7 @@ struct device_node *of_read_file(const char *filename)
out:
free(fdt);
- return root;
+ return root;
}
/**
--
2.39.2
More information about the barebox
mailing list