mirror of
https://github.com/Fishwaldo/u-boot.git
synced 2025-03-27 17:41:34 +00:00
Fine grained per property /chosen updating.
Implement a suggestion by Scott Wood to make the /chosen handling fine grained. Don't overwrite pre-existing properties on a per-property basis, so if /chosen exists but a necessary /chosen/property doesn't, it gets created. If a /chosen property exists, it is NOT overwritten unless the "force" flag is true. Signed-off-by: Gerald Van Baren <vanbaren@cideas.com>
This commit is contained in:
parent
238cb7a423
commit
b60af3d4c1
1 changed files with 40 additions and 33 deletions
|
@ -111,6 +111,7 @@ int fdt_chosen(void *fdt, ulong initrd_start, ulong initrd_end, int force)
|
||||||
int err;
|
int err;
|
||||||
u32 tmp; /* used to set 32 bit integer properties */
|
u32 tmp; /* used to set 32 bit integer properties */
|
||||||
char *str; /* used to set string properties */
|
char *str; /* used to set string properties */
|
||||||
|
const char *path;
|
||||||
|
|
||||||
err = fdt_check_header(fdt);
|
err = fdt_check_header(fdt);
|
||||||
if (err < 0) {
|
if (err < 0) {
|
||||||
|
@ -148,14 +149,7 @@ int fdt_chosen(void *fdt, ulong initrd_start, ulong initrd_end, int force)
|
||||||
nodeoffset = fdt_path_offset (fdt, "/chosen");
|
nodeoffset = fdt_path_offset (fdt, "/chosen");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If we have a "chosen" node already the "force the writing"
|
* If there is no "chosen" node in the blob, create it.
|
||||||
* is not set, our job is done.
|
|
||||||
*/
|
|
||||||
if ((nodeoffset >= 0) && !force)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* No "chosen" node in the blob: create it.
|
|
||||||
*/
|
*/
|
||||||
if (nodeoffset < 0) {
|
if (nodeoffset < 0) {
|
||||||
/*
|
/*
|
||||||
|
@ -170,42 +164,55 @@ int fdt_chosen(void *fdt, ulong initrd_start, ulong initrd_end, int force)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Update pre-existing properties, create them if non-existant.
|
* Create /chosen properites that don't exist in the fdt.
|
||||||
|
* If the property exists, update it only if the "force" parameter
|
||||||
|
* is true.
|
||||||
*/
|
*/
|
||||||
str = getenv("bootargs");
|
str = getenv("bootargs");
|
||||||
if (str != NULL) {
|
if (str != NULL) {
|
||||||
err = fdt_setprop(fdt, nodeoffset,
|
path = fdt_getprop(fdt, nodeoffset, "bootargs", NULL);
|
||||||
"bootargs", str, strlen(str)+1);
|
if ((path == NULL) || force) {
|
||||||
if (err < 0)
|
err = fdt_setprop(fdt, nodeoffset,
|
||||||
printf("WARNING: could not set bootargs %s.\n",
|
"bootargs", str, strlen(str)+1);
|
||||||
fdt_strerror(err));
|
if (err < 0)
|
||||||
|
printf("WARNING: could not set bootargs %s.\n",
|
||||||
|
fdt_strerror(err));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (initrd_start && initrd_end) {
|
if (initrd_start && initrd_end) {
|
||||||
tmp = __cpu_to_be32(initrd_start);
|
path = fdt_getprop(fdt, nodeoffset, "linux,initrd-start", NULL);
|
||||||
err = fdt_setprop(fdt, nodeoffset,
|
if ((path == NULL) || force) {
|
||||||
"linux,initrd-start", &tmp, sizeof(tmp));
|
tmp = __cpu_to_be32(initrd_start);
|
||||||
if (err < 0)
|
err = fdt_setprop(fdt, nodeoffset,
|
||||||
printf("WARNING: "
|
"linux,initrd-start", &tmp, sizeof(tmp));
|
||||||
"could not set linux,initrd-start %s.\n",
|
if (err < 0)
|
||||||
fdt_strerror(err));
|
printf("WARNING: "
|
||||||
tmp = __cpu_to_be32(initrd_end);
|
"could not set linux,initrd-start %s.\n",
|
||||||
err = fdt_setprop(fdt, nodeoffset,
|
fdt_strerror(err));
|
||||||
"linux,initrd-end", &tmp, sizeof(tmp));
|
tmp = __cpu_to_be32(initrd_end);
|
||||||
if (err < 0)
|
err = fdt_setprop(fdt, nodeoffset,
|
||||||
printf("WARNING: could not set linux,initrd-end %s.\n",
|
"linux,initrd-end", &tmp, sizeof(tmp));
|
||||||
fdt_strerror(err));
|
if (err < 0)
|
||||||
|
printf("WARNING: could not set linux,initrd-end %s.\n",
|
||||||
|
fdt_strerror(err));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_OF_STDOUT_VIA_ALIAS
|
#ifdef CONFIG_OF_STDOUT_VIA_ALIAS
|
||||||
err = fdt_fixup_stdout(fdt, nodeoffset);
|
path = fdt_getprop(fdt, nodeoffset, "linux,stdout-path", NULL);
|
||||||
|
if ((path == NULL) || force)
|
||||||
|
err = fdt_fixup_stdout(fdt, nodeoffset);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef OF_STDOUT_PATH
|
#ifdef OF_STDOUT_PATH
|
||||||
err = fdt_setprop(fdt, nodeoffset,
|
path = fdt_getprop(fdt, nodeoffset, "linux,stdout-path", NULL);
|
||||||
"linux,stdout-path", OF_STDOUT_PATH, strlen(OF_STDOUT_PATH)+1);
|
if ((path == NULL) || force) {
|
||||||
if (err < 0)
|
err = fdt_setprop(fdt, nodeoffset,
|
||||||
printf("WARNING: could not set linux,stdout-path %s.\n",
|
"linux,stdout-path", OF_STDOUT_PATH, strlen(OF_STDOUT_PATH)+1);
|
||||||
fdt_strerror(err));
|
if (err < 0)
|
||||||
|
printf("WARNING: could not set linux,stdout-path %s.\n",
|
||||||
|
fdt_strerror(err));
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
|
|
Loading…
Add table
Reference in a new issue