On 2018-09-21 18:19, Cédric Le Goater wrote: > The code looks better, it removes duplicated lines and it will ease > the introduction of common properties for the Aspeed machines. > > Signed-off-by: Cédric Le Goater <c...@kaod.org> > Reviewed-by: Philippe Mathieu-Daudé <f4...@amsat.org> > --- > include/hw/arm/aspeed.h | 46 +++++++++ > hw/arm/aspeed.c | 212 +++++++++++++--------------------------- > 2 files changed, 116 insertions(+), 142 deletions(-) > create mode 100644 include/hw/arm/aspeed.h > > diff --git a/include/hw/arm/aspeed.h b/include/hw/arm/aspeed.h > new file mode 100644 > index 000000000000..325c091d09e4 > --- /dev/null > +++ b/include/hw/arm/aspeed.h > @@ -0,0 +1,46 @@ > +/* > + * Aspeed Machines > + * > + * Copyright 2018 IBM Corp. > + * > + * This code is licensed under the GPL version 2 or later. See > + * the COPYING file in the top-level directory. > + */ > +#ifndef ARM_ASPEED_H > +#define ARM_ASPEED_H > + > +#include "hw/boards.h" > + > +typedef struct AspeedBoardState AspeedBoardState;
Hi Cédric, this patch breaks compiling with clang v3.4.2 here: CC aarch64-softmmu/hw/arm/aspeed.o hw/arm/aspeed.c:36:3: error: redefinition of typedef 'AspeedBoardState' is a C11 feature [-Werror,-Wtypedef-redefinition] } AspeedBoardState; ^ include/hw/arm/aspeed.h:14:33: note: previous definition is here typedef struct AspeedBoardState AspeedBoardState; ^ 1 error generated. make[1]: *** [hw/arm/aspeed.o] Error 1 make: *** [subdir-aarch64-softmmu] Error 2 Seems like it can be fixed like this: diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c --- a/hw/arm/aspeed.c +++ b/hw/arm/aspeed.c @@ -29,11 +29,11 @@ static struct arm_boot_info aspeed_board_binfo = { .nb_cpus = 1, }; -typedef struct AspeedBoardState { +struct AspeedBoardState { AspeedSoCState soc; MemoryRegion ram; MemoryRegion max_ram; -} AspeedBoardState; +}; ... does that look OK for you, too? > +typedef struct AspeedBoardConfig { > + const char *name; > + const char *desc; > + const char *soc_name; > + uint32_t hw_strap1; > + const char *fmc_model; > + const char *spi_model; > + uint32_t num_cs; > + void (*i2c_init)(AspeedBoardState *bmc); > +} AspeedBoardConfig; > + > +#define TYPE_ASPEED_MACHINE MACHINE_TYPE_NAME("aspeed") > +#define ASPEED_MACHINE(obj) \ > + OBJECT_CHECK(AspeedMachine, (obj), TYPE_ASPEED_MACHINE) > + > +typedef struct AspeedMachine { > + MachineState parent_obj; > +} AspeedMachine; > + > +#define ASPEED_MACHINE_CLASS(klass) \ > + OBJECT_CLASS_CHECK(AspeedMachineClass, (klass), TYPE_ASPEED_MACHINE) > +#define ASPEED_MACHINE_GET_CLASS(obj) \ > + OBJECT_GET_CLASS(AspeedMachineClass, (obj), TYPE_ASPEED_MACHINE) > + > +typedef struct AspeedMachineClass { > + MachineClass parent_obj; > + const AspeedBoardConfig *board; > +} AspeedMachineClass; > + > + > +#endif Thomas