aboutsummaryrefslogtreecommitdiffstats
path: root/target
diff options
context:
space:
mode:
authorDaniel Golle <daniel@makrotopia.org>2022-03-21 23:31:38 +0000
committerDaniel Golle <daniel@makrotopia.org>2022-03-27 16:14:00 +0100
commitda13fb9742a72ce9e74b6409cc77c20a5042444d (patch)
tree4aed4a73f1c2eff0d814b394cfc94fbc74a3d2df /target
parent64fd2713a31855e25b2104c8098e10f9e6b77ef3 (diff)
downloadupstream-da13fb9742a72ce9e74b6409cc77c20a5042444d.tar.gz
upstream-da13fb9742a72ce9e74b6409cc77c20a5042444d.tar.bz2
upstream-da13fb9742a72ce9e74b6409cc77c20a5042444d.zip
kernel: generic: use chosen bootconf in FIT partition parser
If the selected boot configuration is stored by U-Boot in '/chosen' node as 'bootconf' attribute, use that configuration to resolve the block device used as rootfs. Fall back to use the default configuration in case 'bootconf' is not present. Signed-off-by: Daniel Golle <daniel@makrotopia.org> (cherry picked from commit 503f3b9f0e9693bb983a0f259aa4ba106a690140)
Diffstat (limited to 'target')
-rw-r--r--target/linux/generic/files/block/partitions/fit.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/target/linux/generic/files/block/partitions/fit.c b/target/linux/generic/files/block/partitions/fit.c
index fa73e64af8..89b5fb3454 100644
--- a/target/linux/generic/files/block/partitions/fit.c
+++ b/target/linux/generic/files/block/partitions/fit.c
@@ -87,6 +87,14 @@ int parse_fit_partitions(struct parsed_partitions *state, u64 fit_start_sector,
config_description_len, config_loadables_len;
sector_t start_sect, nr_sects;
size_t label_min;
+ struct device_node *np = NULL;
+ const char *bootconf;
+
+ np = of_find_node_by_path("/chosen");
+ if (np)
+ bootconf = of_get_property(np, "bootconf", NULL);
+ else
+ bootconf = NULL;
if (fit_start_sector % (1<<(PAGE_SHIFT - SECTOR_SHIFT)))
return -ERANGE;
@@ -144,15 +152,15 @@ int parse_fit_partitions(struct parsed_partitions *state, u64 fit_start_sector,
config_default = fdt_getprop(fit, config, FIT_DEFAULT_PROP, &config_default_len);
- if (!config_default) {
+ if (!config_default && !bootconf) {
printk(KERN_ERR "FIT: Cannot find default configuration\n");
ret = -ENOENT;
goto ret_out;
}
- node = fdt_subnode_offset(fit, config, config_default);
+ node = fdt_subnode_offset(fit, config, bootconf?:config_default);
if (node < 0) {
- printk(KERN_ERR "FIT: Cannot find %s node: %d\n", config_default, node);
+ printk(KERN_ERR "FIT: Cannot find %s node: %d\n", bootconf?:config_default, node);
ret = -ENOENT;
goto ret_out;
}
@@ -160,7 +168,8 @@ int parse_fit_partitions(struct parsed_partitions *state, u64 fit_start_sector,
config_description = fdt_getprop(fit, node, FIT_DESC_PROP, &config_description_len);
config_loadables = fdt_getprop(fit, node, FIT_LOADABLE_PROP, &config_loadables_len);
- printk(KERN_DEBUG "FIT: Default configuration: \"%s\"%s%s%s\n", config_default,
+ printk(KERN_DEBUG "FIT: %s configuration: \"%s\"%s%s%s\n",
+ bootconf?"Selected":"Default", bootconf?:config_default,
config_description?" (":"", config_description?:"", config_description?")":"");
images = fdt_path_offset(fit, FIT_IMAGES_PATH);