diff options
Diffstat (limited to 'common/blspec.c')
-rw-r--r-- | common/blspec.c | 60 |
1 files changed, 25 insertions, 35 deletions
diff --git a/common/blspec.c b/common/blspec.c index 9bb25ee721..23a24c63db 100644 --- a/common/blspec.c +++ b/common/blspec.c @@ -88,7 +88,7 @@ static int blspec_boot(struct bootentry *be, int verbose, int dryrun) bootm_data_init_defaults(&data); - data.verbose = verbose || data.verbose; + data.verbose = max(verbose, data.verbose); devicetree = blspec_entry_var_get(entry, "devicetree"); initrd = blspec_entry_var_get(entry, "initrd"); @@ -316,7 +316,7 @@ static int blspec_have_entry(struct bootentries *bootentries, const char *path) */ static const char *nfs_find_mountpath(const char *nfshostpath) { - struct fs_device_d *fsdev; + struct fs_device *fsdev; for_each_fs_device(fsdev) { if (fsdev->backingstore && !strcmp(fsdev->backingstore, nfshostpath)) @@ -341,10 +341,10 @@ static char *parse_nfs_url(const char *url) int ret; if (!IS_ENABLED(CONFIG_FS_NFS)) - return ERR_PTR(-ENOSYS); + return NULL; if (strncmp(url, "nfs://", 6)) - return ERR_PTR(-EINVAL); + return NULL; url += 6; @@ -413,7 +413,7 @@ out: if (ret) free(mountpath); - return ret ? ERR_PTR(ret) : mountpath; + return ret ? NULL : mountpath; } /* @@ -426,10 +426,10 @@ static bool entry_is_of_compatible(struct blspec_entry *entry) { const char *devicetree; const char *abspath; - size_t size; - void *fdt = NULL; int ret; - struct device_node *root = NULL, *barebox_root; + struct device_node *barebox_root; + size_t size; + void *fdt; const char *compat; char *filename; @@ -459,33 +459,22 @@ static bool entry_is_of_compatible(struct blspec_entry *entry) fdt = read_file(filename, &size); if (!fdt) { - pr_err("Cannot read: %s\n", filename); - ret = false; - goto out; - } - - root = of_unflatten_dtb(fdt, size); - if (IS_ERR(root)) { ret = false; - root = NULL; goto out; } - if (of_device_is_compatible(root, compat)) { + if (fdt_machine_is_compatible(fdt, size, compat)) { ret = true; goto out; } - pr_info("ignoring entry with incompatible devicetree \"%s\"\n", - (char *)of_get_property(root, "compatible", NULL)); + pr_info("ignoring entry with incompatible devicetree: %s\n", devicetree); ret = false; out: - if (root) - of_delete_node(root); - free(filename); free(fdt); + free(filename); return ret; } @@ -622,7 +611,7 @@ err_out: */ static int blspec_scan_ubi(struct bootentries *bootentries, struct cdev *cdev) { - struct device_d *child; + struct device *child; int ret, found = 0; pr_debug("%s: %s\n", __func__, cdev->name); @@ -677,9 +666,7 @@ static int blspec_scan_cdev(struct bootentries *bootentries, struct cdev *cdev) found += ret; } - rootpath = cdev_get_mount_path(cdev); - if (!rootpath) - rootpath = cdev_mount_default(cdev, NULL); + rootpath = cdev_mount(cdev); if (!IS_ERR(rootpath)) { ret = blspec_scan_directory(bootentries, rootpath); if (ret > 0) @@ -698,7 +685,7 @@ static int blspec_scan_cdev(struct bootentries *bootentries, struct cdev *cdev) */ int blspec_scan_devices(struct bootentries *bootentries) { - struct device_d *dev; + struct device *dev; struct block_device *bdev; int ret, found = 0; @@ -726,9 +713,9 @@ int blspec_scan_devices(struct bootentries *bootentries) * Returns the number of entries found or a negative error code if some unexpected * error occurred. */ -int blspec_scan_device(struct bootentries *bootentries, struct device_d *dev) +int blspec_scan_device(struct bootentries *bootentries, struct device *dev) { - struct device_d *child; + struct device *child; struct cdev *cdev; int ret, found = 0; @@ -742,7 +729,7 @@ int blspec_scan_device(struct bootentries *bootentries, struct device_d *dev) * partition with the MBR type id of 0xEA already exists it * should be used as $BOOT */ - if (cdev->dos_partition_type == 0xea) { + if (cdev_is_mbr_partitioned(cdev->master) && cdev->dos_partition_type == 0xea) { ret = blspec_scan_cdev(bootentries, cdev); if (ret == 0) ret = -ENOENT; @@ -790,11 +777,14 @@ int blspec_scan_device(struct bootentries *bootentries, struct device_d *dev) */ int blspec_scan_devicename(struct bootentries *bootentries, const char *devname) { - struct device_d *dev; + struct device *dev; struct cdev *cdev; pr_debug("%s: %s\n", __func__, devname); + /* Support both boot /dev/disk0.rootfs and boot disk0.rootfs */ + devname += str_has_prefix(devname, "/dev/"); + device_detect_by_name(devname); cdev = cdev_by_name(devname); @@ -824,12 +814,12 @@ static int blspec_bootentry_provider(struct bootentries *bootentries, if (*name == '/' || !strncmp(name, "nfs://", 6)) { char *nfspath = parse_nfs_url(name); - if (!IS_ERR(nfspath)) + if (nfspath) name = nfspath; ret = stat(name, &s); if (ret) - return found; + goto out; if (S_ISDIR(s.st_mode)) ret = blspec_scan_directory(bootentries, name); @@ -838,8 +828,8 @@ static int blspec_bootentry_provider(struct bootentries *bootentries, if (ret > 0) found += ret; - if (!IS_ERR(nfspath)) - free(nfspath); +out: + free(nfspath); } return found; |