[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 22/55] ssi: Convert uses of ssi_create_slave_no_init() with C
From: |
Alistair Francis |
Subject: |
Re: [PATCH 22/55] ssi: Convert uses of ssi_create_slave_no_init() with Coccinelle |
Date: |
Tue, 19 May 2020 14:07:17 -0700 |
On Tue, May 19, 2020 at 8:19 AM Markus Armbruster <address@hidden> wrote:
>
> Replace
>
> dev = ssi_create_slave_no_init(bus, type_name);
> ...
> qdev_init_nofail(dev);
>
> by
>
> dev = qdev_new(type_name);
> ...
> qdev_realize_and_unref(dev, bus, &error_fatal);
>
> Recent commit "qdev: New qdev_new(), qdev_realize(), etc." explains
> why.
>
> @@
> type SSIBus;
> identifier bus;
> expression dev, qbus, expr;
> expression list args;
> @@
> - bus = (SSIBus *)qbus;
> + bus = qbus; // TODO fix up decl
> ...
> - dev = ssi_create_slave_no_init(bus, args);
> + dev = qdev_new(args);
> ... when != dev = expr
> - qdev_init_nofail(dev);
> + qdev_realize_and_unref(dev, bus, &error_fatal);
>
> @@
> expression dev, bus, expr;
> expression list args;
> @@
> - dev = ssi_create_slave_no_init(bus, args);
> + dev = qdev_new(args);
> ... when != dev = expr
> - qdev_init_nofail(dev);
> + qdev_realize_and_unref(dev, BUS(bus), &error_fatal);
>
> Bus declarations fixed up manually.
>
> Cc: Alistair Francis <address@hidden>
> Signed-off-by: Markus Armbruster <address@hidden>
Reviewed-by: Alistair Francis <address@hidden>
Alistair
> ---
> hw/arm/aspeed.c | 4 ++--
> hw/arm/msf2-som.c | 8 ++++----
> hw/arm/sabrelite.c | 4 ++--
> hw/arm/xilinx_zynq.c | 4 ++--
> hw/arm/xlnx-zcu102.c | 16 ++++++++--------
> hw/microblaze/petalogix_ml605_mmu.c | 4 ++--
> 6 files changed, 20 insertions(+), 20 deletions(-)
>
> diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
> index c425c01e06..adbfbbd6b4 100644
> --- a/hw/arm/aspeed.c
> +++ b/hw/arm/aspeed.c
> @@ -225,12 +225,12 @@ static void aspeed_board_init_flashes(AspeedSMCState
> *s, const char *flashtype,
> DriveInfo *dinfo = drive_get_next(IF_MTD);
> qemu_irq cs_line;
>
> - fl->flash = ssi_create_slave_no_init(s->spi, flashtype);
> + fl->flash = qdev_new(flashtype);
> if (dinfo) {
> qdev_prop_set_drive(fl->flash, "drive",
> blk_by_legacy_dinfo(dinfo),
> errp);
> }
> - qdev_init_nofail(fl->flash);
> + qdev_realize_and_unref(fl->flash, BUS(s->spi), &error_fatal);
>
> cs_line = qdev_get_gpio_in_named(fl->flash, SSI_GPIO_CS, 0);
> sysbus_connect_irq(SYS_BUS_DEVICE(s), i + 1, cs_line);
> diff --git a/hw/arm/msf2-som.c b/hw/arm/msf2-som.c
> index e398703742..ca9cbe1acb 100644
> --- a/hw/arm/msf2-som.c
> +++ b/hw/arm/msf2-som.c
> @@ -47,7 +47,7 @@ static void emcraft_sf2_s2s010_init(MachineState *machine)
> MachineClass *mc = MACHINE_GET_CLASS(machine);
> DriveInfo *dinfo = drive_get_next(IF_MTD);
> qemu_irq cs_line;
> - SSIBus *spi_bus;
> + BusState *spi_bus;
> MemoryRegion *sysmem = get_system_memory();
> MemoryRegion *ddr = g_new(MemoryRegion, 1);
>
> @@ -82,14 +82,14 @@ static void emcraft_sf2_s2s010_init(MachineState *machine)
> soc = MSF2_SOC(dev);
>
> /* Attach SPI flash to SPI0 controller */
> - spi_bus = (SSIBus *)qdev_get_child_bus(dev, "spi0");
> - spi_flash = ssi_create_slave_no_init(spi_bus, "s25sl12801");
> + spi_bus = qdev_get_child_bus(dev, "spi0");
> + spi_flash = qdev_new("s25sl12801");
> qdev_prop_set_uint8(spi_flash, "spansion-cr2nv", 1);
> if (dinfo) {
> qdev_prop_set_drive(spi_flash, "drive", blk_by_legacy_dinfo(dinfo),
> &error_fatal);
> }
> - qdev_init_nofail(spi_flash);
> + qdev_realize_and_unref(spi_flash, spi_bus, &error_fatal);
> cs_line = qdev_get_gpio_in_named(spi_flash, SSI_GPIO_CS, 0);
> sysbus_connect_irq(SYS_BUS_DEVICE(&soc->spi[0]), 1, cs_line);
>
> diff --git a/hw/arm/sabrelite.c b/hw/arm/sabrelite.c
> index 6f0e233d77..dfd6643822 100644
> --- a/hw/arm/sabrelite.c
> +++ b/hw/arm/sabrelite.c
> @@ -80,13 +80,13 @@ static void sabrelite_init(MachineState *machine)
> qemu_irq cs_line;
> DriveInfo *dinfo = drive_get_next(IF_MTD);
>
> - flash_dev = ssi_create_slave_no_init(spi_bus, "sst25vf016b");
> + flash_dev = qdev_new("sst25vf016b");
> if (dinfo) {
> qdev_prop_set_drive(flash_dev, "drive",
> blk_by_legacy_dinfo(dinfo),
> &error_fatal);
> }
> - qdev_init_nofail(flash_dev);
> + qdev_realize_and_unref(flash_dev, BUS(spi_bus),
> &error_fatal);
>
> cs_line = qdev_get_gpio_in_named(flash_dev, SSI_GPIO_CS, 0);
> sysbus_connect_irq(SYS_BUS_DEVICE(spi_dev), 1, cs_line);
> diff --git a/hw/arm/xilinx_zynq.c b/hw/arm/xilinx_zynq.c
> index 5fbd2b2e31..0e0f0976c4 100644
> --- a/hw/arm/xilinx_zynq.c
> +++ b/hw/arm/xilinx_zynq.c
> @@ -157,12 +157,12 @@ static inline void zynq_init_spi_flashes(uint32_t
> base_addr, qemu_irq irq,
>
> for (j = 0; j < num_ss; ++j) {
> DriveInfo *dinfo = drive_get_next(IF_MTD);
> - flash_dev = ssi_create_slave_no_init(spi, "n25q128");
> + flash_dev = qdev_new("n25q128");
> if (dinfo) {
> qdev_prop_set_drive(flash_dev, "drive",
> blk_by_legacy_dinfo(dinfo),
> &error_fatal);
> }
> - qdev_init_nofail(flash_dev);
> + qdev_realize_and_unref(flash_dev, BUS(spi), &error_fatal);
>
> cs_line = qdev_get_gpio_in_named(flash_dev, SSI_GPIO_CS, 0);
> sysbus_connect_irq(busdev, i * num_ss + j + 1, cs_line);
> diff --git a/hw/arm/xlnx-zcu102.c b/hw/arm/xlnx-zcu102.c
> index 4229b2d936..77c84b82ab 100644
> --- a/hw/arm/xlnx-zcu102.c
> +++ b/hw/arm/xlnx-zcu102.c
> @@ -149,21 +149,21 @@ static void xlnx_zcu102_init(MachineState *machine)
> }
>
> for (i = 0; i < XLNX_ZYNQMP_NUM_SPIS; i++) {
> - SSIBus *spi_bus;
> + BusState *spi_bus;
> DeviceState *flash_dev;
> qemu_irq cs_line;
> DriveInfo *dinfo = drive_get_next(IF_MTD);
> gchar *bus_name = g_strdup_printf("spi%d", i);
>
> - spi_bus = (SSIBus *)qdev_get_child_bus(DEVICE(&s->soc), bus_name);
> + spi_bus = qdev_get_child_bus(DEVICE(&s->soc), bus_name);
> g_free(bus_name);
>
> - flash_dev = ssi_create_slave_no_init(spi_bus, "sst25wf080");
> + flash_dev = qdev_new("sst25wf080");
> if (dinfo) {
> qdev_prop_set_drive(flash_dev, "drive",
> blk_by_legacy_dinfo(dinfo),
> &error_fatal);
> }
> - qdev_init_nofail(flash_dev);
> + qdev_realize_and_unref(flash_dev, spi_bus, &error_fatal);
>
> cs_line = qdev_get_gpio_in_named(flash_dev, SSI_GPIO_CS, 0);
>
> @@ -171,22 +171,22 @@ static void xlnx_zcu102_init(MachineState *machine)
> }
>
> for (i = 0; i < XLNX_ZYNQMP_NUM_QSPI_FLASH; i++) {
> - SSIBus *spi_bus;
> + BusState *spi_bus;
> DeviceState *flash_dev;
> qemu_irq cs_line;
> DriveInfo *dinfo = drive_get_next(IF_MTD);
> int bus = i / XLNX_ZYNQMP_NUM_QSPI_BUS_CS;
> gchar *bus_name = g_strdup_printf("qspi%d", bus);
>
> - spi_bus = (SSIBus *)qdev_get_child_bus(DEVICE(&s->soc), bus_name);
> + spi_bus = qdev_get_child_bus(DEVICE(&s->soc), bus_name);
> g_free(bus_name);
>
> - flash_dev = ssi_create_slave_no_init(spi_bus, "n25q512a11");
> + flash_dev = qdev_new("n25q512a11");
> if (dinfo) {
> qdev_prop_set_drive(flash_dev, "drive",
> blk_by_legacy_dinfo(dinfo),
> &error_fatal);
> }
> - qdev_init_nofail(flash_dev);
> + qdev_realize_and_unref(flash_dev, spi_bus, &error_fatal);
>
> cs_line = qdev_get_gpio_in_named(flash_dev, SSI_GPIO_CS, 0);
>
> diff --git a/hw/microblaze/petalogix_ml605_mmu.c
> b/hw/microblaze/petalogix_ml605_mmu.c
> index 2e7a3fa119..d4bfa233c9 100644
> --- a/hw/microblaze/petalogix_ml605_mmu.c
> +++ b/hw/microblaze/petalogix_ml605_mmu.c
> @@ -186,12 +186,12 @@ petalogix_ml605_init(MachineState *machine)
> DriveInfo *dinfo = drive_get_next(IF_MTD);
> qemu_irq cs_line;
>
> - dev = ssi_create_slave_no_init(spi, "n25q128");
> + dev = qdev_new("n25q128");
> if (dinfo) {
> qdev_prop_set_drive(dev, "drive", blk_by_legacy_dinfo(dinfo),
> &error_fatal);
> }
> - qdev_init_nofail(dev);
> + qdev_realize_and_unref(dev, BUS(spi), &error_fatal);
>
> cs_line = qdev_get_gpio_in_named(dev, SSI_GPIO_CS, 0);
> sysbus_connect_irq(busdev, i+1, cs_line);
> --
> 2.21.1
>
>
- Re: [PATCH 25/55] usb: New usb_new(), usb_realize_and_unref(), (continued)
- [PATCH 51/55] qdev: Make qdev_realize() support bus-less devices, Markus Armbruster, 2020/05/19
- [PATCH 47/55] sysbus: Convert qdev_set_parent_bus() use with Coccinelle, part 3, Markus Armbruster, 2020/05/19
- [PATCH 26/55] usb: Convert uses of usb_create(), Markus Armbruster, 2020/05/19
- [PATCH 35/55] macio: Convert use of qdev_set_parent_bus(), Markus Armbruster, 2020/05/19
- [PATCH 36/55] macio: Eliminate macio_init_child_obj(), Markus Armbruster, 2020/05/19
- [PATCH 42/55] sysbus: New sysbus_realize(), sysbus_realize_and_unref(), Markus Armbruster, 2020/05/19
- [PATCH 22/55] ssi: Convert uses of ssi_create_slave_no_init() with Coccinelle, Markus Armbruster, 2020/05/19
- Re: [PATCH 22/55] ssi: Convert uses of ssi_create_slave_no_init() with Coccinelle,
Alistair Francis <=
- [PATCH 27/55] usb: usb_create() is now unused, drop, Markus Armbruster, 2020/05/19
- [PATCH 45/55] sysbus: Convert qdev_set_parent_bus() use with Coccinelle, part 1, Markus Armbruster, 2020/05/19
- [PATCH 53/55] qdev: Convert bus-less devices to qdev_realize() with Coccinelle, Markus Armbruster, 2020/05/19
- [PATCH 08/55] qdev: Convert uses of qdev_create() with Coccinelle, Markus Armbruster, 2020/05/19
- [PATCH 28/55] usb: Eliminate usb_try_create_simple(), Markus Armbruster, 2020/05/19