]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
fdt_support: move fdt_valid from cmd_fdt.c to fdt_support.c
authorKory Maincent <kory.maincent@bootlin.com>
Tue, 4 May 2021 17:31:21 +0000 (19:31 +0200)
committerTom Rini <trini@konsulko.com>
Thu, 13 May 2021 11:19:34 +0000 (07:19 -0400)
Move the fdt_valid function to fdt_support.
This changes allow to be able to test the validity of a devicetree in
other c files.

Update code syntax.

Signed-off-by: Kory Maincent <kory.maincent@bootlin.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Maxime Ripard <maxime@cerno.tech>
cmd/fdt.c
common/fdt_support.c
include/fdt_support.h

index 89ab572d8df71d0bb85bbae3ebeb1efbb1243acd..f1e2fc2fd8bf93ea5df1bd45ca9fe85ae6e6e001 100644 (file)
--- a/cmd/fdt.c
+++ b/cmd/fdt.c
@@ -27,7 +27,6 @@
  */
 DECLARE_GLOBAL_DATA_PTR;
 
-static int fdt_valid(struct fdt_header **blobp);
 static int fdt_parse_prop(char *const*newval, int count, char *data, int *len);
 static int fdt_print(const char *pathp, char *prop, int depth);
 static int is_printable_string(const void *data, int len);
@@ -732,54 +731,6 @@ static int do_fdt(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
 
 /****************************************************************************/
 
-/**
- * fdt_valid() - Check if an FDT is valid. If not, change it to NULL
- *
- * @blobp: Pointer to FDT pointer
- * @return 1 if OK, 0 if bad (in which case *blobp is set to NULL)
- */
-static int fdt_valid(struct fdt_header **blobp)
-{
-       const void *blob = *blobp;
-       int err;
-
-       if (blob == NULL) {
-               printf ("The address of the fdt is invalid (NULL).\n");
-               return 0;
-       }
-
-       err = fdt_check_header(blob);
-       if (err == 0)
-               return 1;       /* valid */
-
-       if (err < 0) {
-               printf("libfdt fdt_check_header(): %s", fdt_strerror(err));
-               /*
-                * Be more informative on bad version.
-                */
-               if (err == -FDT_ERR_BADVERSION) {
-                       if (fdt_version(blob) <
-                           FDT_FIRST_SUPPORTED_VERSION) {
-                               printf (" - too old, fdt %d < %d",
-                                       fdt_version(blob),
-                                       FDT_FIRST_SUPPORTED_VERSION);
-                       }
-                       if (fdt_last_comp_version(blob) >
-                           FDT_LAST_SUPPORTED_VERSION) {
-                               printf (" - too new, fdt %d > %d",
-                                       fdt_version(blob),
-                                       FDT_LAST_SUPPORTED_VERSION);
-                       }
-               }
-               printf("\n");
-               *blobp = NULL;
-               return 0;
-       }
-       return 1;
-}
-
-/****************************************************************************/
-
 /*
  * Parse the user's input, partially heuristic.  Valid formats:
  * <0x00112233 4 05>   - an array of cells.  Numbers follow standard
index 695d8e134aa43efc5e9308b9256e63e172e706be..a9a32df1e78f62021e7c0732a9e43b74c87c21d8 100644 (file)
@@ -1904,3 +1904,49 @@ int fdt_overlay_apply_verbose(void *fdt, void *fdto)
        return err;
 }
 #endif
+
+/**
+ * fdt_valid() - Check if an FDT is valid. If not, change it to NULL
+ *
+ * @blobp: Pointer to FDT pointer
+ * @return 1 if OK, 0 if bad (in which case *blobp is set to NULL)
+ */
+int fdt_valid(struct fdt_header **blobp)
+{
+       const void *blob = *blobp;
+       int err;
+
+       if (!blob) {
+               printf("The address of the fdt is invalid (NULL).\n");
+               return 0;
+       }
+
+       err = fdt_check_header(blob);
+       if (err == 0)
+               return 1;       /* valid */
+
+       if (err < 0) {
+               printf("libfdt fdt_check_header(): %s", fdt_strerror(err));
+               /*
+                * Be more informative on bad version.
+                */
+               if (err == -FDT_ERR_BADVERSION) {
+                       if (fdt_version(blob) <
+                           FDT_FIRST_SUPPORTED_VERSION) {
+                               printf(" - too old, fdt %d < %d",
+                                      fdt_version(blob),
+                                      FDT_FIRST_SUPPORTED_VERSION);
+                       }
+                       if (fdt_last_comp_version(blob) >
+                           FDT_LAST_SUPPORTED_VERSION) {
+                               printf(" - too new, fdt %d > %d",
+                                      fdt_version(blob),
+                                      FDT_LAST_SUPPORTED_VERSION);
+                       }
+               }
+               printf("\n");
+               *blobp = NULL;
+               return 0;
+       }
+       return 1;
+}
index e2a4689cd8a86b5662ec6538f1bf09a9a6c067fd..1e4dbc0a8f655d2b82bbc133b97325083dea727d 100644 (file)
@@ -352,6 +352,8 @@ int fdt_setup_simplefb_node(void *fdt, int node, u64 base_address, u32 width,
 
 int fdt_overlay_apply_verbose(void *fdt, void *fdto);
 
+int fdt_valid(struct fdt_header **blobp);
+
 /**
  * fdt_get_cells_len() - Get the length of a type of cell in top-level nodes
  *