mirror of
https://github.com/izzy2lost/xemu.git
synced 2026-07-06 00:20:22 -07:00
hw/arm/aspeed_ast27x0-fc: Make sub-init functions return bool with errp
Refactor ast2700fc_ca35_init(), ast2700fc_ssp_init(), and ast2700fc_tsp_init() to take an Error **errp parameter and return a bool. Each function now reports failure through the error object and returns false. Signed-off-by: Jamin Lin <jamin_lin@aspeedtech.com> Reviewed-by: Cédric Le Goater <clg@redhat.com> Link: https://lore.kernel.org/qemu-devel/20250925050535.2657256-7-jamin_lin@aspeedtech.com Signed-off-by: Cédric Le Goater <clg@redhat.com>
This commit is contained in:
committed by
Cédric Le Goater
parent
8d3aaefdb3
commit
9ec30a0748
+20
-14
@@ -56,7 +56,7 @@ struct Ast2700FCState {
|
||||
#define AST2700FC_FMC_MODEL "w25q01jvq"
|
||||
#define AST2700FC_SPI_MODEL "w25q512jv"
|
||||
|
||||
static void ast2700fc_ca35_init(MachineState *machine)
|
||||
static bool ast2700fc_ca35_init(MachineState *machine, Error **errp)
|
||||
{
|
||||
Ast2700FCState *s = AST2700A1FC(machine);
|
||||
AspeedSoCState *soc;
|
||||
@@ -71,8 +71,8 @@ static void ast2700fc_ca35_init(MachineState *machine)
|
||||
memory_region_add_subregion(get_system_memory(), 0, &s->ca35_memory);
|
||||
|
||||
if (!memory_region_init_ram(&s->ca35_dram, OBJECT(&s->ca35), "ca35-dram",
|
||||
AST2700FC_BMC_RAM_SIZE, &error_abort)) {
|
||||
return;
|
||||
AST2700FC_BMC_RAM_SIZE, errp)) {
|
||||
return false;
|
||||
}
|
||||
object_property_set_link(OBJECT(&s->ca35), "memory",
|
||||
OBJECT(&s->ca35_memory), &error_abort);
|
||||
@@ -92,8 +92,8 @@ static void ast2700fc_ca35_init(MachineState *machine)
|
||||
object_property_set_int(OBJECT(&s->ca35), "hw-strap2",
|
||||
AST2700FC_HW_STRAP2, &error_abort);
|
||||
aspeed_soc_uart_set_chr(soc, ASPEED_DEV_UART12, serial_hd(0));
|
||||
if (!qdev_realize(DEVICE(&s->ca35), NULL, &error_abort)) {
|
||||
return;
|
||||
if (!qdev_realize(DEVICE(&s->ca35), NULL, errp)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -108,9 +108,11 @@ static void ast2700fc_ca35_init(MachineState *machine)
|
||||
ast2700fc_board_info.loader_start = sc->memmap[ASPEED_DEV_SDRAM];
|
||||
|
||||
arm_load_kernel(ARM_CPU(first_cpu), machine, &ast2700fc_board_info);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static void ast2700fc_ssp_init(MachineState *machine)
|
||||
static bool ast2700fc_ssp_init(MachineState *machine, Error **errp)
|
||||
{
|
||||
AspeedSoCState *soc;
|
||||
Ast2700FCState *s = AST2700A1FC(machine);
|
||||
@@ -127,12 +129,14 @@ static void ast2700fc_ssp_init(MachineState *machine)
|
||||
|
||||
soc = ASPEED_SOC(&s->ssp);
|
||||
aspeed_soc_uart_set_chr(soc, ASPEED_DEV_UART4, serial_hd(1));
|
||||
if (!qdev_realize(DEVICE(&s->ssp), NULL, &error_abort)) {
|
||||
return;
|
||||
if (!qdev_realize(DEVICE(&s->ssp), NULL, errp)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static void ast2700fc_tsp_init(MachineState *machine)
|
||||
static bool ast2700fc_tsp_init(MachineState *machine, Error **errp)
|
||||
{
|
||||
AspeedSoCState *soc;
|
||||
Ast2700FCState *s = AST2700A1FC(machine);
|
||||
@@ -149,16 +153,18 @@ static void ast2700fc_tsp_init(MachineState *machine)
|
||||
|
||||
soc = ASPEED_SOC(&s->tsp);
|
||||
aspeed_soc_uart_set_chr(soc, ASPEED_DEV_UART7, serial_hd(2));
|
||||
if (!qdev_realize(DEVICE(&s->tsp), NULL, &error_abort)) {
|
||||
return;
|
||||
if (!qdev_realize(DEVICE(&s->tsp), NULL, errp)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static void ast2700fc_init(MachineState *machine)
|
||||
{
|
||||
ast2700fc_ca35_init(machine);
|
||||
ast2700fc_ssp_init(machine);
|
||||
ast2700fc_tsp_init(machine);
|
||||
ast2700fc_ca35_init(machine, &error_abort);
|
||||
ast2700fc_ssp_init(machine, &error_abort);
|
||||
ast2700fc_tsp_init(machine, &error_abort);
|
||||
}
|
||||
|
||||
static void ast2700fc_class_init(ObjectClass *oc, const void *data)
|
||||
|
||||
Reference in New Issue
Block a user