mirror of
https://github.com/freebsd/freebsd-src
synced 2024-07-22 02:37:15 +00:00
kboot: kbootfdt: fix error handling
If we are able to open /sys/firmware/fdt, but aren't able to read it, fall back to /proc/device-tree. Remove comment that's not really true, it turns out. Sponsored by: Netflix
This commit is contained in:
parent
d75524b3fe
commit
462af7676b
|
@ -91,22 +91,21 @@ fdt_platform_load_dtb(void)
|
||||||
{
|
{
|
||||||
void *buffer;
|
void *buffer;
|
||||||
size_t buflen = 409600;
|
size_t buflen = 409600;
|
||||||
int fd;
|
int fd, err = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Should load /sys/firmware/fdt if it exists, otherwise we walk the
|
* Should load /sys/firmware/fdt if it exists, otherwise we walk the
|
||||||
* tree from /proc/device-tree. The former is much easier than the
|
* tree from /proc/device-tree. The former is much easier than the
|
||||||
* latter and also the newer interface. But as long as we support the
|
* latter and also the newer interface. But as long as we support the
|
||||||
* PS3 boot, we'll need the latter due to that kernel's age. It likely
|
* PS3 boot, we'll need the latter due to that kernel's age.
|
||||||
* would be better to script the decision between the two, but that
|
|
||||||
* turns out to be tricky...
|
|
||||||
*/
|
*/
|
||||||
buffer = malloc(buflen);
|
buffer = malloc(buflen);
|
||||||
fd = host_open("/sys/firmware/fdt", O_RDONLY, 0);
|
fd = host_open("/sys/firmware/fdt", O_RDONLY, 0);
|
||||||
if (fd != -1) {
|
if (fd >= 0) {
|
||||||
buflen = host_read(fd, buffer, buflen);
|
err = host_read(fd, buffer, buflen);
|
||||||
close(fd);
|
close(fd);
|
||||||
} else {
|
}
|
||||||
|
if (fd < 0 || err < 0) {
|
||||||
fdt_create_empty_tree(buffer, buflen);
|
fdt_create_empty_tree(buffer, buflen);
|
||||||
add_node_to_fdt(buffer, "/proc/device-tree",
|
add_node_to_fdt(buffer, "/proc/device-tree",
|
||||||
fdt_path_offset(buffer, "/"));
|
fdt_path_offset(buffer, "/"));
|
||||||
|
|
Loading…
Reference in a new issue