mirror of https://gitee.com/openkylin/qemu.git
sysbus: Tidy up sysbus_init_child_obj()'s @childsize arg, part 1
The callers of sysbus_init_child_obj() commonly pass either &child, sizeof(child), or pchild, sizeof(*pchild). Tidy up the few that use sizeof(child_type) instead, mostly to keep future commits simpler. Coccinelle script: @@ expression parent, propname, type; type T; T child; @@ - sysbus_init_child_obj(parent, propname, &child, sizeof(T), type) + sysbus_init_child_obj(parent, propname, &child, sizeof(child), type) @@ expression parent, propname, type; type T; T *child; @@ - sysbus_init_child_obj(parent, propname, child, sizeof(T), type) + sysbus_init_child_obj(parent, propname, child, sizeof(*child), type) Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Message-Id: <20200610053247.1583243-42-armbru@redhat.com>
This commit is contained in:
parent
b0d09949fe
commit
8352a5b8cc
|
@ -27,8 +27,7 @@ static void create_unimp(BCM2835PeripheralState *ps,
|
||||||
UnimplementedDeviceState *uds,
|
UnimplementedDeviceState *uds,
|
||||||
const char *name, hwaddr ofs, hwaddr size)
|
const char *name, hwaddr ofs, hwaddr size)
|
||||||
{
|
{
|
||||||
sysbus_init_child_obj(OBJECT(ps), name, uds,
|
sysbus_init_child_obj(OBJECT(ps), name, uds, sizeof(*uds),
|
||||||
sizeof(UnimplementedDeviceState),
|
|
||||||
TYPE_UNIMPLEMENTED_DEVICE);
|
TYPE_UNIMPLEMENTED_DEVICE);
|
||||||
qdev_prop_set_string(DEVICE(uds), "name", name);
|
qdev_prop_set_string(DEVICE(uds), "name", name);
|
||||||
qdev_prop_set_uint64(DEVICE(uds), "size", size);
|
qdev_prop_set_uint64(DEVICE(uds), "size", size);
|
||||||
|
|
|
@ -174,8 +174,7 @@ static MemoryRegion *make_unimp_dev(MPS2TZMachineState *mms,
|
||||||
*/
|
*/
|
||||||
UnimplementedDeviceState *uds = opaque;
|
UnimplementedDeviceState *uds = opaque;
|
||||||
|
|
||||||
sysbus_init_child_obj(OBJECT(mms), name, uds,
|
sysbus_init_child_obj(OBJECT(mms), name, uds, sizeof(*uds),
|
||||||
sizeof(UnimplementedDeviceState),
|
|
||||||
TYPE_UNIMPLEMENTED_DEVICE);
|
TYPE_UNIMPLEMENTED_DEVICE);
|
||||||
qdev_prop_set_string(DEVICE(uds), "name", name);
|
qdev_prop_set_string(DEVICE(uds), "name", name);
|
||||||
qdev_prop_set_uint64(DEVICE(uds), "size", size);
|
qdev_prop_set_uint64(DEVICE(uds), "size", size);
|
||||||
|
@ -552,7 +551,7 @@ static void mps2tz_common_init(MachineState *machine)
|
||||||
char *gpioname;
|
char *gpioname;
|
||||||
|
|
||||||
sysbus_init_child_obj(OBJECT(machine), ppcinfo->name, ppc,
|
sysbus_init_child_obj(OBJECT(machine), ppcinfo->name, ppc,
|
||||||
sizeof(TZPPC), TYPE_TZ_PPC);
|
sizeof(*ppc), TYPE_TZ_PPC);
|
||||||
ppcdev = DEVICE(ppc);
|
ppcdev = DEVICE(ppc);
|
||||||
|
|
||||||
for (port = 0; port < TZ_NUM_PORTS; port++) {
|
for (port = 0; port < TZ_NUM_PORTS; port++) {
|
||||||
|
|
|
@ -142,8 +142,7 @@ static MemoryRegion *make_unimp_dev(MuscaMachineState *mms,
|
||||||
*/
|
*/
|
||||||
UnimplementedDeviceState *uds = opaque;
|
UnimplementedDeviceState *uds = opaque;
|
||||||
|
|
||||||
sysbus_init_child_obj(OBJECT(mms), name, uds,
|
sysbus_init_child_obj(OBJECT(mms), name, uds, sizeof(*uds),
|
||||||
sizeof(UnimplementedDeviceState),
|
|
||||||
TYPE_UNIMPLEMENTED_DEVICE);
|
TYPE_UNIMPLEMENTED_DEVICE);
|
||||||
qdev_prop_set_string(DEVICE(uds), "name", name);
|
qdev_prop_set_string(DEVICE(uds), "name", name);
|
||||||
qdev_prop_set_uint64(DEVICE(uds), "size", size);
|
qdev_prop_set_uint64(DEVICE(uds), "size", size);
|
||||||
|
@ -246,8 +245,7 @@ static MemoryRegion *make_mpc(MuscaMachineState *mms, void *opaque,
|
||||||
case MPC_CRYPTOISLAND:
|
case MPC_CRYPTOISLAND:
|
||||||
/* We don't implement the CryptoIsland yet */
|
/* We don't implement the CryptoIsland yet */
|
||||||
uds = &mms->cryptoisland;
|
uds = &mms->cryptoisland;
|
||||||
sysbus_init_child_obj(OBJECT(mms), name, uds,
|
sysbus_init_child_obj(OBJECT(mms), name, uds, sizeof(*uds),
|
||||||
sizeof(UnimplementedDeviceState),
|
|
||||||
TYPE_UNIMPLEMENTED_DEVICE);
|
TYPE_UNIMPLEMENTED_DEVICE);
|
||||||
qdev_prop_set_string(DEVICE(uds), "name", mpcinfo[i].name);
|
qdev_prop_set_string(DEVICE(uds), "name", mpcinfo[i].name);
|
||||||
qdev_prop_set_uint64(DEVICE(uds), "size", mpcinfo[i].size);
|
qdev_prop_set_uint64(DEVICE(uds), "size", mpcinfo[i].size);
|
||||||
|
@ -535,7 +533,7 @@ static void musca_init(MachineState *machine)
|
||||||
char *gpioname;
|
char *gpioname;
|
||||||
|
|
||||||
sysbus_init_child_obj(OBJECT(machine), ppcinfo->name, ppc,
|
sysbus_init_child_obj(OBJECT(machine), ppcinfo->name, ppc,
|
||||||
sizeof(TZPPC), TYPE_TZ_PPC);
|
sizeof(*ppc), TYPE_TZ_PPC);
|
||||||
ppcdev = DEVICE(ppc);
|
ppcdev = DEVICE(ppc);
|
||||||
|
|
||||||
for (port = 0; port < TZ_NUM_PORTS; port++) {
|
for (port = 0; port < TZ_NUM_PORTS; port++) {
|
||||||
|
|
|
@ -2023,7 +2023,7 @@ static void sm501_sysbus_init(Object *o)
|
||||||
SM501SysBusState *sm501 = SYSBUS_SM501(o);
|
SM501SysBusState *sm501 = SYSBUS_SM501(o);
|
||||||
SerialMM *smm = &sm501->serial;
|
SerialMM *smm = &sm501->serial;
|
||||||
|
|
||||||
sysbus_init_child_obj(o, "serial", smm, sizeof(SerialMM), TYPE_SERIAL_MM);
|
sysbus_init_child_obj(o, "serial", smm, sizeof(*smm), TYPE_SERIAL_MM);
|
||||||
qdev_set_legacy_instance_id(DEVICE(smm), SM501_UART0, 2);
|
qdev_set_legacy_instance_id(DEVICE(smm), SM501_UART0, 2);
|
||||||
qdev_prop_set_uint8(DEVICE(smm), "regshift", 2);
|
qdev_prop_set_uint8(DEVICE(smm), "regshift", 2);
|
||||||
qdev_prop_set_uint8(DEVICE(smm), "endianness", DEVICE_LITTLE_ENDIAN);
|
qdev_prop_set_uint8(DEVICE(smm), "endianness", DEVICE_LITTLE_ENDIAN);
|
||||||
|
|
|
@ -69,8 +69,8 @@ static void xlnx_zynqmp_pmu_soc_init(Object *obj)
|
||||||
/* Create the IPI device */
|
/* Create the IPI device */
|
||||||
for (int i = 0; i < XLNX_ZYNQMP_PMU_NUM_IPIS; i++) {
|
for (int i = 0; i < XLNX_ZYNQMP_PMU_NUM_IPIS; i++) {
|
||||||
char *name = g_strdup_printf("ipi%d", i);
|
char *name = g_strdup_printf("ipi%d", i);
|
||||||
sysbus_init_child_obj(obj, name, &s->ipi[i],
|
sysbus_init_child_obj(obj, name, &s->ipi[i], sizeof(s->ipi[i]),
|
||||||
sizeof(XlnxZynqMPIPI), TYPE_XLNX_ZYNQMP_IPI);
|
TYPE_XLNX_ZYNQMP_IPI);
|
||||||
g_free(name);
|
g_free(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue