[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 69/84] sysbus: Tidy up sysbus_init_child_obj()'s @childsize arg, p
From: |
Markus Armbruster |
Subject: |
[PULL 69/84] sysbus: Tidy up sysbus_init_child_obj()'s @childsize arg, part 2 |
Date: |
Mon, 15 Jun 2020 22:39:53 +0200 |
The callers of sysbus_init_child_obj() commonly pass either &child,
sizeof(child), or pchild, sizeof(*pchild). Tidy up the few that use
something else instead, mostly to keep future commits simpler.
Coccinelle script:
@@
expression parent, propname, type;
expression child;
type T;
T proxy;
@@
(
sysbus_init_child_obj(parent, propname, &child, sizeof(child), type)
|
sysbus_init_child_obj(parent, propname, child, sizeof(*child), type)
|
- sysbus_init_child_obj(parent, propname, child, sizeof(proxy), type)
+ sysbus_init_child_obj(parent, propname, child, sizeof(*child), type)
)
This script is *unsound*: for each change we need to verify the
@childsize argument stays the same. I did.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20200610053247.1583243-44-armbru@redhat.com>
---
hw/arm/mps2-tz.c | 15 +++++++--------
hw/arm/musca.c | 7 +++----
2 files changed, 10 insertions(+), 12 deletions(-)
diff --git a/hw/arm/mps2-tz.c b/hw/arm/mps2-tz.c
index ad0bc9365a..90f4449b9d 100644
--- a/hw/arm/mps2-tz.c
+++ b/hw/arm/mps2-tz.c
@@ -193,7 +193,7 @@ static MemoryRegion *make_uart(MPS2TZMachineState *mms,
void *opaque,
SysBusDevice *s;
DeviceState *orgate_dev = DEVICE(&mms->uart_irq_orgate);
- sysbus_init_child_obj(OBJECT(mms), name, uart, sizeof(mms->uart[0]),
+ sysbus_init_child_obj(OBJECT(mms), name, uart, sizeof(*uart),
TYPE_CMSDK_APB_UART);
qdev_prop_set_chr(DEVICE(uart), "chardev", serial_hd(i));
qdev_prop_set_uint32(DEVICE(uart), "pclk-frq", SYSCLK_FRQ);
@@ -214,8 +214,8 @@ static MemoryRegion *make_scc(MPS2TZMachineState *mms, void
*opaque,
DeviceState *sccdev;
MPS2TZMachineClass *mmc = MPS2TZ_MACHINE_GET_CLASS(mms);
- sysbus_init_child_obj(OBJECT(mms), "scc", scc,
- sizeof(mms->scc), TYPE_MPS2_SCC);
+ sysbus_init_child_obj(OBJECT(mms), "scc", scc, sizeof(*scc),
+ TYPE_MPS2_SCC);
sccdev = DEVICE(scc);
qdev_prop_set_uint32(sccdev, "scc-cfg4", 0x2);
qdev_prop_set_uint32(sccdev, "scc-aid", 0x00200008);
@@ -229,8 +229,8 @@ static MemoryRegion *make_fpgaio(MPS2TZMachineState *mms,
void *opaque,
{
MPS2FPGAIO *fpgaio = opaque;
- sysbus_init_child_obj(OBJECT(mms), "fpgaio", fpgaio,
- sizeof(mms->fpgaio), TYPE_MPS2_FPGAIO);
+ sysbus_init_child_obj(OBJECT(mms), "fpgaio", fpgaio, sizeof(*fpgaio),
+ TYPE_MPS2_FPGAIO);
object_property_set_bool(OBJECT(fpgaio), true, "realized", &error_fatal);
return sysbus_mmio_get_region(SYS_BUS_DEVICE(fpgaio), 0);
}
@@ -267,7 +267,7 @@ static MemoryRegion *make_mpc(MPS2TZMachineState *mms, void
*opaque,
memory_region_init_ram(ssram, NULL, name, ramsize[i], &error_fatal);
- sysbus_init_child_obj(OBJECT(mms), mpcname, mpc, sizeof(mms->ssram_mpc[0]),
+ sysbus_init_child_obj(OBJECT(mms), mpcname, mpc, sizeof(*mpc),
TYPE_TZ_MPC);
object_property_set_link(OBJECT(mpc), OBJECT(ssram),
"downstream", &error_fatal);
@@ -363,8 +363,7 @@ static MemoryRegion *make_spi(MPS2TZMachineState *mms, void
*opaque,
int i = spi - &mms->spi[0];
SysBusDevice *s;
- sysbus_init_child_obj(OBJECT(mms), name, spi, sizeof(mms->spi[0]),
- TYPE_PL022);
+ sysbus_init_child_obj(OBJECT(mms), name, spi, sizeof(*spi), TYPE_PL022);
object_property_set_bool(OBJECT(spi), true, "realized", &error_fatal);
s = SYS_BUS_DEVICE(spi);
sysbus_connect_irq(s, 0, get_sse_irq_in(mms, 51 + i));
diff --git a/hw/arm/musca.c b/hw/arm/musca.c
index b7f1c4e128..a1a6e887ed 100644
--- a/hw/arm/musca.c
+++ b/hw/arm/musca.c
@@ -256,7 +256,7 @@ static MemoryRegion *make_mpc(MuscaMachineState *mms, void
*opaque,
g_assert_not_reached();
}
- sysbus_init_child_obj(OBJECT(mms), mpcname, mpc, sizeof(mms->mpc[0]),
+ sysbus_init_child_obj(OBJECT(mms), mpcname, mpc, sizeof(*mpc),
TYPE_TZ_MPC);
object_property_set_link(OBJECT(mpc), OBJECT(downstream),
"downstream", &error_fatal);
@@ -279,7 +279,7 @@ static MemoryRegion *make_rtc(MuscaMachineState *mms, void
*opaque,
{
PL031State *rtc = opaque;
- sysbus_init_child_obj(OBJECT(mms), name, rtc, sizeof(mms->rtc),
TYPE_PL031);
+ sysbus_init_child_obj(OBJECT(mms), name, rtc, sizeof(*rtc), TYPE_PL031);
object_property_set_bool(OBJECT(rtc), true, "realized", &error_fatal);
sysbus_connect_irq(SYS_BUS_DEVICE(rtc), 0, get_sse_irq_in(mms, 39));
return sysbus_mmio_get_region(SYS_BUS_DEVICE(rtc), 0);
@@ -293,8 +293,7 @@ static MemoryRegion *make_uart(MuscaMachineState *mms, void
*opaque,
int irqbase = 7 + i * 6;
SysBusDevice *s;
- sysbus_init_child_obj(OBJECT(mms), name, uart, sizeof(mms->uart[0]),
- TYPE_PL011);
+ sysbus_init_child_obj(OBJECT(mms), name, uart, sizeof(*uart), TYPE_PL011);
qdev_prop_set_chr(DEVICE(uart), "chardev", serial_hd(i));
object_property_set_bool(OBJECT(uart), true, "realized", &error_fatal);
s = SYS_BUS_DEVICE(uart);
--
2.26.2
- [PULL 29/84] Revert "hw/versatile: realize the PCI root bus as part of the versatile init", (continued)
- [PULL 29/84] Revert "hw/versatile: realize the PCI root bus as part of the versatile init", Markus Armbruster, 2020/06/15
- [PULL 26/84] qdev: Assert onboard devices all get realized properly, Markus Armbruster, 2020/06/15
- [PULL 40/84] hw/ppc: Eliminate two superfluous QOM casts, Markus Armbruster, 2020/06/15
- [PULL 23/84] sparc/leon3: Fix to put grlib,* devices on sysbus, Markus Armbruster, 2020/06/15
- [PULL 46/84] isa: Convert uses of isa_create(), isa_try_create() manually, Markus Armbruster, 2020/06/15
- [PULL 41/84] pci: Convert uses of pci_create() etc. with Coccinelle, Markus Armbruster, 2020/06/15
- [PULL 47/84] isa: isa_create(), isa_try_create() are now unused, drop, Markus Armbruster, 2020/06/15
- [PULL 51/84] ssi: ssi_create_slave_no_init() is now unused, drop, Markus Armbruster, 2020/06/15
- [PULL 53/84] usb: Convert uses of usb_create(), Markus Armbruster, 2020/06/15
- [PULL 32/84] qdev: Convert to qbus_realize(), qbus_unrealize(), Markus Armbruster, 2020/06/15
- [PULL 69/84] sysbus: Tidy up sysbus_init_child_obj()'s @childsize arg, part 2,
Markus Armbruster <=
- [PULL 68/84] hw/arm/armsse: Pass correct child size to sysbus_init_child_obj(), Markus Armbruster, 2020/06/15
- [PULL 38/84] qdev: Convert uses of qdev_set_parent_bus() manually, Markus Armbruster, 2020/06/15
- [PULL 49/84] ssi: Convert uses of ssi_create_slave_no_init() with Coccinelle, Markus Armbruster, 2020/06/15
- [PULL 44/84] isa: New isa_new(), isa_realize_and_unref() etc., Markus Armbruster, 2020/06/15
- [PULL 42/84] pci: Convert uses of pci_create() etc. manually, Markus Armbruster, 2020/06/15
- [PULL 01/84] qom: Constify object_get_canonical_path{, _component}()'s parameter, Markus Armbruster, 2020/06/15
- [PULL 45/84] isa: Convert uses of isa_create() with Coccinelle, Markus Armbruster, 2020/06/15
- [PULL 57/84] auxbus: Rename aux_init_bus() to aux_bus_init(), Markus Armbruster, 2020/06/15
- [PULL 50/84] ssi: Convert last use of ssi_create_slave_no_init() manually, Markus Armbruster, 2020/06/15
- [PULL 52/84] usb: New usb_new(), usb_realize_and_unref(), Markus Armbruster, 2020/06/15