On Mon, 18 May 2026 at 08:34, Corvin Köhne <[email protected]> wrote:
>
> From: YannickV <[email protected]>
>
> Introduce ZynqMachineClass with qspi_flash_type field to allow
> different Zynq-based machines to specify their flash device
> type. The base Zynq machine defaults to n25q128.
>
> Signed-off-by: YannickV <[email protected]>
> @@ -152,7 +153,11 @@ static inline int zynq_init_spi_flashes(uint32_t
> base_addr, qemu_irq irq,
>
> for (j = 0; j < num_ss; ++j) {
> DriveInfo *dinfo = drive_get(IF_MTD, 0, unit++);
> - flash_dev = qdev_new("n25q128");
> +
> + if (!flash_type || !flash_type[0]) {
> + flash_type = "n25q128";
> + }
This seems a bit unnecessary -- we always pass in
zmc->qspi_flash_type at all the callsites, and that should
never be NULL or an empty string, because we've already done
the "what should the default type be?" handling in
zynq_machine_class_init().
If we do get NULL or an empty string here, that's a QEMU bug
in either this class or its subclasses, which will be fairly
quickly detected when we pass the bogus value to qdev_new().
I would just drop this if().
> +struct ZynqMachineClass {
> + MachineClass parent_class;
> + const char *qspi_flash_type;
> +};
Because we've now given this class its own class struct,
we need to add to the zynq_machine_type TypeInfo:
.class_size = sizeof(ZynqMachineClass),
Otherwise the QOM machinery won't allocate enough space for it.
thanks
-- PMM