]> Git Repo - J-u-boot.git/blobdiff - boot/bootflow.c
Merge patch series "mtd: spi-nor: Add support for S25FS-S family"
[J-u-boot.git] / boot / bootflow.c
index e03932e65a74e1a1ecdef0b2ec382a70a238ca27..59d77d2385f4e566911cab792a850319cf16864d 100644 (file)
@@ -6,7 +6,6 @@
 
 #define LOG_CATEGORY UCLASS_BOOTSTD
 
-#include <common.h>
 #include <bootdev.h>
 #include <bootflow.h>
 #include <bootmeth.h>
@@ -155,6 +154,27 @@ static void bootflow_iter_set_dev(struct bootflow_iter *iter,
        }
 }
 
+/**
+ * scan_next_in_uclass() - Scan for the next bootdev in the same media uclass
+ *
+ * Move through the following bootdevs until we find another in this media
+ * uclass, or run out
+ *
+ * @devp: On entry, the device to check, on exit the new device, or NULL if
+ * there is none
+ */
+static void scan_next_in_uclass(struct udevice **devp)
+{
+       struct udevice *dev = *devp;
+       enum uclass_id cur_id = device_get_uclass_id(dev->parent);
+
+       do {
+               uclass_find_next_device(&dev);
+       } while (dev && cur_id != device_get_uclass_id(dev->parent));
+
+       *devp = dev;
+}
+
 /**
  * iter_incr() - Move to the next item (method, part, bootdev)
  *
@@ -196,6 +216,9 @@ static int iter_incr(struct bootflow_iter *iter)
                }
        }
 
+       if (iter->flags & BOOTFLOWIF_SINGLE_PARTITION)
+               return BF_NO_MORE_DEVICES;
+
        /* No more bootmeths; start at the first one, and... */
        iter->cur_method = 0;
        iter->method = iter->method_order[iter->cur_method];
@@ -230,8 +253,7 @@ static int iter_incr(struct bootflow_iter *iter)
                                                 &method_flags);
                } else if (IS_ENABLED(CONFIG_BOOTSTD_FULL) &&
                           (iter->flags & BOOTFLOWIF_SINGLE_UCLASS)) {
-                       /* Move to the next bootdev in this uclass */
-                       uclass_find_next_device(&dev);
+                       scan_next_in_uclass(&dev);
                        if (!dev) {
                                log_debug("finished uclass %s\n",
                                          dev_get_uclass_name(dev));
@@ -266,8 +288,9 @@ static int iter_incr(struct bootflow_iter *iter)
                                 * bootdev_find_by_label() where this flag is
                                 * set up
                                 */
-                               if (iter->method_flags & BOOTFLOW_METHF_SINGLE_UCLASS) {
-                                       uclass_next_device(&dev);
+                               if (iter->method_flags &
+                                   BOOTFLOW_METHF_SINGLE_UCLASS) {
+                                       scan_next_in_uclass(&dev);
                                        log_debug("looking for next device %s: %s\n",
                                                  iter->dev->name,
                                                  dev ? dev->name : "<none>");
@@ -340,7 +363,7 @@ static int bootflow_check(struct bootflow_iter *iter, struct bootflow *bflow)
        }
 
        /* Unless there is nothing more to try, move to the next device */
-       else if (ret != BF_NO_MORE_PARTS && ret != -ENOSYS) {
+       if (ret != BF_NO_MORE_PARTS && ret != -ENOSYS) {
                log_debug("Bootdev '%s' part %d method '%s': Error %d\n",
                          dev->name, iter->part, iter->method->name, ret);
                /*
@@ -350,10 +373,8 @@ static int bootflow_check(struct bootflow_iter *iter, struct bootflow *bflow)
                if (iter->flags & BOOTFLOWIF_ALL)
                        return log_msg_ret("all", ret);
        }
-       if (ret)
-               return log_msg_ret("check", ret);
 
-       return 0;
+       return log_msg_ret("check", ret);
 }
 
 int bootflow_scan_first(struct udevice *dev, const char *label,
@@ -446,7 +467,8 @@ void bootflow_free(struct bootflow *bflow)
        free(bflow->name);
        free(bflow->subdir);
        free(bflow->fname);
-       free(bflow->buf);
+       if (!(bflow->flags & BOOTFLOWF_STATIC_BUF))
+               free(bflow->buf);
        free(bflow->os_name);
        free(bflow->fdt_fname);
        free(bflow->bootmeth_priv);
@@ -553,6 +575,18 @@ int bootflow_iter_check_blk(const struct bootflow_iter *iter)
        return -ENOTSUPP;
 }
 
+int bootflow_iter_check_mmc(const struct bootflow_iter *iter)
+{
+       const struct udevice *media = dev_get_parent(iter->dev);
+       enum uclass_id id = device_get_uclass_id(media);
+
+       log_debug("uclass %d: %s\n", id, uclass_get_name(id));
+       if (id == UCLASS_MMC)
+               return 0;
+
+       return -ENOTSUPP;
+}
+
 int bootflow_iter_check_sf(const struct bootflow_iter *iter)
 {
        const struct udevice *media = dev_get_parent(iter->dev);
@@ -731,7 +765,7 @@ int cmdline_set_arg(char *buf, int maxlen, const char *cmdline,
                                        in_quote = false;
                                continue;
                        }
-                       if (*p == '=') {
+                       if (*p == '=' && !arg_end) {
                                arg_end = p;
                                val = p + 1;
                        } else if (*p == '"') {
@@ -767,7 +801,8 @@ int cmdline_set_arg(char *buf, int maxlen, const char *cmdline,
                }
 
                /* if this is the target arg, update it */
-               if (!strncmp(from, set_arg, arg_end - from)) {
+               if (arg_end - from == set_arg_len &&
+                   !strncmp(from, set_arg, set_arg_len)) {
                        if (!buf) {
                                bool has_quote = val_end[-1] == '"';
 
This page took 0.030271 seconds and 4 git commands to generate.