]> Git Repo - J-u-boot.git/blobdiff - boot/bootmeth-uclass.c
Merge patch series "mtd: spi-nor: Remove recently added nor->addr_width == 3 test"
[J-u-boot.git] / boot / bootmeth-uclass.c
index eeded08dd428472e7987f10c714c8b19e2424c01..5b5fea39b3b3925375477ab41e2288f4ef4c7358 100644 (file)
@@ -6,7 +6,6 @@
 
 #define LOG_CATEGORY UCLASS_BOOTSTD
 
-#include <common.h>
 #include <blk.h>
 #include <bootflow.h>
 #include <bootmeth.h>
@@ -61,6 +60,18 @@ int bootmeth_set_bootflow(struct udevice *dev, struct bootflow *bflow,
        return ops->set_bootflow(dev, bflow, buf, size);
 }
 
+#if CONFIG_IS_ENABLED(BOOTSTD_FULL)
+int bootmeth_read_all(struct udevice *dev, struct bootflow *bflow)
+{
+       const struct bootmeth_ops *ops = bootmeth_get_ops(dev);
+
+       if (!ops->read_all)
+               return -ENOSYS;
+
+       return ops->read_all(dev, bflow);
+}
+#endif /* BOOTSTD_FULL */
+
 int bootmeth_boot(struct udevice *dev, struct bootflow *bflow)
 {
        const struct bootmeth_ops *ops = bootmeth_get_ops(dev);
@@ -240,18 +251,32 @@ int bootmeth_set_order(const char *order_str)
        return 0;
 }
 
-/**
- * setup_fs() - Set up read to read a file
- *
- * We must redo the setup before each filesystem operation. This function
- * handles that, including setting the filesystem type if a block device is not
- * being used
- *
- * @bflow: Information about file to try
- * @desc: Block descriptor to read from (NULL if not a block device)
- * Return: 0 if OK, -ve on error
- */
-static int setup_fs(struct bootflow *bflow, struct blk_desc *desc)
+int bootmeth_set_property(const char *name, const char *property, const char *value)
+{
+       int ret;
+       int len;
+       struct udevice *dev;
+       const struct bootmeth_ops *ops;
+
+       len = strlen(name);
+
+       ret = uclass_find_device_by_namelen(UCLASS_BOOTMETH, name, len,
+                                           &dev);
+       if (ret) {
+               printf("Unknown bootmeth '%s'\n", name);
+               return ret;
+       }
+
+       ops = bootmeth_get_ops(dev);
+       if (!ops->set_property) {
+               printf("set_property not found\n");
+               return -ENODEV;
+       }
+
+       return ops->set_property(dev, property, value);
+}
+
+int bootmeth_setup_fs(struct bootflow *bflow, struct blk_desc *desc)
 {
        int ret;
 
@@ -288,7 +313,7 @@ int bootmeth_try_file(struct bootflow *bflow, struct blk_desc *desc,
        log_debug("   %s - err=%d\n", path, ret);
 
        /* Sadly FS closes the file after fs_size() so we must redo this */
-       ret2 = setup_fs(bflow, desc);
+       ret2 = bootmeth_setup_fs(bflow, desc);
        if (ret2)
                return log_msg_ret("fs", ret2);
 
@@ -337,14 +362,14 @@ int bootmeth_alloc_other(struct bootflow *bflow, const char *fname,
        if (bflow->blk)
                desc = dev_get_uclass_plat(bflow->blk);
 
-       ret = setup_fs(bflow, desc);
+       ret = bootmeth_setup_fs(bflow, desc);
        if (ret)
                return log_msg_ret("fs", ret);
 
        ret = fs_size(path, &size);
        log_debug("   %s - err=%d\n", path, ret);
 
-       ret = setup_fs(bflow, desc);
+       ret = bootmeth_setup_fs(bflow, desc);
        if (ret)
                return log_msg_ret("fs", ret);
 
@@ -369,7 +394,7 @@ int bootmeth_common_read_file(struct udevice *dev, struct bootflow *bflow,
        if (bflow->blk)
                desc = dev_get_uclass_plat(bflow->blk);
 
-       ret = setup_fs(bflow, desc);
+       ret = bootmeth_setup_fs(bflow, desc);
        if (ret)
                return log_msg_ret("fs", ret);
 
@@ -379,7 +404,7 @@ int bootmeth_common_read_file(struct udevice *dev, struct bootflow *bflow,
        if (size > *sizep)
                return log_msg_ret("spc", -ENOSPC);
 
-       ret = setup_fs(bflow, desc);
+       ret = bootmeth_setup_fs(bflow, desc);
        if (ret)
                return log_msg_ret("fs", ret);
 
This page took 0.027717 seconds and 4 git commands to generate.