[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 16/16] sam460ex: Make sam460ex_load_device_tree() han
From: |
David Gibson |
Subject: |
[Qemu-devel] [PULL 16/16] sam460ex: Make sam460ex_load_device_tree() handle all errors internally |
Date: |
Mon, 9 Jul 2018 17:43:50 +1000 |
sam460ex_load_device_tree() handles nearly all possible errors by simply
exiting (within helper functions and macros). It handles two early error
cases by returning an error.
There's no particular point to this, so make it handle those directly as
well, removing the need for the caller to handle a failure. As a bonus it
gives us more specific error messages.
Signed-off-by: David Gibson <address@hidden>
---
hw/ppc/sam460ex.c | 18 ++++++------------
1 file changed, 6 insertions(+), 12 deletions(-)
diff --git a/hw/ppc/sam460ex.c b/hw/ppc/sam460ex.c
index 8194f32cd3..e2b7028843 100644
--- a/hw/ppc/sam460ex.c
+++ b/hw/ppc/sam460ex.c
@@ -255,7 +255,6 @@ static int sam460ex_load_device_tree(hwaddr addr,
hwaddr initrd_size,
const char *kernel_cmdline)
{
- int ret = -1;
uint32_t mem_reg_property[] = { 0, 0, cpu_to_be32(ramsize) };
char *filename;
int fdt_size;
@@ -266,12 +265,14 @@ static int sam460ex_load_device_tree(hwaddr addr,
filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, BINARY_DEVICE_TREE_FILE);
if (!filename) {
- goto out;
+ error_report("Couldn't find dtb file `%s'", BINARY_DEVICE_TREE_FILE);
+ exit(1);
}
fdt = load_device_tree(filename, &fdt_size);
g_free(filename);
- if (fdt == NULL) {
- goto out;
+ if (!fdt) {
+ error_report("Couldn't load dtb file `%s'", filename);
+ exit(1);
}
/* Manipulate device tree in memory. */
@@ -325,11 +326,8 @@ static int sam460ex_load_device_tree(hwaddr addr,
rom_add_blob_fixed(BINARY_DEVICE_TREE_FILE, fdt, fdt_size, addr);
g_free(fdt);
- ret = fdt_size;
-
-out:
- return ret;
+ return fdt_size;
}
/* Create reset TLB entries for BookE, mapping only the flash memory. */
@@ -599,10 +597,6 @@ static void sam460ex_init(MachineState *machine)
dt_size = sam460ex_load_device_tree(FDT_ADDR, machine->ram_size,
RAMDISK_ADDR, initrd_size,
machine->kernel_cmdline);
- if (dt_size < 0) {
- error_report("couldn't load device tree");
- exit(1);
- }
boot_info->dt_base = FDT_ADDR;
boot_info->dt_size = dt_size;
--
2.17.1
- [Qemu-devel] [PULL 00/16] ppc-for-3.0 queue 20180709, David Gibson, 2018/07/09
- [Qemu-devel] [PULL 02/16] spapr/vio: quiet down the "irq" property accessors, David Gibson, 2018/07/09
- [Qemu-devel] [PULL 03/16] sm501: Implement i2c part for reading monitor EDID, David Gibson, 2018/07/09
- [Qemu-devel] [PULL 01/16] ppc: fix default VGA display for Mac machines, David Gibson, 2018/07/09
- [Qemu-devel] [PULL 11/16] target/ppc: fix build on ppc64 host, David Gibson, 2018/07/09
- [Qemu-devel] [PULL 05/16] sm501: Use values from the pitch register for 2D operations, David Gibson, 2018/07/09
- [Qemu-devel] [PULL 04/16] sm501: Perform a full update after palette change, David Gibson, 2018/07/09
- [Qemu-devel] [PULL 09/16] sm501: Set updated region dirty after 2D operation, David Gibson, 2018/07/09
- [Qemu-devel] [PULL 08/16] sm501: Fix support for non-zero frame buffer start address, David Gibson, 2018/07/09
- [Qemu-devel] [PULL 16/16] sam460ex: Make sam460ex_load_device_tree() handle all errors internally,
David Gibson <=
- [Qemu-devel] [PULL 15/16] sam460ex: Don't check for errors from qemu_fdt_*(), David Gibson, 2018/07/09
- [Qemu-devel] [PULL 07/16] sm501: Log unimplemented raster operation modes, David Gibson, 2018/07/09
- [Qemu-devel] [PULL 06/16] sm501: Implement negated destination raster operation mode, David Gibson, 2018/07/09
- [Qemu-devel] [PULL 13/16] sam460ex: Update u-boot-sam460ex firmware, David Gibson, 2018/07/09
- [Qemu-devel] [PULL 10/16] ppc440_uc: Fix a copy/paste error, David Gibson, 2018/07/09
- [Qemu-devel] [PULL 12/16] ppc: fix default VGA display for PReP machines, David Gibson, 2018/07/09
- [Qemu-devel] [PULL 14/16] sam460ex: Check for errors from libfdt functions, David Gibson, 2018/07/09
- Re: [Qemu-devel] [PULL 00/16] ppc-for-3.0 queue 20180709, Peter Maydell, 2018/07/09