diff options
Diffstat (limited to 'drivers/of/fdt.c')
-rw-r--r-- | drivers/of/fdt.c | 41 |
1 files changed, 12 insertions, 29 deletions
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index 0121100372b4..aedd0e2dcd89 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c @@ -8,7 +8,6 @@ #define pr_fmt(fmt) "OF: fdt: " fmt -#include <linux/acpi.h> #include <linux/crash_dump.h> #include <linux/crc32.h> #include <linux/kernel.h> @@ -497,6 +496,7 @@ static void __init fdt_reserve_elfcorehdr(void) void __init early_init_fdt_scan_reserved_mem(void) { int n; + int res; u64 base, size; if (!initial_boot_params) @@ -507,7 +507,11 @@ void __init early_init_fdt_scan_reserved_mem(void) /* Process header /memreserve/ fields */ for (n = 0; ; n++) { - fdt_get_mem_rsv(initial_boot_params, n, &base, &size); + res = fdt_get_mem_rsv(initial_boot_params, n, &base, &size); + if (res) { + pr_err("Invalid memory reservation block index %d\n", n); + break; + } if (!size) break; memblock_reserve(base, size); @@ -1126,13 +1130,7 @@ void __init __weak early_init_dt_add_memory_arch(u64 base, u64 size) static void * __init early_init_dt_alloc_memory_arch(u64 size, u64 align) { - void *ptr = memblock_alloc(size, align); - - if (!ptr) - panic("%s: Failed to allocate %llu bytes align=0x%llx\n", - __func__, size, align); - - return ptr; + return memblock_alloc_or_panic(size, align); } bool __init early_init_dt_verify(void *dt_virt, phys_addr_t dt_phys) @@ -1215,14 +1213,7 @@ void __init unflatten_device_tree(void) /* Save the statically-placed regions in the reserved_mem array */ fdt_scan_reserved_mem_reg_nodes(); - /* Don't use the bootloader provided DTB if ACPI is enabled */ - if (!acpi_disabled) - fdt = NULL; - - /* - * Populate an empty root node when ACPI is enabled or bootloader - * doesn't provide one. - */ + /* Populate an empty root node when bootloader doesn't provide one */ if (!fdt) { fdt = (void *) __dtb_empty_root_begin; /* fdt_totalsize() will be used for copy size */ @@ -1264,18 +1255,9 @@ void __init unflatten_and_copy_device_tree(void) } #ifdef CONFIG_SYSFS -static ssize_t of_fdt_raw_read(struct file *filp, struct kobject *kobj, - struct bin_attribute *bin_attr, - char *buf, loff_t off, size_t count) -{ - memcpy(buf, initial_boot_params + off, count); - return count; -} - static int __init of_fdt_raw_init(void) { - static struct bin_attribute of_fdt_raw_attr = - __BIN_ATTR(fdt, S_IRUSR, of_fdt_raw_read, NULL, 0); + static __ro_after_init BIN_ATTR_SIMPLE_ADMIN_RO(fdt); if (!initial_boot_params) return 0; @@ -1285,8 +1267,9 @@ static int __init of_fdt_raw_init(void) pr_warn("not creating '/sys/firmware/fdt': CRC check failed\n"); return 0; } - of_fdt_raw_attr.size = fdt_totalsize(initial_boot_params); - return sysfs_create_bin_file(firmware_kobj, &of_fdt_raw_attr); + bin_attr_fdt.private = initial_boot_params; + bin_attr_fdt.size = fdt_totalsize(initial_boot_params); + return sysfs_create_bin_file(firmware_kobj, &bin_attr_fdt); } late_initcall(of_fdt_raw_init); #endif |