]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
sandbox: Use os functions to read host device tree
authorSimon Glass <sjg@chromium.org>
Thu, 27 Feb 2014 20:25:58 +0000 (13:25 -0700)
committerSimon Glass <sjg@chromium.org>
Tue, 18 Mar 2014 02:05:45 +0000 (20:05 -0600)
At present we use U-Boot's filesystem layer to read the sandbox device tree,
but this is problematic since it relies on a temporary feauture added
there. Since we plan to implement proper block layer support for sandbox,
change this code to use the os layer functions instead. Also use the new
fdt_create_empty_tree() instead of our own code.

Signed-off-by: Simon Glass <sjg@chromium.org>
common/board_f.c
disk/part.c

index 4856975161b1b123901c399f72a290da452527a5..f285bad5388e74cc2170955b79e3a47aaf197dd5 100644 (file)
@@ -282,45 +282,39 @@ __weak int arch_cpu_init(void)
 
 #ifdef CONFIG_OF_HOSTFILE
 
 
 #ifdef CONFIG_OF_HOSTFILE
 
-#define CHECK(x)               err = (x); if (err) goto failed;
-
-/* Create an empty device tree blob */
-static int make_empty_fdt(void *fdt)
-{
-       int err;
-
-       CHECK(fdt_create(fdt, 256));
-       CHECK(fdt_finish_reservemap(fdt));
-       CHECK(fdt_begin_node(fdt, ""));
-       CHECK(fdt_end_node(fdt));
-       CHECK(fdt_finish(fdt));
-
-       return 0;
-failed:
-       printf("Unable to create empty FDT: %s\n", fdt_strerror(err));
-       return -EACCES;
-}
-
 static int read_fdt_from_file(void)
 {
        struct sandbox_state *state = state_get_current();
 static int read_fdt_from_file(void)
 {
        struct sandbox_state *state = state_get_current();
+       const char *fname = state->fdt_fname;
        void *blob;
        void *blob;
-       int size;
+       ssize_t size;
        int err;
        int err;
+       int fd;
 
        blob = map_sysmem(CONFIG_SYS_FDT_LOAD_ADDR, 0);
        if (!state->fdt_fname) {
 
        blob = map_sysmem(CONFIG_SYS_FDT_LOAD_ADDR, 0);
        if (!state->fdt_fname) {
-               err = make_empty_fdt(blob);
+               err = fdt_create_empty_tree(blob, 256);
                if (!err)
                        goto done;
                if (!err)
                        goto done;
-               return err;
+               printf("Unable to create empty FDT: %s\n", fdt_strerror(err));
+               return -EINVAL;
+       }
+
+       size = os_get_filesize(fname);
+       if (size < 0) {
+               printf("Failed to file FDT file '%s'\n", fname);
+               return -ENOENT;
+       }
+       fd = os_open(fname, OS_O_RDONLY);
+       if (fd < 0) {
+               printf("Failed to open FDT file '%s'\n", fname);
+               return -EACCES;
        }
        }
-       err = fs_set_blk_dev("host", NULL, FS_TYPE_SANDBOX);
-       if (err)
-               return err;
-       size = fs_read(state->fdt_fname, CONFIG_SYS_FDT_LOAD_ADDR, 0, 0);
-       if (size < 0)
+       if (os_read(fd, blob, size) != size) {
+               os_close(fd);
                return -EIO;
                return -EIO;
+       }
+       os_close(fd);
 
 done:
        gd->fdt_blob = blob;
 
 done:
        gd->fdt_blob = blob;
index 6941033d8d7b7850561e9cd386ce62433ab1cdcd..b8c6aac801626f165bab1bb800ccf657c5a944f4 100644 (file)
@@ -452,23 +452,6 @@ int get_device_and_partition(const char *ifname, const char *dev_part_str,
        int part;
        disk_partition_t tmpinfo;
 
        int part;
        disk_partition_t tmpinfo;
 
-       /*
-        * For now, we have a special case for sandbox, since there is no
-        * real block device support.
-        */
-       if (0 == strcmp(ifname, "host")) {
-               *dev_desc = NULL;
-               info->start = info->size =  info->blksz = 0;
-               info->bootable = 0;
-               strcpy((char *)info->type, BOOT_PART_TYPE);
-               strcpy((char *)info->name, "Sandbox host");
-#ifdef CONFIG_PARTITION_UUIDS
-               info->uuid[0] = 0;
-#endif
-
-               return 0;
-       }
-
        /* If no dev_part_str, use bootdevice environment variable */
        if (!dev_part_str || !strlen(dev_part_str) ||
            !strcmp(dev_part_str, "-"))
        /* If no dev_part_str, use bootdevice environment variable */
        if (!dev_part_str || !strlen(dev_part_str) ||
            !strcmp(dev_part_str, "-"))