* [Qemu-devel] [PATCH 01/22] musicpal: Convert sysbus init function to realize function
2018-11-19 12:07 [Qemu-devel] [PATCH 00/22] QOM'ify SysBusDeviceClass->init Mao Zhongyi
@ 2018-11-19 12:07 ` Mao Zhongyi
2018-11-20 21:43 ` Philippe Mathieu-Daudé
2018-11-19 12:08 ` [Qemu-devel] [PATCH 02/22] block/noenand: " Mao Zhongyi
` (22 subsequent siblings)
23 siblings, 1 reply; 55+ messages in thread
From: Mao Zhongyi @ 2018-11-19 12:07 UTC (permalink / raw)
To: qemu-devel
Cc: Mao Zhongyi, jan.kiszka, peter.maydell, qemu-arm, Zhang Shengju
Use DeviceClass rather than SysBusDeviceClass in
mv88w8618_wlan_class_init().
Cc: jan.kiszka@web.de
Cc: peter.maydell@linaro.org
Cc: qemu-arm@nongnu.org
Signed-off-by: Mao Zhongyi <maozhongyi@cmss.chinamobile.com>
Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com>
---
hw/arm/musicpal.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/hw/arm/musicpal.c b/hw/arm/musicpal.c
index 9648b3af44..7ffcdbb097 100644
--- a/hw/arm/musicpal.c
+++ b/hw/arm/musicpal.c
@@ -1147,14 +1147,13 @@ static const MemoryRegionOps mv88w8618_wlan_ops = {
.endianness = DEVICE_NATIVE_ENDIAN,
};
-static int mv88w8618_wlan_init(SysBusDevice *dev)
+static void mv88w8618_wlan_realize(DeviceState *dev, Error **errp)
{
MemoryRegion *iomem = g_new(MemoryRegion, 1);
memory_region_init_io(iomem, OBJECT(dev), &mv88w8618_wlan_ops, NULL,
"musicpal-wlan", MP_WLAN_SIZE);
- sysbus_init_mmio(dev, iomem);
- return 0;
+ sysbus_init_mmio(SYS_BUS_DEVICE(dev), iomem);
}
/* GPIO register offsets */
@@ -1720,9 +1719,9 @@ DEFINE_MACHINE("musicpal", musicpal_machine_init)
static void mv88w8618_wlan_class_init(ObjectClass *klass, void *data)
{
- SysBusDeviceClass *sdc = SYS_BUS_DEVICE_CLASS(klass);
+ DeviceClass *dc = DEVICE_CLASS(klass);
- sdc->init = mv88w8618_wlan_init;
+ dc->realize = mv88w8618_wlan_realize;
}
static const TypeInfo mv88w8618_wlan_info = {
--
2.17.1
^ permalink raw reply related [flat|nested] 55+ messages in thread
* Re: [Qemu-devel] [PATCH 01/22] musicpal: Convert sysbus init function to realize function
2018-11-19 12:07 ` [Qemu-devel] [PATCH 01/22] musicpal: Convert sysbus init function to realize function Mao Zhongyi
@ 2018-11-20 21:43 ` Philippe Mathieu-Daudé
0 siblings, 0 replies; 55+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-11-20 21:43 UTC (permalink / raw)
To: Mao Zhongyi, qemu-devel
Cc: peter.maydell, qemu-arm, jan.kiszka, Zhang Shengju
On 19/11/18 13:07, Mao Zhongyi wrote:
> Use DeviceClass rather than SysBusDeviceClass in
> mv88w8618_wlan_class_init().
>
> Cc: jan.kiszka@web.de
> Cc: peter.maydell@linaro.org
> Cc: qemu-arm@nongnu.org
>
> Signed-off-by: Mao Zhongyi <maozhongyi@cmss.chinamobile.com>
> Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
> hw/arm/musicpal.c | 9 ++++-----
> 1 file changed, 4 insertions(+), 5 deletions(-)
>
> diff --git a/hw/arm/musicpal.c b/hw/arm/musicpal.c
> index 9648b3af44..7ffcdbb097 100644
> --- a/hw/arm/musicpal.c
> +++ b/hw/arm/musicpal.c
> @@ -1147,14 +1147,13 @@ static const MemoryRegionOps mv88w8618_wlan_ops = {
> .endianness = DEVICE_NATIVE_ENDIAN,
> };
>
> -static int mv88w8618_wlan_init(SysBusDevice *dev)
> +static void mv88w8618_wlan_realize(DeviceState *dev, Error **errp)
> {
> MemoryRegion *iomem = g_new(MemoryRegion, 1);
>
> memory_region_init_io(iomem, OBJECT(dev), &mv88w8618_wlan_ops, NULL,
> "musicpal-wlan", MP_WLAN_SIZE);
> - sysbus_init_mmio(dev, iomem);
> - return 0;
> + sysbus_init_mmio(SYS_BUS_DEVICE(dev), iomem);
> }
>
> /* GPIO register offsets */
> @@ -1720,9 +1719,9 @@ DEFINE_MACHINE("musicpal", musicpal_machine_init)
>
> static void mv88w8618_wlan_class_init(ObjectClass *klass, void *data)
> {
> - SysBusDeviceClass *sdc = SYS_BUS_DEVICE_CLASS(klass);
> + DeviceClass *dc = DEVICE_CLASS(klass);
>
> - sdc->init = mv88w8618_wlan_init;
> + dc->realize = mv88w8618_wlan_realize;
> }
>
> static const TypeInfo mv88w8618_wlan_info = {
>
^ permalink raw reply [flat|nested] 55+ messages in thread
* [Qemu-devel] [PATCH 02/22] block/noenand: Convert sysbus init function to realize function
2018-11-19 12:07 [Qemu-devel] [PATCH 00/22] QOM'ify SysBusDeviceClass->init Mao Zhongyi
2018-11-19 12:07 ` [Qemu-devel] [PATCH 01/22] musicpal: Convert sysbus init function to realize function Mao Zhongyi
@ 2018-11-19 12:08 ` Mao Zhongyi
2018-11-19 12:08 ` [Qemu-devel] [PATCH 03/22] char/grlib_apbuart: " Mao Zhongyi
` (21 subsequent siblings)
23 siblings, 0 replies; 55+ messages in thread
From: Mao Zhongyi @ 2018-11-19 12:08 UTC (permalink / raw)
To: qemu-devel; +Cc: Mao Zhongyi, kwolf, mreitz, qemu-block, Zhang Shengju
Use DeviceClass rather than SysBusDeviceClass in
onenand_class_init().
Cc: kwolf@redhat.com
Cc: mreitz@redhat.com
Cc: qemu-block@nongnu.org
Signed-off-by: Mao Zhongyi <maozhongyi@cmss.chinamobile.com>
Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com>
---
hw/block/onenand.c | 19 ++++++++-----------
1 file changed, 8 insertions(+), 11 deletions(-)
diff --git a/hw/block/onenand.c b/hw/block/onenand.c
index 0cb8d7fa13..6bf89aac1d 100644
--- a/hw/block/onenand.c
+++ b/hw/block/onenand.c
@@ -768,9 +768,8 @@ static const MemoryRegionOps onenand_ops = {
.endianness = DEVICE_NATIVE_ENDIAN,
};
-static int onenand_initfn(SysBusDevice *sbd)
+static void onenand_realize(DeviceState *dev, Error **errp)
{
- DeviceState *dev = DEVICE(sbd);
OneNANDState *s = ONE_NAND(dev);
uint32_t size = 1 << (24 + ((s->id.dev >> 4) & 7));
void *ram;
@@ -790,14 +789,14 @@ static int onenand_initfn(SysBusDevice *sbd)
0xff, size + (size >> 5));
} else {
if (blk_is_read_only(s->blk)) {
- error_report("Can't use a read-only drive");
- return -1;
+ error_setg(errp, "Can't use a read-only drive");
+ return;
}
blk_set_perm(s->blk, BLK_PERM_CONSISTENT_READ | BLK_PERM_WRITE,
BLK_PERM_ALL, &local_err);
if (local_err) {
- error_report_err(local_err);
- return -1;
+ error_propagate(errp, local_err);
+ return;
}
s->blk_cur = s->blk;
}
@@ -814,15 +813,14 @@ static int onenand_initfn(SysBusDevice *sbd)
s->data[1][0] = ram + ((0x0200 + (1 << (PAGE_SHIFT - 1))) << s->shift);
s->data[1][1] = ram + ((0x8010 + (1 << (PAGE_SHIFT - 6))) << s->shift);
onenand_mem_setup(s);
- sysbus_init_irq(sbd, &s->intr);
- sysbus_init_mmio(sbd, &s->container);
+ sysbus_init_irq(SYS_BUS_DEVICE(dev), &s->intr);
+ sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->container);
vmstate_register(dev,
((s->shift & 0x7f) << 24)
| ((s->id.man & 0xff) << 16)
| ((s->id.dev & 0xff) << 8)
| (s->id.ver & 0xff),
&vmstate_onenand, s);
- return 0;
}
static Property onenand_properties[] = {
@@ -837,9 +835,8 @@ static Property onenand_properties[] = {
static void onenand_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
- SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
- k->init = onenand_initfn;
+ dc->realize = onenand_realize;
dc->reset = onenand_system_reset;
dc->props = onenand_properties;
}
--
2.17.1
^ permalink raw reply related [flat|nested] 55+ messages in thread
* [Qemu-devel] [PATCH 03/22] char/grlib_apbuart: Convert sysbus init function to realize function
2018-11-19 12:07 [Qemu-devel] [PATCH 00/22] QOM'ify SysBusDeviceClass->init Mao Zhongyi
2018-11-19 12:07 ` [Qemu-devel] [PATCH 01/22] musicpal: Convert sysbus init function to realize function Mao Zhongyi
2018-11-19 12:08 ` [Qemu-devel] [PATCH 02/22] block/noenand: " Mao Zhongyi
@ 2018-11-19 12:08 ` Mao Zhongyi
2018-11-19 12:08 ` [Qemu-devel] [PATCH 04/22] core/empty_slot: " Mao Zhongyi
` (20 subsequent siblings)
23 siblings, 0 replies; 55+ messages in thread
From: Mao Zhongyi @ 2018-11-19 12:08 UTC (permalink / raw)
To: qemu-devel
Cc: Mao Zhongyi, chouteau, marcandre.lureau, pbonzini, Zhang Shengju
Use DeviceClass rather than SysBusDeviceClass in
grlib_apbuart_class_init().
Cc: chouteau@adacore.com
Cc: marcandre.lureau@redhat.com
Cc: pbonzini@redhat.com
Signed-off-by: Mao Zhongyi <maozhongyi@cmss.chinamobile.com>
Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com>
---
hw/char/grlib_apbuart.c | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/hw/char/grlib_apbuart.c b/hw/char/grlib_apbuart.c
index bac11bec58..e73ecf2ea5 100644
--- a/hw/char/grlib_apbuart.c
+++ b/hw/char/grlib_apbuart.c
@@ -239,7 +239,7 @@ static const MemoryRegionOps grlib_apbuart_ops = {
.endianness = DEVICE_NATIVE_ENDIAN,
};
-static int grlib_apbuart_init(SysBusDevice *dev)
+static void grlib_apbuart_realize(DeviceState *dev, Error **errp)
{
UART *uart = GRLIB_APB_UART(dev);
@@ -249,14 +249,12 @@ static int grlib_apbuart_init(SysBusDevice *dev)
grlib_apbuart_event,
NULL, uart, NULL, true);
- sysbus_init_irq(dev, &uart->irq);
+ sysbus_init_irq(SYS_BUS_DEVICE(dev), &uart->irq);
memory_region_init_io(&uart->iomem, OBJECT(uart), &grlib_apbuart_ops, uart,
"uart", UART_REG_SIZE);
- sysbus_init_mmio(dev, &uart->iomem);
-
- return 0;
+ sysbus_init_mmio(SYS_BUS_DEVICE(dev), &uart->iomem);
}
static void grlib_apbuart_reset(DeviceState *d)
@@ -280,9 +278,8 @@ static Property grlib_apbuart_properties[] = {
static void grlib_apbuart_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
- SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
- k->init = grlib_apbuart_init;
+ dc->realize = grlib_apbuart_realize;
dc->reset = grlib_apbuart_reset;
dc->props = grlib_apbuart_properties;
}
--
2.17.1
^ permalink raw reply related [flat|nested] 55+ messages in thread
* [Qemu-devel] [PATCH 04/22] core/empty_slot: Convert sysbus init function to realize function
2018-11-19 12:07 [Qemu-devel] [PATCH 00/22] QOM'ify SysBusDeviceClass->init Mao Zhongyi
` (2 preceding siblings ...)
2018-11-19 12:08 ` [Qemu-devel] [PATCH 03/22] char/grlib_apbuart: " Mao Zhongyi
@ 2018-11-19 12:08 ` Mao Zhongyi
2018-11-20 14:48 ` Peter Maydell
2018-11-20 21:25 ` Philippe Mathieu-Daudé
2018-11-19 12:08 ` [Qemu-devel] [PATCH 05/22] display/g364fb: " Mao Zhongyi
` (19 subsequent siblings)
23 siblings, 2 replies; 55+ messages in thread
From: Mao Zhongyi @ 2018-11-19 12:08 UTC (permalink / raw)
To: qemu-devel; +Cc: Mao Zhongyi, Zhang Shengju
Use DeviceClass rather than SysBusDeviceClass in
empty_slot_class_init().
Signed-off-by: Mao Zhongyi <maozhongyi@cmss.chinamobile.com>
Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com>
---
hw/core/empty_slot.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/hw/core/empty_slot.c b/hw/core/empty_slot.c
index c1b9c2b104..239f78e2a7 100644
--- a/hw/core/empty_slot.c
+++ b/hw/core/empty_slot.c
@@ -71,21 +71,20 @@ void empty_slot_init(hwaddr addr, uint64_t slot_size)
}
}
-static int empty_slot_init1(SysBusDevice *dev)
+static void empty_slot_realize(DeviceState *dev, Error **errp)
{
EmptySlot *s = EMPTY_SLOT(dev);
memory_region_init_io(&s->iomem, OBJECT(s), &empty_slot_ops, s,
"empty-slot", s->size);
- sysbus_init_mmio(dev, &s->iomem);
- return 0;
+ sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->iomem);
}
static void empty_slot_class_init(ObjectClass *klass, void *data)
{
- SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
+ DeviceClass *dc = DEVICE_CLASS(klass);
- k->init = empty_slot_init1;
+ dc->realize = empty_slot_realize;
}
static const TypeInfo empty_slot_info = {
--
2.17.1
^ permalink raw reply related [flat|nested] 55+ messages in thread
* Re: [Qemu-devel] [PATCH 04/22] core/empty_slot: Convert sysbus init function to realize function
2018-11-19 12:08 ` [Qemu-devel] [PATCH 04/22] core/empty_slot: " Mao Zhongyi
@ 2018-11-20 14:48 ` Peter Maydell
2018-11-20 21:25 ` Philippe Mathieu-Daudé
1 sibling, 0 replies; 55+ messages in thread
From: Peter Maydell @ 2018-11-20 14:48 UTC (permalink / raw)
To: Mao Zhongyi; +Cc: QEMU Developers, Zhang Shengju
On 19 November 2018 at 12:08, Mao Zhongyi
<maozhongyi@cmss.chinamobile.com> wrote:
> Use DeviceClass rather than SysBusDeviceClass in
> empty_slot_class_init().
>
> Signed-off-by: Mao Zhongyi <maozhongyi@cmss.chinamobile.com>
> Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com>
> ---
> hw/core/empty_slot.c | 9 ++++-----
> 1 file changed, 4 insertions(+), 5 deletions(-)
>
> diff --git a/hw/core/empty_slot.c b/hw/core/empty_slot.c
> index c1b9c2b104..239f78e2a7 100644
> --- a/hw/core/empty_slot.c
> +++ b/hw/core/empty_slot.c
> @@ -71,21 +71,20 @@ void empty_slot_init(hwaddr addr, uint64_t slot_size)
> }
> }
>
> -static int empty_slot_init1(SysBusDevice *dev)
> +static void empty_slot_realize(DeviceState *dev, Error **errp)
> {
> EmptySlot *s = EMPTY_SLOT(dev);
>
> memory_region_init_io(&s->iomem, OBJECT(s), &empty_slot_ops, s,
> "empty-slot", s->size);
> - sysbus_init_mmio(dev, &s->iomem);
> - return 0;
> + sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->iomem);
> }
>
> static void empty_slot_class_init(ObjectClass *klass, void *data)
> {
> - SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
> + DeviceClass *dc = DEVICE_CLASS(klass);
>
> - k->init = empty_slot_init1;
> + dc->realize = empty_slot_realize;
> }
>
> static const TypeInfo empty_slot_info = {
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
thanks
-- PMM
^ permalink raw reply [flat|nested] 55+ messages in thread
* Re: [Qemu-devel] [PATCH 04/22] core/empty_slot: Convert sysbus init function to realize function
2018-11-19 12:08 ` [Qemu-devel] [PATCH 04/22] core/empty_slot: " Mao Zhongyi
2018-11-20 14:48 ` Peter Maydell
@ 2018-11-20 21:25 ` Philippe Mathieu-Daudé
1 sibling, 0 replies; 55+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-11-20 21:25 UTC (permalink / raw)
To: Mao Zhongyi, qemu-devel; +Cc: Zhang Shengju
On 19/11/18 13:08, Mao Zhongyi wrote:
> Use DeviceClass rather than SysBusDeviceClass in
> empty_slot_class_init().
>
> Signed-off-by: Mao Zhongyi <maozhongyi@cmss.chinamobile.com>
> Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
> hw/core/empty_slot.c | 9 ++++-----
> 1 file changed, 4 insertions(+), 5 deletions(-)
>
> diff --git a/hw/core/empty_slot.c b/hw/core/empty_slot.c
> index c1b9c2b104..239f78e2a7 100644
> --- a/hw/core/empty_slot.c
> +++ b/hw/core/empty_slot.c
> @@ -71,21 +71,20 @@ void empty_slot_init(hwaddr addr, uint64_t slot_size)
> }
> }
>
> -static int empty_slot_init1(SysBusDevice *dev)
> +static void empty_slot_realize(DeviceState *dev, Error **errp)
> {
> EmptySlot *s = EMPTY_SLOT(dev);
>
> memory_region_init_io(&s->iomem, OBJECT(s), &empty_slot_ops, s,
> "empty-slot", s->size);
> - sysbus_init_mmio(dev, &s->iomem);
> - return 0;
> + sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->iomem);
> }
>
> static void empty_slot_class_init(ObjectClass *klass, void *data)
> {
> - SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
> + DeviceClass *dc = DEVICE_CLASS(klass);
>
> - k->init = empty_slot_init1;
> + dc->realize = empty_slot_realize;
> }
>
> static const TypeInfo empty_slot_info = {
>
^ permalink raw reply [flat|nested] 55+ messages in thread
* [Qemu-devel] [PATCH 05/22] display/g364fb: Convert sysbus init function to realize function
2018-11-19 12:07 [Qemu-devel] [PATCH 00/22] QOM'ify SysBusDeviceClass->init Mao Zhongyi
` (3 preceding siblings ...)
2018-11-19 12:08 ` [Qemu-devel] [PATCH 04/22] core/empty_slot: " Mao Zhongyi
@ 2018-11-19 12:08 ` Mao Zhongyi
2018-11-20 17:14 ` Alistair Francis
2018-11-19 12:08 ` [Qemu-devel] [PATCH 06/22] dma/puv3_dma: " Mao Zhongyi
` (18 subsequent siblings)
23 siblings, 1 reply; 55+ messages in thread
From: Mao Zhongyi @ 2018-11-19 12:08 UTC (permalink / raw)
To: qemu-devel
Cc: Mao Zhongyi, pbonzini, kraxel, f4bug, alistair.francis, Zhang Shengju
Use DeviceClass rather than SysBusDeviceClass in
g364fb_sysbus_class_init().
Cc: pbonzini@redhat.com
Cc: kraxel@redhat.com
Cc: f4bug@amsat.org
Cc: alistair.francis@wdc.com
Signed-off-by: Mao Zhongyi <maozhongyi@cmss.chinamobile.com>
Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com>
---
hw/display/g364fb.c | 14 +++++---------
1 file changed, 5 insertions(+), 9 deletions(-)
diff --git a/hw/display/g364fb.c b/hw/display/g364fb.c
index 8ad7e5d824..e7f67088b0 100644
--- a/hw/display/g364fb.c
+++ b/hw/display/g364fb.c
@@ -489,18 +489,15 @@ typedef struct {
G364State g364;
} G364SysBusState;
-static int g364fb_sysbus_init(SysBusDevice *sbd)
+static void g364fb_sysbus_realize(DeviceState *dev, Error **errp)
{
- DeviceState *dev = DEVICE(sbd);
G364SysBusState *sbs = G364(dev);
G364State *s = &sbs->g364;
g364fb_init(dev, s);
- sysbus_init_irq(sbd, &s->irq);
- sysbus_init_mmio(sbd, &s->mem_ctrl);
- sysbus_init_mmio(sbd, &s->mem_vram);
-
- return 0;
+ sysbus_init_irq(SYS_BUS_DEVICE(dev), &s->irq);
+ sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->mem_ctrl);
+ sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->mem_vram);
}
static void g364fb_sysbus_reset(DeviceState *d)
@@ -518,9 +515,8 @@ static Property g364fb_sysbus_properties[] = {
static void g364fb_sysbus_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
- SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
- k->init = g364fb_sysbus_init;
+ dc->realize = g364fb_sysbus_realize;
set_bit(DEVICE_CATEGORY_DISPLAY, dc->categories);
dc->desc = "G364 framebuffer";
dc->reset = g364fb_sysbus_reset;
--
2.17.1
^ permalink raw reply related [flat|nested] 55+ messages in thread
* Re: [Qemu-devel] [PATCH 05/22] display/g364fb: Convert sysbus init function to realize function
2018-11-19 12:08 ` [Qemu-devel] [PATCH 05/22] display/g364fb: " Mao Zhongyi
@ 2018-11-20 17:14 ` Alistair Francis
0 siblings, 0 replies; 55+ messages in thread
From: Alistair Francis @ 2018-11-20 17:14 UTC (permalink / raw)
To: maozhongyi
Cc: qemu-devel@nongnu.org Developers, Philippe Mathieu-Daudé,
Alistair Francis, Gerd Hoffmann, Paolo Bonzini, zhangshengju
On Mon, Nov 19, 2018 at 4:28 AM Mao Zhongyi
<maozhongyi@cmss.chinamobile.com> wrote:
>
> Use DeviceClass rather than SysBusDeviceClass in
> g364fb_sysbus_class_init().
>
> Cc: pbonzini@redhat.com
> Cc: kraxel@redhat.com
> Cc: f4bug@amsat.org
> Cc: alistair.francis@wdc.com
>
> Signed-off-by: Mao Zhongyi <maozhongyi@cmss.chinamobile.com>
> Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Alistair
> ---
> hw/display/g364fb.c | 14 +++++---------
> 1 file changed, 5 insertions(+), 9 deletions(-)
>
> diff --git a/hw/display/g364fb.c b/hw/display/g364fb.c
> index 8ad7e5d824..e7f67088b0 100644
> --- a/hw/display/g364fb.c
> +++ b/hw/display/g364fb.c
> @@ -489,18 +489,15 @@ typedef struct {
> G364State g364;
> } G364SysBusState;
>
> -static int g364fb_sysbus_init(SysBusDevice *sbd)
> +static void g364fb_sysbus_realize(DeviceState *dev, Error **errp)
> {
> - DeviceState *dev = DEVICE(sbd);
> G364SysBusState *sbs = G364(dev);
> G364State *s = &sbs->g364;
>
> g364fb_init(dev, s);
> - sysbus_init_irq(sbd, &s->irq);
> - sysbus_init_mmio(sbd, &s->mem_ctrl);
> - sysbus_init_mmio(sbd, &s->mem_vram);
> -
> - return 0;
> + sysbus_init_irq(SYS_BUS_DEVICE(dev), &s->irq);
> + sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->mem_ctrl);
> + sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->mem_vram);
> }
>
> static void g364fb_sysbus_reset(DeviceState *d)
> @@ -518,9 +515,8 @@ static Property g364fb_sysbus_properties[] = {
> static void g364fb_sysbus_class_init(ObjectClass *klass, void *data)
> {
> DeviceClass *dc = DEVICE_CLASS(klass);
> - SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
>
> - k->init = g364fb_sysbus_init;
> + dc->realize = g364fb_sysbus_realize;
> set_bit(DEVICE_CATEGORY_DISPLAY, dc->categories);
> dc->desc = "G364 framebuffer";
> dc->reset = g364fb_sysbus_reset;
> --
> 2.17.1
>
>
>
>
^ permalink raw reply [flat|nested] 55+ messages in thread
* [Qemu-devel] [PATCH 06/22] dma/puv3_dma: Convert sysbus init function to realize function
2018-11-19 12:07 [Qemu-devel] [PATCH 00/22] QOM'ify SysBusDeviceClass->init Mao Zhongyi
` (4 preceding siblings ...)
2018-11-19 12:08 ` [Qemu-devel] [PATCH 05/22] display/g364fb: " Mao Zhongyi
@ 2018-11-19 12:08 ` Mao Zhongyi
2018-11-20 14:46 ` Peter Maydell
2018-11-20 21:26 ` [Qemu-devel] [PATCH 06/22] dma/puv3_dma: Convert sysbus init function " Philippe Mathieu-Daudé
2018-11-19 12:08 ` [Qemu-devel] [PATCH 07/22] gpio/puv3_gpio: " Mao Zhongyi
` (17 subsequent siblings)
23 siblings, 2 replies; 55+ messages in thread
From: Mao Zhongyi @ 2018-11-19 12:08 UTC (permalink / raw)
To: qemu-devel; +Cc: Mao Zhongyi, gxt, Zhang Shengju
Use DeviceClass rather than SysBusDeviceClass in
puv3_dma_class_init().
Cc: gxt@mprc.pku.edu.cn
Signed-off-by: Mao Zhongyi <maozhongyi@cmss.chinamobile.com>
Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com>
---
hw/dma/puv3_dma.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/hw/dma/puv3_dma.c b/hw/dma/puv3_dma.c
index b97a6c1767..c89eade029 100644
--- a/hw/dma/puv3_dma.c
+++ b/hw/dma/puv3_dma.c
@@ -76,7 +76,7 @@ static const MemoryRegionOps puv3_dma_ops = {
.endianness = DEVICE_NATIVE_ENDIAN,
};
-static int puv3_dma_init(SysBusDevice *dev)
+static void puv3_dma_realize(DeviceState *dev, Error **errp)
{
PUV3DMAState *s = PUV3_DMA(dev);
int i;
@@ -87,16 +87,14 @@ static int puv3_dma_init(SysBusDevice *dev)
memory_region_init_io(&s->iomem, OBJECT(s), &puv3_dma_ops, s, "puv3_dma",
PUV3_REGS_OFFSET);
- sysbus_init_mmio(dev, &s->iomem);
-
- return 0;
+ sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->iomem);
}
static void puv3_dma_class_init(ObjectClass *klass, void *data)
{
- SysBusDeviceClass *sdc = SYS_BUS_DEVICE_CLASS(klass);
+ DeviceClass *dc = DEVICE_CLASS(klass);
- sdc->init = puv3_dma_init;
+ dc->realize = puv3_dma_realize;
}
static const TypeInfo puv3_dma_info = {
--
2.17.1
^ permalink raw reply related [flat|nested] 55+ messages in thread
* Re: [Qemu-devel] [PATCH 06/22] dma/puv3_dma: Convert sysbus init function to realize function
2018-11-19 12:08 ` [Qemu-devel] [PATCH 06/22] dma/puv3_dma: " Mao Zhongyi
@ 2018-11-20 14:46 ` Peter Maydell
2018-11-23 3:25 ` [Qemu-devel] [PATCH 06/22] dma/puv3_dma: Convert sysbus initfunction " maozy
2018-11-20 21:26 ` [Qemu-devel] [PATCH 06/22] dma/puv3_dma: Convert sysbus init function " Philippe Mathieu-Daudé
1 sibling, 1 reply; 55+ messages in thread
From: Peter Maydell @ 2018-11-20 14:46 UTC (permalink / raw)
To: Mao Zhongyi; +Cc: QEMU Developers, Guan Xuetao, Zhang Shengju
On 19 November 2018 at 12:08, Mao Zhongyi
<maozhongyi@cmss.chinamobile.com> wrote:
> Use DeviceClass rather than SysBusDeviceClass in
> puv3_dma_class_init().
>
> Cc: gxt@mprc.pku.edu.cn
>
> Signed-off-by: Mao Zhongyi <maozhongyi@cmss.chinamobile.com>
> Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com>
> ---
> hw/dma/puv3_dma.c | 10 ++++------
> 1 file changed, 4 insertions(+), 6 deletions(-)
>
> diff --git a/hw/dma/puv3_dma.c b/hw/dma/puv3_dma.c
> index b97a6c1767..c89eade029 100644
> --- a/hw/dma/puv3_dma.c
> +++ b/hw/dma/puv3_dma.c
> @@ -76,7 +76,7 @@ static const MemoryRegionOps puv3_dma_ops = {
> .endianness = DEVICE_NATIVE_ENDIAN,
> };
>
> -static int puv3_dma_init(SysBusDevice *dev)
> +static void puv3_dma_realize(DeviceState *dev, Error **errp)
> {
> PUV3DMAState *s = PUV3_DMA(dev);
> int i;
> @@ -87,16 +87,14 @@ static int puv3_dma_init(SysBusDevice *dev)
>
> memory_region_init_io(&s->iomem, OBJECT(s), &puv3_dma_ops, s, "puv3_dma",
> PUV3_REGS_OFFSET);
> - sysbus_init_mmio(dev, &s->iomem);
> -
> - return 0;
> + sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->iomem);
> }
>
> static void puv3_dma_class_init(ObjectClass *klass, void *data)
> {
> - SysBusDeviceClass *sdc = SYS_BUS_DEVICE_CLASS(klass);
> + DeviceClass *dc = DEVICE_CLASS(klass);
>
> - sdc->init = puv3_dma_init;
> + dc->realize = puv3_dma_realize;
> }
>
> static const TypeInfo puv3_dma_info = {
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
(I note that this device is missing a reset function and is
instead resetting in its init/realize function, but that's a
separate bug. It's also missing vmstate.)
thanks
-- PMM
^ permalink raw reply [flat|nested] 55+ messages in thread
* Re: [Qemu-devel] [PATCH 06/22] dma/puv3_dma: Convert sysbus initfunction to realize function
2018-11-20 14:46 ` Peter Maydell
@ 2018-11-23 3:25 ` maozy
0 siblings, 0 replies; 55+ messages in thread
From: maozy @ 2018-11-23 3:25 UTC (permalink / raw)
To: Peter Maydell; +Cc: QEMU Developers, Guan Xuetao, Zhang Shengju
On 11/20/18 10:46 PM, Peter Maydell wrote:
> On 19 November 2018 at 12:08, Mao Zhongyi
> <maozhongyi@cmss.chinamobile.com> wrote:
>> Use DeviceClass rather than SysBusDeviceClass in
>> puv3_dma_class_init().
>>
>> Cc: gxt@mprc.pku.edu.cn
>>
>> Signed-off-by: Mao Zhongyi <maozhongyi@cmss.chinamobile.com>
>> Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com>
>> ---
>> hw/dma/puv3_dma.c | 10 ++++------
>> 1 file changed, 4 insertions(+), 6 deletions(-)
>>
>> diff --git a/hw/dma/puv3_dma.c b/hw/dma/puv3_dma.c
>> index b97a6c1767..c89eade029 100644
>> --- a/hw/dma/puv3_dma.c
>> +++ b/hw/dma/puv3_dma.c
>> @@ -76,7 +76,7 @@ static const MemoryRegionOps puv3_dma_ops = {
>> .endianness = DEVICE_NATIVE_ENDIAN,
>> };
>>
>> -static int puv3_dma_init(SysBusDevice *dev)
>> +static void puv3_dma_realize(DeviceState *dev, Error **errp)
>> {
>> PUV3DMAState *s = PUV3_DMA(dev);
>> int i;
>> @@ -87,16 +87,14 @@ static int puv3_dma_init(SysBusDevice *dev)
>>
>> memory_region_init_io(&s->iomem, OBJECT(s), &puv3_dma_ops, s, "puv3_dma",
>> PUV3_REGS_OFFSET);
>> - sysbus_init_mmio(dev, &s->iomem);
>> -
>> - return 0;
>> + sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->iomem);
>> }
>>
>> static void puv3_dma_class_init(ObjectClass *klass, void *data)
>> {
>> - SysBusDeviceClass *sdc = SYS_BUS_DEVICE_CLASS(klass);
>> + DeviceClass *dc = DEVICE_CLASS(klass);
>>
>> - sdc->init = puv3_dma_init;
>> + dc->realize = puv3_dma_realize;
>> }
>>
>> static const TypeInfo puv3_dma_info = {
>
> Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
>
> (I note that this device is missing a reset function and is
> instead resetting in its init/realize function, but that's a
> separate bug. It's also missing vmstate.)
OK, I will fix it later in a separate patch.
Thanks,
Mao
>
> thanks
> -- PMM
>
^ permalink raw reply [flat|nested] 55+ messages in thread
* Re: [Qemu-devel] [PATCH 06/22] dma/puv3_dma: Convert sysbus init function to realize function
2018-11-19 12:08 ` [Qemu-devel] [PATCH 06/22] dma/puv3_dma: " Mao Zhongyi
2018-11-20 14:46 ` Peter Maydell
@ 2018-11-20 21:26 ` Philippe Mathieu-Daudé
1 sibling, 0 replies; 55+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-11-20 21:26 UTC (permalink / raw)
To: Mao Zhongyi, qemu-devel; +Cc: gxt, Zhang Shengju
On 19/11/18 13:08, Mao Zhongyi wrote:
> Use DeviceClass rather than SysBusDeviceClass in
> puv3_dma_class_init().
>
> Cc: gxt@mprc.pku.edu.cn
>
> Signed-off-by: Mao Zhongyi <maozhongyi@cmss.chinamobile.com>
> Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
> hw/dma/puv3_dma.c | 10 ++++------
> 1 file changed, 4 insertions(+), 6 deletions(-)
>
> diff --git a/hw/dma/puv3_dma.c b/hw/dma/puv3_dma.c
> index b97a6c1767..c89eade029 100644
> --- a/hw/dma/puv3_dma.c
> +++ b/hw/dma/puv3_dma.c
> @@ -76,7 +76,7 @@ static const MemoryRegionOps puv3_dma_ops = {
> .endianness = DEVICE_NATIVE_ENDIAN,
> };
>
> -static int puv3_dma_init(SysBusDevice *dev)
> +static void puv3_dma_realize(DeviceState *dev, Error **errp)
> {
> PUV3DMAState *s = PUV3_DMA(dev);
> int i;
> @@ -87,16 +87,14 @@ static int puv3_dma_init(SysBusDevice *dev)
>
> memory_region_init_io(&s->iomem, OBJECT(s), &puv3_dma_ops, s, "puv3_dma",
> PUV3_REGS_OFFSET);
> - sysbus_init_mmio(dev, &s->iomem);
> -
> - return 0;
> + sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->iomem);
> }
>
> static void puv3_dma_class_init(ObjectClass *klass, void *data)
> {
> - SysBusDeviceClass *sdc = SYS_BUS_DEVICE_CLASS(klass);
> + DeviceClass *dc = DEVICE_CLASS(klass);
>
> - sdc->init = puv3_dma_init;
> + dc->realize = puv3_dma_realize;
> }
>
> static const TypeInfo puv3_dma_info = {
>
^ permalink raw reply [flat|nested] 55+ messages in thread
* [Qemu-devel] [PATCH 07/22] gpio/puv3_gpio: Convert sysbus init function to realize function
2018-11-19 12:07 [Qemu-devel] [PATCH 00/22] QOM'ify SysBusDeviceClass->init Mao Zhongyi
` (5 preceding siblings ...)
2018-11-19 12:08 ` [Qemu-devel] [PATCH 06/22] dma/puv3_dma: " Mao Zhongyi
@ 2018-11-19 12:08 ` Mao Zhongyi
2018-11-19 14:31 ` Peter Maydell
2018-11-19 12:08 ` [Qemu-devel] [PATCH 08/22] milkymist-softusb: Convert sysbus init function " Mao Zhongyi
` (16 subsequent siblings)
23 siblings, 1 reply; 55+ messages in thread
From: Mao Zhongyi @ 2018-11-19 12:08 UTC (permalink / raw)
To: qemu-devel; +Cc: Mao Zhongyi, gxt, Zhang Shengju
Use DeviceClass rather than SysBusDeviceClass in
puv3_gpio_class_init().
Cc: gxt@mprc.pku.edu.cn
Signed-off-by: Mao Zhongyi <maozhongyi@cmss.chinamobile.com>
Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com>
---
hw/gpio/puv3_gpio.c | 28 +++++++++++++---------------
1 file changed, 13 insertions(+), 15 deletions(-)
diff --git a/hw/gpio/puv3_gpio.c b/hw/gpio/puv3_gpio.c
index 445afccf9f..bd6fc43aae 100644
--- a/hw/gpio/puv3_gpio.c
+++ b/hw/gpio/puv3_gpio.c
@@ -99,7 +99,7 @@ static const MemoryRegionOps puv3_gpio_ops = {
.endianness = DEVICE_NATIVE_ENDIAN,
};
-static int puv3_gpio_init(SysBusDevice *dev)
+static void puv3_gpio_realize(DeviceState *dev, Error **errp)
{
PUV3GPIOState *s = PUV3_GPIO(dev);
@@ -107,28 +107,26 @@ static int puv3_gpio_init(SysBusDevice *dev)
s->reg_GPDR = 0;
/* FIXME: these irqs not handled yet */
- sysbus_init_irq(dev, &s->irq[PUV3_IRQS_GPIOLOW0]);
- sysbus_init_irq(dev, &s->irq[PUV3_IRQS_GPIOLOW1]);
- sysbus_init_irq(dev, &s->irq[PUV3_IRQS_GPIOLOW2]);
- sysbus_init_irq(dev, &s->irq[PUV3_IRQS_GPIOLOW3]);
- sysbus_init_irq(dev, &s->irq[PUV3_IRQS_GPIOLOW4]);
- sysbus_init_irq(dev, &s->irq[PUV3_IRQS_GPIOLOW5]);
- sysbus_init_irq(dev, &s->irq[PUV3_IRQS_GPIOLOW6]);
- sysbus_init_irq(dev, &s->irq[PUV3_IRQS_GPIOLOW7]);
- sysbus_init_irq(dev, &s->irq[PUV3_IRQS_GPIOHIGH]);
+ sysbus_init_irq(SYS_BUS_DEVICE(dev), &s->irq[PUV3_IRQS_GPIOLOW0]);
+ sysbus_init_irq(SYS_BUS_DEVICE(dev), &s->irq[PUV3_IRQS_GPIOLOW1]);
+ sysbus_init_irq(SYS_BUS_DEVICE(dev), &s->irq[PUV3_IRQS_GPIOLOW2]);
+ sysbus_init_irq(SYS_BUS_DEVICE(dev), &s->irq[PUV3_IRQS_GPIOLOW3]);
+ sysbus_init_irq(SYS_BUS_DEVICE(dev), &s->irq[PUV3_IRQS_GPIOLOW4]);
+ sysbus_init_irq(SYS_BUS_DEVICE(dev), &s->irq[PUV3_IRQS_GPIOLOW5]);
+ sysbus_init_irq(SYS_BUS_DEVICE(dev), &s->irq[PUV3_IRQS_GPIOLOW6]);
+ sysbus_init_irq(SYS_BUS_DEVICE(dev), &s->irq[PUV3_IRQS_GPIOLOW7]);
+ sysbus_init_irq(SYS_BUS_DEVICE(dev), &s->irq[PUV3_IRQS_GPIOHIGH]);
memory_region_init_io(&s->iomem, OBJECT(s), &puv3_gpio_ops, s, "puv3_gpio",
PUV3_REGS_OFFSET);
- sysbus_init_mmio(dev, &s->iomem);
-
- return 0;
+ sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->iomem);
}
static void puv3_gpio_class_init(ObjectClass *klass, void *data)
{
- SysBusDeviceClass *sdc = SYS_BUS_DEVICE_CLASS(klass);
+ DeviceClass *dc = DEVICE_CLASS(klass);
- sdc->init = puv3_gpio_init;
+ dc->realize = puv3_gpio_realize;
}
static const TypeInfo puv3_gpio_info = {
--
2.17.1
^ permalink raw reply related [flat|nested] 55+ messages in thread
* Re: [Qemu-devel] [PATCH 07/22] gpio/puv3_gpio: Convert sysbus init function to realize function
2018-11-19 12:08 ` [Qemu-devel] [PATCH 07/22] gpio/puv3_gpio: " Mao Zhongyi
@ 2018-11-19 14:31 ` Peter Maydell
2018-11-20 1:23 ` [Qemu-devel] [PATCH 07/22] gpio/puv3_gpio: Convert sysbus initfunction " maozy
0 siblings, 1 reply; 55+ messages in thread
From: Peter Maydell @ 2018-11-19 14:31 UTC (permalink / raw)
To: Mao Zhongyi; +Cc: QEMU Developers, Guan Xuetao, Zhang Shengju
On 19 November 2018 at 12:08, Mao Zhongyi
<maozhongyi@cmss.chinamobile.com> wrote:
> Use DeviceClass rather than SysBusDeviceClass in
> puv3_gpio_class_init().
>
> Cc: gxt@mprc.pku.edu.cn
>
> Signed-off-by: Mao Zhongyi <maozhongyi@cmss.chinamobile.com>
> Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com>
> ---
> hw/gpio/puv3_gpio.c | 28 +++++++++++++---------------
> 1 file changed, 13 insertions(+), 15 deletions(-)
>
> diff --git a/hw/gpio/puv3_gpio.c b/hw/gpio/puv3_gpio.c
> index 445afccf9f..bd6fc43aae 100644
> --- a/hw/gpio/puv3_gpio.c
> +++ b/hw/gpio/puv3_gpio.c
> @@ -99,7 +99,7 @@ static const MemoryRegionOps puv3_gpio_ops = {
> .endianness = DEVICE_NATIVE_ENDIAN,
> };
>
> -static int puv3_gpio_init(SysBusDevice *dev)
> +static void puv3_gpio_realize(DeviceState *dev, Error **errp)
> {
> PUV3GPIOState *s = PUV3_GPIO(dev);
>
> @@ -107,28 +107,26 @@ static int puv3_gpio_init(SysBusDevice *dev)
> s->reg_GPDR = 0;
>
> /* FIXME: these irqs not handled yet */
> - sysbus_init_irq(dev, &s->irq[PUV3_IRQS_GPIOLOW0]);
> - sysbus_init_irq(dev, &s->irq[PUV3_IRQS_GPIOLOW1]);
> - sysbus_init_irq(dev, &s->irq[PUV3_IRQS_GPIOLOW2]);
> - sysbus_init_irq(dev, &s->irq[PUV3_IRQS_GPIOLOW3]);
> - sysbus_init_irq(dev, &s->irq[PUV3_IRQS_GPIOLOW4]);
> - sysbus_init_irq(dev, &s->irq[PUV3_IRQS_GPIOLOW5]);
> - sysbus_init_irq(dev, &s->irq[PUV3_IRQS_GPIOLOW6]);
> - sysbus_init_irq(dev, &s->irq[PUV3_IRQS_GPIOLOW7]);
> - sysbus_init_irq(dev, &s->irq[PUV3_IRQS_GPIOHIGH]);
> + sysbus_init_irq(SYS_BUS_DEVICE(dev), &s->irq[PUV3_IRQS_GPIOLOW0]);
> + sysbus_init_irq(SYS_BUS_DEVICE(dev), &s->irq[PUV3_IRQS_GPIOLOW1]);
> + sysbus_init_irq(SYS_BUS_DEVICE(dev), &s->irq[PUV3_IRQS_GPIOLOW2]);
> + sysbus_init_irq(SYS_BUS_DEVICE(dev), &s->irq[PUV3_IRQS_GPIOLOW3]);
> + sysbus_init_irq(SYS_BUS_DEVICE(dev), &s->irq[PUV3_IRQS_GPIOLOW4]);
> + sysbus_init_irq(SYS_BUS_DEVICE(dev), &s->irq[PUV3_IRQS_GPIOLOW5]);
> + sysbus_init_irq(SYS_BUS_DEVICE(dev), &s->irq[PUV3_IRQS_GPIOLOW6]);
> + sysbus_init_irq(SYS_BUS_DEVICE(dev), &s->irq[PUV3_IRQS_GPIOLOW7]);
> + sysbus_init_irq(SYS_BUS_DEVICE(dev), &s->irq[PUV3_IRQS_GPIOHIGH]);
>
> memory_region_init_io(&s->iomem, OBJECT(s), &puv3_gpio_ops, s, "puv3_gpio",
> PUV3_REGS_OFFSET);
> - sysbus_init_mmio(dev, &s->iomem);
> -
> - return 0;
> + sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->iomem);
> }
The SYS_BUS_DEVICE() cast is not free (it does type
checking). It's better to do it once, ie
SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
and use the variable, if we're going to be using
it several times.
thanks
-- PMM
^ permalink raw reply [flat|nested] 55+ messages in thread
* Re: [Qemu-devel] [PATCH 07/22] gpio/puv3_gpio: Convert sysbus initfunction to realize function
2018-11-19 14:31 ` Peter Maydell
@ 2018-11-20 1:23 ` maozy
0 siblings, 0 replies; 55+ messages in thread
From: maozy @ 2018-11-20 1:23 UTC (permalink / raw)
To: Peter Maydell; +Cc: QEMU Developers, Guan Xuetao, Zhang Shengju
On 11/19/18 10:31 PM, Peter Maydell wrote:
> On 19 November 2018 at 12:08, Mao Zhongyi
> <maozhongyi@cmss.chinamobile.com> wrote:
>> Use DeviceClass rather than SysBusDeviceClass in
>> puv3_gpio_class_init().
>>
>> Cc: gxt@mprc.pku.edu.cn
>>
>> Signed-off-by: Mao Zhongyi <maozhongyi@cmss.chinamobile.com>
>> Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com>
>> ---
>> hw/gpio/puv3_gpio.c | 28 +++++++++++++---------------
>> 1 file changed, 13 insertions(+), 15 deletions(-)
>>
>> diff --git a/hw/gpio/puv3_gpio.c b/hw/gpio/puv3_gpio.c
>> index 445afccf9f..bd6fc43aae 100644
>> --- a/hw/gpio/puv3_gpio.c
>> +++ b/hw/gpio/puv3_gpio.c
>> @@ -99,7 +99,7 @@ static const MemoryRegionOps puv3_gpio_ops = {
>> .endianness = DEVICE_NATIVE_ENDIAN,
>> };
>>
>> -static int puv3_gpio_init(SysBusDevice *dev)
>> +static void puv3_gpio_realize(DeviceState *dev, Error **errp)
>> {
>> PUV3GPIOState *s = PUV3_GPIO(dev);
>>
>> @@ -107,28 +107,26 @@ static int puv3_gpio_init(SysBusDevice *dev)
>> s->reg_GPDR = 0;
>>
>> /* FIXME: these irqs not handled yet */
>> - sysbus_init_irq(dev, &s->irq[PUV3_IRQS_GPIOLOW0]);
>> - sysbus_init_irq(dev, &s->irq[PUV3_IRQS_GPIOLOW1]);
>> - sysbus_init_irq(dev, &s->irq[PUV3_IRQS_GPIOLOW2]);
>> - sysbus_init_irq(dev, &s->irq[PUV3_IRQS_GPIOLOW3]);
>> - sysbus_init_irq(dev, &s->irq[PUV3_IRQS_GPIOLOW4]);
>> - sysbus_init_irq(dev, &s->irq[PUV3_IRQS_GPIOLOW5]);
>> - sysbus_init_irq(dev, &s->irq[PUV3_IRQS_GPIOLOW6]);
>> - sysbus_init_irq(dev, &s->irq[PUV3_IRQS_GPIOLOW7]);
>> - sysbus_init_irq(dev, &s->irq[PUV3_IRQS_GPIOHIGH]);
>> + sysbus_init_irq(SYS_BUS_DEVICE(dev), &s->irq[PUV3_IRQS_GPIOLOW0]);
>> + sysbus_init_irq(SYS_BUS_DEVICE(dev), &s->irq[PUV3_IRQS_GPIOLOW1]);
>> + sysbus_init_irq(SYS_BUS_DEVICE(dev), &s->irq[PUV3_IRQS_GPIOLOW2]);
>> + sysbus_init_irq(SYS_BUS_DEVICE(dev), &s->irq[PUV3_IRQS_GPIOLOW3]);
>> + sysbus_init_irq(SYS_BUS_DEVICE(dev), &s->irq[PUV3_IRQS_GPIOLOW4]);
>> + sysbus_init_irq(SYS_BUS_DEVICE(dev), &s->irq[PUV3_IRQS_GPIOLOW5]);
>> + sysbus_init_irq(SYS_BUS_DEVICE(dev), &s->irq[PUV3_IRQS_GPIOLOW6]);
>> + sysbus_init_irq(SYS_BUS_DEVICE(dev), &s->irq[PUV3_IRQS_GPIOLOW7]);
>> + sysbus_init_irq(SYS_BUS_DEVICE(dev), &s->irq[PUV3_IRQS_GPIOHIGH]);
>>
>> memory_region_init_io(&s->iomem, OBJECT(s), &puv3_gpio_ops, s, "puv3_gpio",
>> PUV3_REGS_OFFSET);
>> - sysbus_init_mmio(dev, &s->iomem);
>> -
>> - return 0;
>> + sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->iomem);
>> }
>
> The SYS_BUS_DEVICE() cast is not free (it does type
> checking). It's better to do it once, ie
> SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
> and use the variable, if we're going to be using
> it several times.
Wow, sure,thanks a lot, will fix it in the next.
mao
>
> thanks
> -- PMM
>
^ permalink raw reply [flat|nested] 55+ messages in thread
* [Qemu-devel] [PATCH 08/22] milkymist-softusb: Convert sysbus init function to realize function
2018-11-19 12:07 [Qemu-devel] [PATCH 00/22] QOM'ify SysBusDeviceClass->init Mao Zhongyi
` (6 preceding siblings ...)
2018-11-19 12:08 ` [Qemu-devel] [PATCH 07/22] gpio/puv3_gpio: " Mao Zhongyi
@ 2018-11-19 12:08 ` Mao Zhongyi
2018-11-19 12:08 ` [Qemu-devel] [PATCH 09/22] input/pl050: " Mao Zhongyi
` (15 subsequent siblings)
23 siblings, 0 replies; 55+ messages in thread
From: Mao Zhongyi @ 2018-11-19 12:08 UTC (permalink / raw)
To: qemu-devel; +Cc: Mao Zhongyi, michael, Zhang Shengju
Use DeviceClass rather than SysBusDeviceClass in
milkymist_softusb_class_init().
Cc: michael@walle.cc
Signed-off-by: Mao Zhongyi <maozhongyi@cmss.chinamobile.com>
Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com>
---
hw/input/milkymist-softusb.c | 15 ++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)
diff --git a/hw/input/milkymist-softusb.c b/hw/input/milkymist-softusb.c
index ef8f47cd83..6e4cb29205 100644
--- a/hw/input/milkymist-softusb.c
+++ b/hw/input/milkymist-softusb.c
@@ -245,32 +245,30 @@ static void milkymist_softusb_reset(DeviceState *d)
s->regs[R_CTRL] = CTRL_RESET;
}
-static int milkymist_softusb_init(SysBusDevice *dev)
+static void milkymist_softusb_realize(DeviceState *dev, Error **errp)
{
MilkymistSoftUsbState *s = MILKYMIST_SOFTUSB(dev);
- sysbus_init_irq(dev, &s->irq);
+ sysbus_init_irq(SYS_BUS_DEVICE(dev), &s->irq);
memory_region_init_io(&s->regs_region, OBJECT(s), &softusb_mmio_ops, s,
"milkymist-softusb", R_MAX * 4);
- sysbus_init_mmio(dev, &s->regs_region);
+ sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->regs_region);
/* register pmem and dmem */
memory_region_init_ram_nomigrate(&s->pmem, OBJECT(s), "milkymist-softusb.pmem",
s->pmem_size, &error_fatal);
vmstate_register_ram_global(&s->pmem);
s->pmem_ptr = memory_region_get_ram_ptr(&s->pmem);
- sysbus_init_mmio(dev, &s->pmem);
+ sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->pmem);
memory_region_init_ram_nomigrate(&s->dmem, OBJECT(s), "milkymist-softusb.dmem",
s->dmem_size, &error_fatal);
vmstate_register_ram_global(&s->dmem);
s->dmem_ptr = memory_region_get_ram_ptr(&s->dmem);
- sysbus_init_mmio(dev, &s->dmem);
+ sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->dmem);
hid_init(&s->hid_kbd, HID_KEYBOARD, softusb_kbd_hid_datain);
hid_init(&s->hid_mouse, HID_MOUSE, softusb_mouse_hid_datain);
-
- return 0;
}
static const VMStateDescription vmstate_milkymist_softusb = {
@@ -296,9 +294,8 @@ static Property milkymist_softusb_properties[] = {
static void milkymist_softusb_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
- SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
- k->init = milkymist_softusb_init;
+ dc->realize = milkymist_softusb_realize;
dc->reset = milkymist_softusb_reset;
dc->vmsd = &vmstate_milkymist_softusb;
dc->props = milkymist_softusb_properties;
--
2.17.1
^ permalink raw reply related [flat|nested] 55+ messages in thread
* [Qemu-devel] [PATCH 09/22] input/pl050: Convert sysbus init function to realize function
2018-11-19 12:07 [Qemu-devel] [PATCH 00/22] QOM'ify SysBusDeviceClass->init Mao Zhongyi
` (7 preceding siblings ...)
2018-11-19 12:08 ` [Qemu-devel] [PATCH 08/22] milkymist-softusb: Convert sysbus init function " Mao Zhongyi
@ 2018-11-19 12:08 ` Mao Zhongyi
2018-11-19 12:08 ` [Qemu-devel] [PATCH 10/22] intc/puv3_intc: " Mao Zhongyi
` (14 subsequent siblings)
23 siblings, 0 replies; 55+ messages in thread
From: Mao Zhongyi @ 2018-11-19 12:08 UTC (permalink / raw)
To: qemu-devel; +Cc: Mao Zhongyi, peter.maydell, qemu-arm, Zhang Shengju
Use DeviceClass rather than SysBusDeviceClass in
pl050_class_init().
Cc: peter.maydell@linaro.org
Cc: qemu-arm@nongnu.org
Signed-off-by: Mao Zhongyi <maozhongyi@cmss.chinamobile.com>
Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com>
---
hw/input/pl050.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/hw/input/pl050.c b/hw/input/pl050.c
index be9cd57b17..f341c26a63 100644
--- a/hw/input/pl050.c
+++ b/hw/input/pl050.c
@@ -139,19 +139,18 @@ static const MemoryRegionOps pl050_ops = {
.endianness = DEVICE_NATIVE_ENDIAN,
};
-static int pl050_initfn(SysBusDevice *dev)
+static void pl050_realize(DeviceState *dev, Error **errp)
{
PL050State *s = PL050(dev);
memory_region_init_io(&s->iomem, OBJECT(s), &pl050_ops, s, "pl050", 0x1000);
- sysbus_init_mmio(dev, &s->iomem);
- sysbus_init_irq(dev, &s->irq);
+ sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->iomem);
+ sysbus_init_irq(SYS_BUS_DEVICE(dev), &s->irq);
if (s->is_mouse) {
s->dev = ps2_mouse_init(pl050_update, s);
} else {
s->dev = ps2_kbd_init(pl050_update, s);
}
- return 0;
}
static void pl050_keyboard_init(Object *obj)
@@ -183,9 +182,8 @@ static const TypeInfo pl050_mouse_info = {
static void pl050_class_init(ObjectClass *oc, void *data)
{
DeviceClass *dc = DEVICE_CLASS(oc);
- SysBusDeviceClass *sdc = SYS_BUS_DEVICE_CLASS(oc);
- sdc->init = pl050_initfn;
+ dc->realize = pl050_realize;
dc->vmsd = &vmstate_pl050;
}
--
2.17.1
^ permalink raw reply related [flat|nested] 55+ messages in thread
* [Qemu-devel] [PATCH 10/22] intc/puv3_intc: Convert sysbus init function to realize function
2018-11-19 12:07 [Qemu-devel] [PATCH 00/22] QOM'ify SysBusDeviceClass->init Mao Zhongyi
` (8 preceding siblings ...)
2018-11-19 12:08 ` [Qemu-devel] [PATCH 09/22] input/pl050: " Mao Zhongyi
@ 2018-11-19 12:08 ` Mao Zhongyi
2018-11-19 12:08 ` [Qemu-devel] [PATCH 11/22] milkymist-hpdmc: " Mao Zhongyi
` (13 subsequent siblings)
23 siblings, 0 replies; 55+ messages in thread
From: Mao Zhongyi @ 2018-11-19 12:08 UTC (permalink / raw)
To: qemu-devel; +Cc: Mao Zhongyi, gxt, Zhang Shengju
Use DeviceClass rather than SysBusDeviceClass in
puv3_intc_class_init().
Cc: gxt@mprc.pku.edu.cn
Signed-off-by: Mao Zhongyi <maozhongyi@cmss.chinamobile.com>
Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com>
---
hw/intc/puv3_intc.c | 14 +++++---------
1 file changed, 5 insertions(+), 9 deletions(-)
diff --git a/hw/intc/puv3_intc.c b/hw/intc/puv3_intc.c
index ef8488aacc..dfef505c47 100644
--- a/hw/intc/puv3_intc.c
+++ b/hw/intc/puv3_intc.c
@@ -101,29 +101,25 @@ static const MemoryRegionOps puv3_intc_ops = {
.endianness = DEVICE_NATIVE_ENDIAN,
};
-static int puv3_intc_init(SysBusDevice *sbd)
+static void puv3_intc_realize(DeviceState *dev, Error **errp)
{
- DeviceState *dev = DEVICE(sbd);
PUV3INTCState *s = PUV3_INTC(dev);
qdev_init_gpio_in(dev, puv3_intc_handler, PUV3_IRQS_NR);
- sysbus_init_irq(sbd, &s->parent_irq);
+ sysbus_init_irq(SYS_BUS_DEVICE(dev), &s->parent_irq);
s->reg_ICMR = 0;
s->reg_ICPR = 0;
memory_region_init_io(&s->iomem, OBJECT(s), &puv3_intc_ops, s, "puv3_intc",
PUV3_REGS_OFFSET);
- sysbus_init_mmio(sbd, &s->iomem);
-
- return 0;
+ sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->iomem);
}
static void puv3_intc_class_init(ObjectClass *klass, void *data)
{
- SysBusDeviceClass *sdc = SYS_BUS_DEVICE_CLASS(klass);
-
- sdc->init = puv3_intc_init;
+ DeviceClass *dc = DEVICE_CLASS(klass);
+ dc->realize = puv3_intc_realize;
}
static const TypeInfo puv3_intc_info = {
--
2.17.1
^ permalink raw reply related [flat|nested] 55+ messages in thread
* [Qemu-devel] [PATCH 11/22] milkymist-hpdmc: Convert sysbus init function to realize function
2018-11-19 12:07 [Qemu-devel] [PATCH 00/22] QOM'ify SysBusDeviceClass->init Mao Zhongyi
` (9 preceding siblings ...)
2018-11-19 12:08 ` [Qemu-devel] [PATCH 10/22] intc/puv3_intc: " Mao Zhongyi
@ 2018-11-19 12:08 ` Mao Zhongyi
2018-11-20 14:47 ` Peter Maydell
2018-11-20 21:29 ` Philippe Mathieu-Daudé
2018-11-19 12:08 ` [Qemu-devel] [PATCH 12/22] milkymist-pfpu: " Mao Zhongyi
` (12 subsequent siblings)
23 siblings, 2 replies; 55+ messages in thread
From: Mao Zhongyi @ 2018-11-19 12:08 UTC (permalink / raw)
To: qemu-devel; +Cc: Mao Zhongyi, gxt, michael, Zhang Shengju
Use DeviceClass rather than SysBusDeviceClass in
milkymist_hpdmc_class_init().
Cc: gxt@mprc.pku.edu.cn
Cc: michael@walle.cc
Signed-off-by: Mao Zhongyi <maozhongyi@cmss.chinamobile.com>
Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com>
---
hw/intc/puv3_intc.c | 1 +
hw/misc/milkymist-hpdmc.c | 9 +++------
2 files changed, 4 insertions(+), 6 deletions(-)
diff --git a/hw/intc/puv3_intc.c b/hw/intc/puv3_intc.c
index dfef505c47..a3ca6d466b 100644
--- a/hw/intc/puv3_intc.c
+++ b/hw/intc/puv3_intc.c
@@ -119,6 +119,7 @@ static void puv3_intc_realize(DeviceState *dev, Error **errp)
static void puv3_intc_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
+
dc->realize = puv3_intc_realize;
}
diff --git a/hw/misc/milkymist-hpdmc.c b/hw/misc/milkymist-hpdmc.c
index e6140eec6b..44dc0698ec 100644
--- a/hw/misc/milkymist-hpdmc.c
+++ b/hw/misc/milkymist-hpdmc.c
@@ -129,15 +129,13 @@ static void milkymist_hpdmc_reset(DeviceState *d)
| IODELAY_PLL2_LOCKED;
}
-static int milkymist_hpdmc_init(SysBusDevice *dev)
+static void milkymist_hpdmc_realize(DeviceState *dev, Error **errp)
{
MilkymistHpdmcState *s = MILKYMIST_HPDMC(dev);
memory_region_init_io(&s->regs_region, OBJECT(dev), &hpdmc_mmio_ops, s,
"milkymist-hpdmc", R_MAX * 4);
- sysbus_init_mmio(dev, &s->regs_region);
-
- return 0;
+ sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->regs_region);
}
static const VMStateDescription vmstate_milkymist_hpdmc = {
@@ -153,9 +151,8 @@ static const VMStateDescription vmstate_milkymist_hpdmc = {
static void milkymist_hpdmc_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
- SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
- k->init = milkymist_hpdmc_init;
+ dc->realize = milkymist_hpdmc_realize;
dc->reset = milkymist_hpdmc_reset;
dc->vmsd = &vmstate_milkymist_hpdmc;
}
--
2.17.1
^ permalink raw reply related [flat|nested] 55+ messages in thread
* Re: [Qemu-devel] [PATCH 11/22] milkymist-hpdmc: Convert sysbus init function to realize function
2018-11-19 12:08 ` [Qemu-devel] [PATCH 11/22] milkymist-hpdmc: " Mao Zhongyi
@ 2018-11-20 14:47 ` Peter Maydell
2018-11-20 21:29 ` Philippe Mathieu-Daudé
1 sibling, 0 replies; 55+ messages in thread
From: Peter Maydell @ 2018-11-20 14:47 UTC (permalink / raw)
To: Mao Zhongyi; +Cc: QEMU Developers, Michael Walle, Guan Xuetao, Zhang Shengju
On 19 November 2018 at 12:08, Mao Zhongyi
<maozhongyi@cmss.chinamobile.com> wrote:
> Use DeviceClass rather than SysBusDeviceClass in
> milkymist_hpdmc_class_init().
>
> Cc: gxt@mprc.pku.edu.cn
> Cc: michael@walle.cc
>
> Signed-off-by: Mao Zhongyi <maozhongyi@cmss.chinamobile.com>
> Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com>
> ---
> hw/intc/puv3_intc.c | 1 +
> hw/misc/milkymist-hpdmc.c | 9 +++------
> 2 files changed, 4 insertions(+), 6 deletions(-)
>
> diff --git a/hw/intc/puv3_intc.c b/hw/intc/puv3_intc.c
> index dfef505c47..a3ca6d466b 100644
> --- a/hw/intc/puv3_intc.c
> +++ b/hw/intc/puv3_intc.c
> @@ -119,6 +119,7 @@ static void puv3_intc_realize(DeviceState *dev, Error **errp)
> static void puv3_intc_class_init(ObjectClass *klass, void *data)
> {
> DeviceClass *dc = DEVICE_CLASS(klass);
> +
> dc->realize = puv3_intc_realize;
> }
Stray change to the wrong file ?
> diff --git a/hw/misc/milkymist-hpdmc.c b/hw/misc/milkymist-hpdmc.c
> index e6140eec6b..44dc0698ec 100644
> --- a/hw/misc/milkymist-hpdmc.c
> +++ b/hw/misc/milkymist-hpdmc.c
> @@ -129,15 +129,13 @@ static void milkymist_hpdmc_reset(DeviceState *d)
> | IODELAY_PLL2_LOCKED;
> }
>
> -static int milkymist_hpdmc_init(SysBusDevice *dev)
> +static void milkymist_hpdmc_realize(DeviceState *dev, Error **errp)
> {
> MilkymistHpdmcState *s = MILKYMIST_HPDMC(dev);
>
> memory_region_init_io(&s->regs_region, OBJECT(dev), &hpdmc_mmio_ops, s,
> "milkymist-hpdmc", R_MAX * 4);
> - sysbus_init_mmio(dev, &s->regs_region);
> -
> - return 0;
> + sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->regs_region);
> }
>
> static const VMStateDescription vmstate_milkymist_hpdmc = {
> @@ -153,9 +151,8 @@ static const VMStateDescription vmstate_milkymist_hpdmc = {
> static void milkymist_hpdmc_class_init(ObjectClass *klass, void *data)
> {
> DeviceClass *dc = DEVICE_CLASS(klass);
> - SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
>
> - k->init = milkymist_hpdmc_init;
> + dc->realize = milkymist_hpdmc_realize;
> dc->reset = milkymist_hpdmc_reset;
> dc->vmsd = &vmstate_milkymist_hpdmc;
> }
thanks
-- PMM
^ permalink raw reply [flat|nested] 55+ messages in thread
* Re: [Qemu-devel] [PATCH 11/22] milkymist-hpdmc: Convert sysbus init function to realize function
2018-11-19 12:08 ` [Qemu-devel] [PATCH 11/22] milkymist-hpdmc: " Mao Zhongyi
2018-11-20 14:47 ` Peter Maydell
@ 2018-11-20 21:29 ` Philippe Mathieu-Daudé
1 sibling, 0 replies; 55+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-11-20 21:29 UTC (permalink / raw)
To: Mao Zhongyi, qemu-devel; +Cc: michael, gxt, Zhang Shengju
On 19/11/18 13:08, Mao Zhongyi wrote:
> Use DeviceClass rather than SysBusDeviceClass in
> milkymist_hpdmc_class_init().
>
> Cc: gxt@mprc.pku.edu.cn
> Cc: michael@walle.cc
>
> Signed-off-by: Mao Zhongyi <maozhongyi@cmss.chinamobile.com>
> Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com>
> ---
> hw/intc/puv3_intc.c | 1 +
> hw/misc/milkymist-hpdmc.c | 9 +++------
> 2 files changed, 4 insertions(+), 6 deletions(-)
>
> diff --git a/hw/intc/puv3_intc.c b/hw/intc/puv3_intc.c
> index dfef505c47..a3ca6d466b 100644
> --- a/hw/intc/puv3_intc.c
> +++ b/hw/intc/puv3_intc.c
> @@ -119,6 +119,7 @@ static void puv3_intc_realize(DeviceState *dev, Error **errp)
> static void puv3_intc_class_init(ObjectClass *klass, void *data)
> {
> DeviceClass *dc = DEVICE_CLASS(klass);
> +
This change isn't related to milkymist-hpdmc (subject of your patch).
Except that:
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> dc->realize = puv3_intc_realize;
> }
>
> diff --git a/hw/misc/milkymist-hpdmc.c b/hw/misc/milkymist-hpdmc.c
> index e6140eec6b..44dc0698ec 100644
> --- a/hw/misc/milkymist-hpdmc.c
> +++ b/hw/misc/milkymist-hpdmc.c
> @@ -129,15 +129,13 @@ static void milkymist_hpdmc_reset(DeviceState *d)
> | IODELAY_PLL2_LOCKED;
> }
>
> -static int milkymist_hpdmc_init(SysBusDevice *dev)
> +static void milkymist_hpdmc_realize(DeviceState *dev, Error **errp)
> {
> MilkymistHpdmcState *s = MILKYMIST_HPDMC(dev);
>
> memory_region_init_io(&s->regs_region, OBJECT(dev), &hpdmc_mmio_ops, s,
> "milkymist-hpdmc", R_MAX * 4);
> - sysbus_init_mmio(dev, &s->regs_region);
> -
> - return 0;
> + sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->regs_region);
> }
>
> static const VMStateDescription vmstate_milkymist_hpdmc = {
> @@ -153,9 +151,8 @@ static const VMStateDescription vmstate_milkymist_hpdmc = {
> static void milkymist_hpdmc_class_init(ObjectClass *klass, void *data)
> {
> DeviceClass *dc = DEVICE_CLASS(klass);
> - SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
>
> - k->init = milkymist_hpdmc_init;
> + dc->realize = milkymist_hpdmc_realize;
> dc->reset = milkymist_hpdmc_reset;
> dc->vmsd = &vmstate_milkymist_hpdmc;
> }
>
^ permalink raw reply [flat|nested] 55+ messages in thread
* [Qemu-devel] [PATCH 12/22] milkymist-pfpu: Convert sysbus init function to realize function
2018-11-19 12:07 [Qemu-devel] [PATCH 00/22] QOM'ify SysBusDeviceClass->init Mao Zhongyi
` (10 preceding siblings ...)
2018-11-19 12:08 ` [Qemu-devel] [PATCH 11/22] milkymist-hpdmc: " Mao Zhongyi
@ 2018-11-19 12:08 ` Mao Zhongyi
2018-11-19 12:08 ` [Qemu-devel] [PATCH 13/22] puv3_pm.c: " Mao Zhongyi
` (11 subsequent siblings)
23 siblings, 0 replies; 55+ messages in thread
From: Mao Zhongyi @ 2018-11-19 12:08 UTC (permalink / raw)
To: qemu-devel; +Cc: Mao Zhongyi, michael, Zhang Shengju
Use DeviceClass rather than SysBusDeviceClass in
milkymist_pfpu_class_init().
Cc: michael@walle.cc
Signed-off-by: Mao Zhongyi <maozhongyi@cmss.chinamobile.com>
Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com>
---
hw/misc/milkymist-pfpu.c | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/hw/misc/milkymist-pfpu.c b/hw/misc/milkymist-pfpu.c
index 86f5e383b0..5d93c6c758 100644
--- a/hw/misc/milkymist-pfpu.c
+++ b/hw/misc/milkymist-pfpu.c
@@ -497,17 +497,15 @@ static void milkymist_pfpu_reset(DeviceState *d)
}
}
-static int milkymist_pfpu_init(SysBusDevice *dev)
+static void milkymist_pfpu_realize(DeviceState *dev, Error **errp)
{
MilkymistPFPUState *s = MILKYMIST_PFPU(dev);
- sysbus_init_irq(dev, &s->irq);
+ sysbus_init_irq(SYS_BUS_DEVICE(dev), &s->irq);
memory_region_init_io(&s->regs_region, OBJECT(dev), &pfpu_mmio_ops, s,
"milkymist-pfpu", MICROCODE_END * 4);
- sysbus_init_mmio(dev, &s->regs_region);
-
- return 0;
+ sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->regs_region);
}
static const VMStateDescription vmstate_milkymist_pfpu = {
@@ -527,9 +525,8 @@ static const VMStateDescription vmstate_milkymist_pfpu = {
static void milkymist_pfpu_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
- SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
- k->init = milkymist_pfpu_init;
+ dc->realize = milkymist_pfpu_realize;
dc->reset = milkymist_pfpu_reset;
dc->vmsd = &vmstate_milkymist_pfpu;
}
--
2.17.1
^ permalink raw reply related [flat|nested] 55+ messages in thread
* [Qemu-devel] [PATCH 13/22] puv3_pm.c: Convert sysbus init function to realize function
2018-11-19 12:07 [Qemu-devel] [PATCH 00/22] QOM'ify SysBusDeviceClass->init Mao Zhongyi
` (11 preceding siblings ...)
2018-11-19 12:08 ` [Qemu-devel] [PATCH 12/22] milkymist-pfpu: " Mao Zhongyi
@ 2018-11-19 12:08 ` Mao Zhongyi
2018-11-20 14:51 ` Peter Maydell
2018-11-20 21:29 ` Philippe Mathieu-Daudé
2018-11-19 12:08 ` [Qemu-devel] [PATCH 14/22] nvram/ds1225y: " Mao Zhongyi
` (10 subsequent siblings)
23 siblings, 2 replies; 55+ messages in thread
From: Mao Zhongyi @ 2018-11-19 12:08 UTC (permalink / raw)
To: qemu-devel; +Cc: Mao Zhongyi, gxt, Zhang Shengju
Use DeviceClass rather than SysBusDeviceClass in
puv3_pm_class_init().
Cc: gxt@mprc.pku.edu.cn
Signed-off-by: Mao Zhongyi <maozhongyi@cmss.chinamobile.com>
Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com>
---
hw/misc/puv3_pm.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/hw/misc/puv3_pm.c b/hw/misc/puv3_pm.c
index 577cebaac7..afe191fbe1 100644
--- a/hw/misc/puv3_pm.c
+++ b/hw/misc/puv3_pm.c
@@ -119,7 +119,7 @@ static const MemoryRegionOps puv3_pm_ops = {
.endianness = DEVICE_NATIVE_ENDIAN,
};
-static int puv3_pm_init(SysBusDevice *dev)
+static void puv3_pm_realize(DeviceState *dev, Error **errp)
{
PUV3PMState *s = PUV3_PM(dev);
@@ -127,16 +127,14 @@ static int puv3_pm_init(SysBusDevice *dev)
memory_region_init_io(&s->iomem, OBJECT(s), &puv3_pm_ops, s, "puv3_pm",
PUV3_REGS_OFFSET);
- sysbus_init_mmio(dev, &s->iomem);
-
- return 0;
+ sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->iomem);
}
static void puv3_pm_class_init(ObjectClass *klass, void *data)
{
- SysBusDeviceClass *sdc = SYS_BUS_DEVICE_CLASS(klass);
+ DeviceClass *dc = DEVICE_CLASS(klass);
- sdc->init = puv3_pm_init;
+ dc->realize = puv3_pm_realize;
}
static const TypeInfo puv3_pm_info = {
--
2.17.1
^ permalink raw reply related [flat|nested] 55+ messages in thread
* Re: [Qemu-devel] [PATCH 13/22] puv3_pm.c: Convert sysbus init function to realize function
2018-11-19 12:08 ` [Qemu-devel] [PATCH 13/22] puv3_pm.c: " Mao Zhongyi
@ 2018-11-20 14:51 ` Peter Maydell
2018-11-20 21:29 ` Philippe Mathieu-Daudé
1 sibling, 0 replies; 55+ messages in thread
From: Peter Maydell @ 2018-11-20 14:51 UTC (permalink / raw)
To: Mao Zhongyi; +Cc: QEMU Developers, Guan Xuetao, Zhang Shengju
On 19 November 2018 at 12:08, Mao Zhongyi
<maozhongyi@cmss.chinamobile.com> wrote:
> Use DeviceClass rather than SysBusDeviceClass in
> puv3_pm_class_init().
>
> Cc: gxt@mprc.pku.edu.cn
>
> Signed-off-by: Mao Zhongyi <maozhongyi@cmss.chinamobile.com>
> Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com>
> ---
> hw/misc/puv3_pm.c | 10 ++++------
> 1 file changed, 4 insertions(+), 6 deletions(-)
>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
thanks
-- PMM
^ permalink raw reply [flat|nested] 55+ messages in thread
* Re: [Qemu-devel] [PATCH 13/22] puv3_pm.c: Convert sysbus init function to realize function
2018-11-19 12:08 ` [Qemu-devel] [PATCH 13/22] puv3_pm.c: " Mao Zhongyi
2018-11-20 14:51 ` Peter Maydell
@ 2018-11-20 21:29 ` Philippe Mathieu-Daudé
1 sibling, 0 replies; 55+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-11-20 21:29 UTC (permalink / raw)
To: Mao Zhongyi, qemu-devel; +Cc: gxt, Zhang Shengju
On 19/11/18 13:08, Mao Zhongyi wrote:
> Use DeviceClass rather than SysBusDeviceClass in
> puv3_pm_class_init().
>
> Cc: gxt@mprc.pku.edu.cn
>
> Signed-off-by: Mao Zhongyi <maozhongyi@cmss.chinamobile.com>
> Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
> hw/misc/puv3_pm.c | 10 ++++------
> 1 file changed, 4 insertions(+), 6 deletions(-)
>
> diff --git a/hw/misc/puv3_pm.c b/hw/misc/puv3_pm.c
> index 577cebaac7..afe191fbe1 100644
> --- a/hw/misc/puv3_pm.c
> +++ b/hw/misc/puv3_pm.c
> @@ -119,7 +119,7 @@ static const MemoryRegionOps puv3_pm_ops = {
> .endianness = DEVICE_NATIVE_ENDIAN,
> };
>
> -static int puv3_pm_init(SysBusDevice *dev)
> +static void puv3_pm_realize(DeviceState *dev, Error **errp)
> {
> PUV3PMState *s = PUV3_PM(dev);
>
> @@ -127,16 +127,14 @@ static int puv3_pm_init(SysBusDevice *dev)
>
> memory_region_init_io(&s->iomem, OBJECT(s), &puv3_pm_ops, s, "puv3_pm",
> PUV3_REGS_OFFSET);
> - sysbus_init_mmio(dev, &s->iomem);
> -
> - return 0;
> + sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->iomem);
> }
>
> static void puv3_pm_class_init(ObjectClass *klass, void *data)
> {
> - SysBusDeviceClass *sdc = SYS_BUS_DEVICE_CLASS(klass);
> + DeviceClass *dc = DEVICE_CLASS(klass);
>
> - sdc->init = puv3_pm_init;
> + dc->realize = puv3_pm_realize;
> }
>
> static const TypeInfo puv3_pm_info = {
>
^ permalink raw reply [flat|nested] 55+ messages in thread
* [Qemu-devel] [PATCH 14/22] nvram/ds1225y: Convert sysbus init function to realize function
2018-11-19 12:07 [Qemu-devel] [PATCH 00/22] QOM'ify SysBusDeviceClass->init Mao Zhongyi
` (12 preceding siblings ...)
2018-11-19 12:08 ` [Qemu-devel] [PATCH 13/22] puv3_pm.c: " Mao Zhongyi
@ 2018-11-19 12:08 ` Mao Zhongyi
2018-11-20 14:51 ` Peter Maydell
2018-11-19 12:08 ` [Qemu-devel] [PATCH 15/22] pci-bridge/dec: " Mao Zhongyi
` (9 subsequent siblings)
23 siblings, 1 reply; 55+ messages in thread
From: Mao Zhongyi @ 2018-11-19 12:08 UTC (permalink / raw)
To: qemu-devel; +Cc: Mao Zhongyi, pbonzini, marcandre.lureau, Zhang Shengju
Use DeviceClass rather than SysBusDeviceClass in
nvram_sysbus_class_init().
Cc: pbonzini@redhat.com
Cc: marcandre.lureau@redhat.com
Signed-off-by: Mao Zhongyi <maozhongyi@cmss.chinamobile.com>
Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com>
---
hw/nvram/ds1225y.c | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/hw/nvram/ds1225y.c b/hw/nvram/ds1225y.c
index ad7345f288..b6ef463db0 100644
--- a/hw/nvram/ds1225y.c
+++ b/hw/nvram/ds1225y.c
@@ -25,6 +25,7 @@
#include "qemu/osdep.h"
#include "hw/sysbus.h"
#include "trace.h"
+#include "qemu/error-report.h"
typedef struct {
MemoryRegion iomem;
@@ -113,7 +114,7 @@ typedef struct {
NvRamState nvram;
} SysBusNvRamState;
-static int nvram_sysbus_initfn(SysBusDevice *dev)
+static void nvram_sysbus_realize(DeviceState *dev, Error **errp)
{
SysBusNvRamState *sys = DS1225Y(dev);
NvRamState *s = &sys->nvram;
@@ -123,20 +124,18 @@ static int nvram_sysbus_initfn(SysBusDevice *dev)
memory_region_init_io(&s->iomem, OBJECT(s), &nvram_ops, s,
"nvram", s->chip_size);
- sysbus_init_mmio(dev, &s->iomem);
+ sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->iomem);
/* Read current file */
file = s->filename ? fopen(s->filename, "rb") : NULL;
if (file) {
/* Read nvram contents */
if (fread(s->contents, s->chip_size, 1, file) != 1) {
- printf("nvram_sysbus_initfn: short read\n");
+ error_report("nvram_sysbus_realize: short read");
}
fclose(file);
}
nvram_post_load(s, 0);
-
- return 0;
}
static Property nvram_sysbus_properties[] = {
@@ -148,9 +147,8 @@ static Property nvram_sysbus_properties[] = {
static void nvram_sysbus_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
- SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
- k->init = nvram_sysbus_initfn;
+ dc->realize = nvram_sysbus_realize;
dc->vmsd = &vmstate_nvram;
dc->props = nvram_sysbus_properties;
}
--
2.17.1
^ permalink raw reply related [flat|nested] 55+ messages in thread
* Re: [Qemu-devel] [PATCH 14/22] nvram/ds1225y: Convert sysbus init function to realize function
2018-11-19 12:08 ` [Qemu-devel] [PATCH 14/22] nvram/ds1225y: " Mao Zhongyi
@ 2018-11-20 14:51 ` Peter Maydell
2018-11-20 23:14 ` Philippe Mathieu-Daudé
0 siblings, 1 reply; 55+ messages in thread
From: Peter Maydell @ 2018-11-20 14:51 UTC (permalink / raw)
To: Mao Zhongyi
Cc: QEMU Developers, Paolo Bonzini, Zhang Shengju, Marc-André Lureau
On 19 November 2018 at 12:08, Mao Zhongyi
<maozhongyi@cmss.chinamobile.com> wrote:
> Use DeviceClass rather than SysBusDeviceClass in
> nvram_sysbus_class_init().
>
> Cc: pbonzini@redhat.com
> Cc: marcandre.lureau@redhat.com
>
> Signed-off-by: Mao Zhongyi <maozhongyi@cmss.chinamobile.com>
> Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com>
> ---
> hw/nvram/ds1225y.c | 12 +++++-------
> 1 file changed, 5 insertions(+), 7 deletions(-)
>
> diff --git a/hw/nvram/ds1225y.c b/hw/nvram/ds1225y.c
> index ad7345f288..b6ef463db0 100644
> --- a/hw/nvram/ds1225y.c
> +++ b/hw/nvram/ds1225y.c
> @@ -25,6 +25,7 @@
> #include "qemu/osdep.h"
> #include "hw/sysbus.h"
> #include "trace.h"
> +#include "qemu/error-report.h"
>
> typedef struct {
> MemoryRegion iomem;
> @@ -113,7 +114,7 @@ typedef struct {
> NvRamState nvram;
> } SysBusNvRamState;
>
> -static int nvram_sysbus_initfn(SysBusDevice *dev)
> +static void nvram_sysbus_realize(DeviceState *dev, Error **errp)
> {
> SysBusNvRamState *sys = DS1225Y(dev);
> NvRamState *s = &sys->nvram;
> @@ -123,20 +124,18 @@ static int nvram_sysbus_initfn(SysBusDevice *dev)
>
> memory_region_init_io(&s->iomem, OBJECT(s), &nvram_ops, s,
> "nvram", s->chip_size);
> - sysbus_init_mmio(dev, &s->iomem);
> + sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->iomem);
>
> /* Read current file */
> file = s->filename ? fopen(s->filename, "rb") : NULL;
> if (file) {
> /* Read nvram contents */
> if (fread(s->contents, s->chip_size, 1, file) != 1) {
> - printf("nvram_sysbus_initfn: short read\n");
> + error_report("nvram_sysbus_realize: short read");
It seems a bit odd that we don't make this cause the
device to fail its realize method, though I suppose
it was not previously.
> }
> fclose(file);
> }
> nvram_post_load(s, 0);
> -
> - return 0;
> }
>
> static Property nvram_sysbus_properties[] = {
> @@ -148,9 +147,8 @@ static Property nvram_sysbus_properties[] = {
> static void nvram_sysbus_class_init(ObjectClass *klass, void *data)
> {
> DeviceClass *dc = DEVICE_CLASS(klass);
> - SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
>
> - k->init = nvram_sysbus_initfn;
> + dc->realize = nvram_sysbus_realize;
> dc->vmsd = &vmstate_nvram;
> dc->props = nvram_sysbus_properties;
> }
> --
> 2.17.1
>
thanks
-- PMM
^ permalink raw reply [flat|nested] 55+ messages in thread
* Re: [Qemu-devel] [PATCH 14/22] nvram/ds1225y: Convert sysbus init function to realize function
2018-11-20 14:51 ` Peter Maydell
@ 2018-11-20 23:14 ` Philippe Mathieu-Daudé
0 siblings, 0 replies; 55+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-11-20 23:14 UTC (permalink / raw)
To: Peter Maydell, Mao Zhongyi, Hervé Poussineau
Cc: Paolo Bonzini, QEMU Developers, Marc-André Lureau, Zhang Shengju
Hi Peter,
On 20/11/18 15:51, Peter Maydell wrote:
> On 19 November 2018 at 12:08, Mao Zhongyi
> <maozhongyi@cmss.chinamobile.com> wrote:
>> Use DeviceClass rather than SysBusDeviceClass in
>> nvram_sysbus_class_init().
>>
>> Cc: pbonzini@redhat.com
>> Cc: marcandre.lureau@redhat.com
>>
>> Signed-off-by: Mao Zhongyi <maozhongyi@cmss.chinamobile.com>
>> Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com>
>> ---
>> hw/nvram/ds1225y.c | 12 +++++-------
>> 1 file changed, 5 insertions(+), 7 deletions(-)
>>
>> diff --git a/hw/nvram/ds1225y.c b/hw/nvram/ds1225y.c
>> index ad7345f288..b6ef463db0 100644
>> --- a/hw/nvram/ds1225y.c
>> +++ b/hw/nvram/ds1225y.c
>> @@ -25,6 +25,7 @@
>> #include "qemu/osdep.h"
>> #include "hw/sysbus.h"
>> #include "trace.h"
>> +#include "qemu/error-report.h"
>>
>> typedef struct {
>> MemoryRegion iomem;
>> @@ -113,7 +114,7 @@ typedef struct {
>> NvRamState nvram;
>> } SysBusNvRamState;
>>
>> -static int nvram_sysbus_initfn(SysBusDevice *dev)
>> +static void nvram_sysbus_realize(DeviceState *dev, Error **errp)
>> {
>> SysBusNvRamState *sys = DS1225Y(dev);
>> NvRamState *s = &sys->nvram;
>> @@ -123,20 +124,18 @@ static int nvram_sysbus_initfn(SysBusDevice *dev)
>>
>> memory_region_init_io(&s->iomem, OBJECT(s), &nvram_ops, s,
>> "nvram", s->chip_size);
>> - sysbus_init_mmio(dev, &s->iomem);
>> + sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->iomem);
>>
>> /* Read current file */
>> file = s->filename ? fopen(s->filename, "rb") : NULL;
>> if (file) {
>> /* Read nvram contents */
>> if (fread(s->contents, s->chip_size, 1, file) != 1) {
>> - printf("nvram_sysbus_initfn: short read\n");
>> + error_report("nvram_sysbus_realize: short read");
>
> It seems a bit odd that we don't make this cause the
> device to fail its realize method, though I suppose
> it was not previously.
I think the case where the file length is <= chip_size is OK, since the
contents buffer is zero-allocated.
Now for the other case when length > chip_size, you are right we
shouldn't ignore it and throw an error.
However this is not related to this patch and should be addressed in a
different patch, so for this patch:
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
This file is named ds1225y but is rather a generic way to byte-access a
file (except the default chip_size which is 8kB for the DS1225Y).
Is there a more up-to-date way to do that nowaday?
>
>> }
>> fclose(file);
>> }
>> nvram_post_load(s, 0);
>> -
>> - return 0;
>> }
>>
>> static Property nvram_sysbus_properties[] = {
>> @@ -148,9 +147,8 @@ static Property nvram_sysbus_properties[] = {
>> static void nvram_sysbus_class_init(ObjectClass *klass, void *data)
>> {
>> DeviceClass *dc = DEVICE_CLASS(klass);
>> - SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
>>
>> - k->init = nvram_sysbus_initfn;
>> + dc->realize = nvram_sysbus_realize;
>> dc->vmsd = &vmstate_nvram;
>> dc->props = nvram_sysbus_properties;
>> }
>> --
>> 2.17.1
>>
>
> thanks
> -- PMM
>
^ permalink raw reply [flat|nested] 55+ messages in thread
* [Qemu-devel] [PATCH 15/22] pci-bridge/dec: Convert sysbus init function to realize function
2018-11-19 12:07 [Qemu-devel] [PATCH 00/22] QOM'ify SysBusDeviceClass->init Mao Zhongyi
` (13 preceding siblings ...)
2018-11-19 12:08 ` [Qemu-devel] [PATCH 14/22] nvram/ds1225y: " Mao Zhongyi
@ 2018-11-19 12:08 ` Mao Zhongyi
2018-11-21 8:42 ` David Gibson
2018-11-19 12:08 ` [Qemu-devel] [PATCH 16/22] timer/etraxfs_timer: " Mao Zhongyi
` (8 subsequent siblings)
23 siblings, 1 reply; 55+ messages in thread
From: Mao Zhongyi @ 2018-11-19 12:08 UTC (permalink / raw)
To: qemu-devel
Cc: Mao Zhongyi, david, mst, marcel.apfelbaum, qemu-ppc, Zhang Shengju
Use DeviceClass rather than SysBusDeviceClass in
pci_dec_21154_device_class_init().
Cc: david@gibson.dropbear.id.au
Cc: mst@redhat.com
Cc: marcel.apfelbaum@gmail.com
Cc: qemu-ppc@nongnu.org
Signed-off-by: Mao Zhongyi <maozhongyi@cmss.chinamobile.com>
Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com>
---
hw/pci-bridge/dec.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/hw/pci-bridge/dec.c b/hw/pci-bridge/dec.c
index 84492d5e5f..5b21c20e50 100644
--- a/hw/pci-bridge/dec.c
+++ b/hw/pci-bridge/dec.c
@@ -98,7 +98,7 @@ PCIBus *pci_dec_21154_init(PCIBus *parent_bus, int devfn)
return pci_bridge_get_sec_bus(br);
}
-static int pci_dec_21154_device_init(SysBusDevice *dev)
+static void pci_dec_21154_device_realize(DeviceState *dev, Error **errp)
{
PCIHostState *phb;
@@ -108,9 +108,8 @@ static int pci_dec_21154_device_init(SysBusDevice *dev)
dev, "pci-conf-idx", 0x1000);
memory_region_init_io(&phb->data_mem, OBJECT(dev), &pci_host_data_le_ops,
dev, "pci-data-idx", 0x1000);
- sysbus_init_mmio(dev, &phb->conf_mem);
- sysbus_init_mmio(dev, &phb->data_mem);
- return 0;
+ sysbus_init_mmio(SYS_BUS_DEVICE(dev), &phb->conf_mem);
+ sysbus_init_mmio(SYS_BUS_DEVICE(dev), &phb->data_mem);
}
static void dec_21154_pci_host_realize(PCIDevice *d, Error **errp)
@@ -150,9 +149,9 @@ static const TypeInfo dec_21154_pci_host_info = {
static void pci_dec_21154_device_class_init(ObjectClass *klass, void *data)
{
- SysBusDeviceClass *sdc = SYS_BUS_DEVICE_CLASS(klass);
+ DeviceClass *dc = DEVICE_CLASS(klass);
- sdc->init = pci_dec_21154_device_init;
+ dc->realize = pci_dec_21154_device_realize;
}
static const TypeInfo pci_dec_21154_device_info = {
--
2.17.1
^ permalink raw reply related [flat|nested] 55+ messages in thread
* Re: [Qemu-devel] [PATCH 15/22] pci-bridge/dec: Convert sysbus init function to realize function
2018-11-19 12:08 ` [Qemu-devel] [PATCH 15/22] pci-bridge/dec: " Mao Zhongyi
@ 2018-11-21 8:42 ` David Gibson
0 siblings, 0 replies; 55+ messages in thread
From: David Gibson @ 2018-11-21 8:42 UTC (permalink / raw)
To: Mao Zhongyi; +Cc: qemu-devel, mst, marcel.apfelbaum, qemu-ppc, Zhang Shengju
[-- Attachment #1: Type: text/plain, Size: 2333 bytes --]
On Mon, Nov 19, 2018 at 08:08:13PM +0800, Mao Zhongyi wrote:
> Use DeviceClass rather than SysBusDeviceClass in
> pci_dec_21154_device_class_init().
>
> Cc: david@gibson.dropbear.id.au
> Cc: mst@redhat.com
> Cc: marcel.apfelbaum@gmail.com
> Cc: qemu-ppc@nongnu.org
>
> Signed-off-by: Mao Zhongyi <maozhongyi@cmss.chinamobile.com>
> Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
> ---
> hw/pci-bridge/dec.c | 11 +++++------
> 1 file changed, 5 insertions(+), 6 deletions(-)
>
> diff --git a/hw/pci-bridge/dec.c b/hw/pci-bridge/dec.c
> index 84492d5e5f..5b21c20e50 100644
> --- a/hw/pci-bridge/dec.c
> +++ b/hw/pci-bridge/dec.c
> @@ -98,7 +98,7 @@ PCIBus *pci_dec_21154_init(PCIBus *parent_bus, int devfn)
> return pci_bridge_get_sec_bus(br);
> }
>
> -static int pci_dec_21154_device_init(SysBusDevice *dev)
> +static void pci_dec_21154_device_realize(DeviceState *dev, Error **errp)
> {
> PCIHostState *phb;
>
> @@ -108,9 +108,8 @@ static int pci_dec_21154_device_init(SysBusDevice *dev)
> dev, "pci-conf-idx", 0x1000);
> memory_region_init_io(&phb->data_mem, OBJECT(dev), &pci_host_data_le_ops,
> dev, "pci-data-idx", 0x1000);
> - sysbus_init_mmio(dev, &phb->conf_mem);
> - sysbus_init_mmio(dev, &phb->data_mem);
> - return 0;
> + sysbus_init_mmio(SYS_BUS_DEVICE(dev), &phb->conf_mem);
> + sysbus_init_mmio(SYS_BUS_DEVICE(dev), &phb->data_mem);
> }
>
> static void dec_21154_pci_host_realize(PCIDevice *d, Error **errp)
> @@ -150,9 +149,9 @@ static const TypeInfo dec_21154_pci_host_info = {
>
> static void pci_dec_21154_device_class_init(ObjectClass *klass, void *data)
> {
> - SysBusDeviceClass *sdc = SYS_BUS_DEVICE_CLASS(klass);
> + DeviceClass *dc = DEVICE_CLASS(klass);
>
> - sdc->init = pci_dec_21154_device_init;
> + dc->realize = pci_dec_21154_device_realize;
> }
>
> static const TypeInfo pci_dec_21154_device_info = {
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 55+ messages in thread
* [Qemu-devel] [PATCH 16/22] timer/etraxfs_timer: Convert sysbus init function to realize function
2018-11-19 12:07 [Qemu-devel] [PATCH 00/22] QOM'ify SysBusDeviceClass->init Mao Zhongyi
` (14 preceding siblings ...)
2018-11-19 12:08 ` [Qemu-devel] [PATCH 15/22] pci-bridge/dec: " Mao Zhongyi
@ 2018-11-19 12:08 ` Mao Zhongyi
2018-11-19 12:08 ` [Qemu-devel] [PATCH 17/22] timer/grlib_gptimer: " Mao Zhongyi
` (7 subsequent siblings)
23 siblings, 0 replies; 55+ messages in thread
From: Mao Zhongyi @ 2018-11-19 12:08 UTC (permalink / raw)
To: qemu-devel; +Cc: Mao Zhongyi, edgar.iglesias, Zhang Shengju
Use DeviceClass rather than SysBusDeviceClass in
etraxfs_timer_class_init().
Cc: edgar.iglesias@gmail.com
Signed-off-by: Mao Zhongyi <maozhongyi@cmss.chinamobile.com>
Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com>
---
hw/timer/etraxfs_timer.c | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/hw/timer/etraxfs_timer.c b/hw/timer/etraxfs_timer.c
index d13bc30b2d..e8c53b836e 100644
--- a/hw/timer/etraxfs_timer.c
+++ b/hw/timer/etraxfs_timer.c
@@ -315,7 +315,7 @@ static void etraxfs_timer_reset(void *opaque)
qemu_irq_lower(t->irq);
}
-static int etraxfs_timer_init(SysBusDevice *dev)
+static void etraxfs_timer_realize(DeviceState *dev, Error **errp)
{
ETRAXTimerState *t = ETRAX_TIMER(dev);
@@ -326,21 +326,20 @@ static int etraxfs_timer_init(SysBusDevice *dev)
t->ptimer_t1 = ptimer_init(t->bh_t1, PTIMER_POLICY_DEFAULT);
t->ptimer_wd = ptimer_init(t->bh_wd, PTIMER_POLICY_DEFAULT);
- sysbus_init_irq(dev, &t->irq);
- sysbus_init_irq(dev, &t->nmi);
+ sysbus_init_irq(SYS_BUS_DEVICE(dev), &t->irq);
+ sysbus_init_irq(SYS_BUS_DEVICE(dev), &t->nmi);
memory_region_init_io(&t->mmio, OBJECT(t), &timer_ops, t,
"etraxfs-timer", 0x5c);
- sysbus_init_mmio(dev, &t->mmio);
+ sysbus_init_mmio(SYS_BUS_DEVICE(dev), &t->mmio);
qemu_register_reset(etraxfs_timer_reset, t);
- return 0;
}
static void etraxfs_timer_class_init(ObjectClass *klass, void *data)
{
- SysBusDeviceClass *sdc = SYS_BUS_DEVICE_CLASS(klass);
+ DeviceClass *dc = DEVICE_CLASS(klass);
- sdc->init = etraxfs_timer_init;
+ dc->realize = etraxfs_timer_realize;
}
static const TypeInfo etraxfs_timer_info = {
--
2.17.1
^ permalink raw reply related [flat|nested] 55+ messages in thread
* [Qemu-devel] [PATCH 17/22] timer/grlib_gptimer: Convert sysbus init function to realize function
2018-11-19 12:07 [Qemu-devel] [PATCH 00/22] QOM'ify SysBusDeviceClass->init Mao Zhongyi
` (15 preceding siblings ...)
2018-11-19 12:08 ` [Qemu-devel] [PATCH 16/22] timer/etraxfs_timer: " Mao Zhongyi
@ 2018-11-19 12:08 ` Mao Zhongyi
2018-11-19 12:08 ` [Qemu-devel] [PATCH 18/22] timer/puv3_ost: " Mao Zhongyi
` (6 subsequent siblings)
23 siblings, 0 replies; 55+ messages in thread
From: Mao Zhongyi @ 2018-11-19 12:08 UTC (permalink / raw)
To: qemu-devel; +Cc: Mao Zhongyi, chouteau, Zhang Shengju
Use DeviceClass rather than SysBusDeviceClass in
grlib_gptimer_class_init().
Cc: chouteau@adacore.com
Signed-off-by: Mao Zhongyi <maozhongyi@cmss.chinamobile.com>
Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com>
---
hw/timer/grlib_gptimer.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/hw/timer/grlib_gptimer.c b/hw/timer/grlib_gptimer.c
index 4ed96e970a..c4d739708f 100644
--- a/hw/timer/grlib_gptimer.c
+++ b/hw/timer/grlib_gptimer.c
@@ -347,7 +347,7 @@ static void grlib_gptimer_reset(DeviceState *d)
}
}
-static int grlib_gptimer_init(SysBusDevice *dev)
+static void grlib_gptimer_realize(DeviceState *dev, Error **errp)
{
GPTimerUnit *unit = GRLIB_GPTIMER(dev);
unsigned int i;
@@ -366,7 +366,7 @@ static int grlib_gptimer_init(SysBusDevice *dev)
timer->id = i;
/* One IRQ line for each timer */
- sysbus_init_irq(dev, &timer->irq);
+ sysbus_init_irq(SYS_BUS_DEVICE(dev), &timer->irq);
ptimer_set_freq(timer->ptimer, unit->freq_hz);
}
@@ -375,8 +375,7 @@ static int grlib_gptimer_init(SysBusDevice *dev)
unit, "gptimer",
UNIT_REG_SIZE + GPTIMER_REG_SIZE * unit->nr_timers);
- sysbus_init_mmio(dev, &unit->iomem);
- return 0;
+ sysbus_init_mmio(SYS_BUS_DEVICE(dev), &unit->iomem);
}
static Property grlib_gptimer_properties[] = {
@@ -389,9 +388,8 @@ static Property grlib_gptimer_properties[] = {
static void grlib_gptimer_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
- SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
- k->init = grlib_gptimer_init;
+ dc->realize = grlib_gptimer_realize;
dc->reset = grlib_gptimer_reset;
dc->props = grlib_gptimer_properties;
}
--
2.17.1
^ permalink raw reply related [flat|nested] 55+ messages in thread
* [Qemu-devel] [PATCH 18/22] timer/puv3_ost: Convert sysbus init function to realize function
2018-11-19 12:07 [Qemu-devel] [PATCH 00/22] QOM'ify SysBusDeviceClass->init Mao Zhongyi
` (16 preceding siblings ...)
2018-11-19 12:08 ` [Qemu-devel] [PATCH 17/22] timer/grlib_gptimer: " Mao Zhongyi
@ 2018-11-19 12:08 ` Mao Zhongyi
2018-11-19 12:08 ` [Qemu-devel] [PATCH 19/22] usb/tusb6010: " Mao Zhongyi
` (5 subsequent siblings)
23 siblings, 0 replies; 55+ messages in thread
From: Mao Zhongyi @ 2018-11-19 12:08 UTC (permalink / raw)
To: qemu-devel; +Cc: Mao Zhongyi, gxt, Zhang Shengju
Use DeviceClass rather than SysBusDeviceClass in
puv3_ost_class_init().
Cc: gxt@mprc.pku.edu.cn
Signed-off-by: Mao Zhongyi <maozhongyi@cmss.chinamobile.com>
Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com>
---
hw/timer/puv3_ost.c | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/hw/timer/puv3_ost.c b/hw/timer/puv3_ost.c
index 0b3d717e60..853b96dbde 100644
--- a/hw/timer/puv3_ost.c
+++ b/hw/timer/puv3_ost.c
@@ -113,7 +113,7 @@ static void puv3_ost_tick(void *opaque)
}
}
-static int puv3_ost_init(SysBusDevice *dev)
+static void puv3_ost_realize(DeviceState *dev, Error **errp)
{
PUV3OSTState *s = PUV3_OST(dev);
@@ -122,7 +122,7 @@ static int puv3_ost_init(SysBusDevice *dev)
s->reg_OSMR0 = 0;
s->reg_OSCR = 0;
- sysbus_init_irq(dev, &s->irq);
+ sysbus_init_irq(SYS_BUS_DEVICE(dev), &s->irq);
s->bh = qemu_bh_new(puv3_ost_tick, s);
s->ptimer = ptimer_init(s->bh, PTIMER_POLICY_DEFAULT);
@@ -130,16 +130,14 @@ static int puv3_ost_init(SysBusDevice *dev)
memory_region_init_io(&s->iomem, OBJECT(s), &puv3_ost_ops, s, "puv3_ost",
PUV3_REGS_OFFSET);
- sysbus_init_mmio(dev, &s->iomem);
-
- return 0;
+ sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->iomem);
}
static void puv3_ost_class_init(ObjectClass *klass, void *data)
{
- SysBusDeviceClass *sdc = SYS_BUS_DEVICE_CLASS(klass);
+ DeviceClass *dc = DEVICE_CLASS(klass);
- sdc->init = puv3_ost_init;
+ dc->realize = puv3_ost_realize;
}
static const TypeInfo puv3_ost_info = {
--
2.17.1
^ permalink raw reply related [flat|nested] 55+ messages in thread
* [Qemu-devel] [PATCH 19/22] usb/tusb6010: Convert sysbus init function to realize function
2018-11-19 12:07 [Qemu-devel] [PATCH 00/22] QOM'ify SysBusDeviceClass->init Mao Zhongyi
` (17 preceding siblings ...)
2018-11-19 12:08 ` [Qemu-devel] [PATCH 18/22] timer/puv3_ost: " Mao Zhongyi
@ 2018-11-19 12:08 ` Mao Zhongyi
2018-11-19 12:08 ` [Qemu-devel] [PATCH 20/22] xen_backend: " Mao Zhongyi
` (4 subsequent siblings)
23 siblings, 0 replies; 55+ messages in thread
From: Mao Zhongyi @ 2018-11-19 12:08 UTC (permalink / raw)
To: qemu-devel; +Cc: Mao Zhongyi, kraxel, Zhang Shengju
Use DeviceClass rather than SysBusDeviceClass in
tusb6010_class_init().
Cc: kraxel@redhat.com
Signed-off-by: Mao Zhongyi <maozhongyi@cmss.chinamobile.com>
Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com>
---
hw/usb/tusb6010.c | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)
diff --git a/hw/usb/tusb6010.c b/hw/usb/tusb6010.c
index a2128024c1..0712281c42 100644
--- a/hw/usb/tusb6010.c
+++ b/hw/usb/tusb6010.c
@@ -808,29 +808,26 @@ static void tusb6010_reset(DeviceState *dev)
musb_reset(s->musb);
}
-static int tusb6010_init(SysBusDevice *sbd)
+static void tusb6010_realize(DeviceState *dev, Error **errp)
{
- DeviceState *dev = DEVICE(sbd);
TUSBState *s = TUSB(dev);
s->otg_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, tusb_otg_tick, s);
s->pwr_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, tusb_power_tick, s);
memory_region_init_io(&s->iomem[1], OBJECT(s), &tusb_async_ops, s,
"tusb-async", UINT32_MAX);
- sysbus_init_mmio(sbd, &s->iomem[0]);
- sysbus_init_mmio(sbd, &s->iomem[1]);
- sysbus_init_irq(sbd, &s->irq);
+ sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->iomem[0]);
+ sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->iomem[1]);
+ sysbus_init_irq(SYS_BUS_DEVICE(dev), &s->irq);
qdev_init_gpio_in(dev, tusb6010_irq, musb_irq_max + 1);
s->musb = musb_init(dev, 1);
- return 0;
}
static void tusb6010_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
- SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
- k->init = tusb6010_init;
+ dc->realize = tusb6010_realize;
dc->reset = tusb6010_reset;
}
--
2.17.1
^ permalink raw reply related [flat|nested] 55+ messages in thread
* [Qemu-devel] [PATCH 20/22] xen_backend: Convert sysbus init function to realize function
2018-11-19 12:07 [Qemu-devel] [PATCH 00/22] QOM'ify SysBusDeviceClass->init Mao Zhongyi
` (18 preceding siblings ...)
2018-11-19 12:08 ` [Qemu-devel] [PATCH 19/22] usb/tusb6010: " Mao Zhongyi
@ 2018-11-19 12:08 ` Mao Zhongyi
2018-11-20 14:49 ` Peter Maydell
2018-11-19 12:08 ` Mao Zhongyi
` (3 subsequent siblings)
23 siblings, 1 reply; 55+ messages in thread
From: Mao Zhongyi @ 2018-11-19 12:08 UTC (permalink / raw)
To: qemu-devel
Cc: Mao Zhongyi, sstabellini, anthony.perard, xen-devel, Zhang Shengju
Use DeviceClass rather than SysBusDeviceClass in
xen_sysdev_class_init().
Cc: sstabellini@kernel.org
Cc: anthony.perard@citrix.com
Cc: xen-devel@lists.xenproject.org
Signed-off-by: Mao Zhongyi <maozhongyi@cmss.chinamobile.com>
Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com>
---
hw/xen/xen_backend.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/hw/xen/xen_backend.c b/hw/xen/xen_backend.c
index 9a8e8771ec..73b0ed0169 100644
--- a/hw/xen/xen_backend.c
+++ b/hw/xen/xen_backend.c
@@ -809,9 +809,8 @@ static const TypeInfo xensysbus_info = {
}
};
-static int xen_sysdev_init(SysBusDevice *dev)
+static void xen_sysdev_realize(DeviceState *dev, Error **errp)
{
- return 0;
}
static Property xen_sysdev_properties[] = {
@@ -821,9 +820,8 @@ static Property xen_sysdev_properties[] = {
static void xen_sysdev_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
- SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
- k->init = xen_sysdev_init;
+ dc->realize = xen_sysdev_realize;
dc->props = xen_sysdev_properties;
dc->bus_type = TYPE_XENSYSBUS;
}
--
2.17.1
^ permalink raw reply related [flat|nested] 55+ messages in thread
* Re: [Qemu-devel] [PATCH 20/22] xen_backend: Convert sysbus init function to realize function
2018-11-19 12:08 ` [Qemu-devel] [PATCH 20/22] xen_backend: " Mao Zhongyi
@ 2018-11-20 14:49 ` Peter Maydell
0 siblings, 0 replies; 55+ messages in thread
From: Peter Maydell @ 2018-11-20 14:49 UTC (permalink / raw)
To: Mao Zhongyi
Cc: QEMU Developers, Anthony PERARD, open list:X86,
Stefano Stabellini, Zhang Shengju
On 19 November 2018 at 12:08, Mao Zhongyi
<maozhongyi@cmss.chinamobile.com> wrote:
> Use DeviceClass rather than SysBusDeviceClass in
> xen_sysdev_class_init().
>
> Cc: sstabellini@kernel.org
> Cc: anthony.perard@citrix.com
> Cc: xen-devel@lists.xenproject.org
>
> Signed-off-by: Mao Zhongyi <maozhongyi@cmss.chinamobile.com>
> Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com>
> ---
> hw/xen/xen_backend.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/hw/xen/xen_backend.c b/hw/xen/xen_backend.c
> index 9a8e8771ec..73b0ed0169 100644
> --- a/hw/xen/xen_backend.c
> +++ b/hw/xen/xen_backend.c
> @@ -809,9 +809,8 @@ static const TypeInfo xensysbus_info = {
> }
> };
>
> -static int xen_sysdev_init(SysBusDevice *dev)
> +static void xen_sysdev_realize(DeviceState *dev, Error **errp)
> {
> - return 0;
> }
>
> static Property xen_sysdev_properties[] = {
> @@ -821,9 +820,8 @@ static Property xen_sysdev_properties[] = {
> static void xen_sysdev_class_init(ObjectClass *klass, void *data)
> {
> DeviceClass *dc = DEVICE_CLASS(klass);
> - SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
>
> - k->init = xen_sysdev_init;
> + dc->realize = xen_sysdev_realize;
> dc->props = xen_sysdev_properties;
> dc->bus_type = TYPE_XENSYSBUS;
> }
If the realize function doesn't do anything at all, can't
we just omit it ?
thanks
-- PMM
^ permalink raw reply [flat|nested] 55+ messages in thread
* Re: [Qemu-devel] [PATCH 20/22] xen_backend: Convert sysbus init function to realize function
@ 2018-11-20 14:49 ` Peter Maydell
0 siblings, 0 replies; 55+ messages in thread
From: Peter Maydell @ 2018-11-20 14:49 UTC (permalink / raw)
To: Mao Zhongyi
Cc: Anthony PERARD, open list:X86, Stefano Stabellini,
QEMU Developers, Zhang Shengju
On 19 November 2018 at 12:08, Mao Zhongyi
<maozhongyi@cmss.chinamobile.com> wrote:
> Use DeviceClass rather than SysBusDeviceClass in
> xen_sysdev_class_init().
>
> Cc: sstabellini@kernel.org
> Cc: anthony.perard@citrix.com
> Cc: xen-devel@lists.xenproject.org
>
> Signed-off-by: Mao Zhongyi <maozhongyi@cmss.chinamobile.com>
> Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com>
> ---
> hw/xen/xen_backend.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/hw/xen/xen_backend.c b/hw/xen/xen_backend.c
> index 9a8e8771ec..73b0ed0169 100644
> --- a/hw/xen/xen_backend.c
> +++ b/hw/xen/xen_backend.c
> @@ -809,9 +809,8 @@ static const TypeInfo xensysbus_info = {
> }
> };
>
> -static int xen_sysdev_init(SysBusDevice *dev)
> +static void xen_sysdev_realize(DeviceState *dev, Error **errp)
> {
> - return 0;
> }
>
> static Property xen_sysdev_properties[] = {
> @@ -821,9 +820,8 @@ static Property xen_sysdev_properties[] = {
> static void xen_sysdev_class_init(ObjectClass *klass, void *data)
> {
> DeviceClass *dc = DEVICE_CLASS(klass);
> - SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
>
> - k->init = xen_sysdev_init;
> + dc->realize = xen_sysdev_realize;
> dc->props = xen_sysdev_properties;
> dc->bus_type = TYPE_XENSYSBUS;
> }
If the realize function doesn't do anything at all, can't
we just omit it ?
thanks
-- PMM
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply [flat|nested] 55+ messages in thread
* [PATCH 20/22] xen_backend: Convert sysbus init function to realize function
2018-11-19 12:07 [Qemu-devel] [PATCH 00/22] QOM'ify SysBusDeviceClass->init Mao Zhongyi
` (19 preceding siblings ...)
2018-11-19 12:08 ` [Qemu-devel] [PATCH 20/22] xen_backend: " Mao Zhongyi
@ 2018-11-19 12:08 ` Mao Zhongyi
2018-11-19 12:08 ` [Qemu-devel] [PATCH 21/22] event-facility: Change SysBusDeviceClass *sbdc to SysBusDeviceClass *sbc Mao Zhongyi
` (2 subsequent siblings)
23 siblings, 0 replies; 55+ messages in thread
From: Mao Zhongyi @ 2018-11-19 12:08 UTC (permalink / raw)
To: qemu-devel
Cc: anthony.perard, xen-devel, sstabellini, Zhang Shengju, Mao Zhongyi
Use DeviceClass rather than SysBusDeviceClass in
xen_sysdev_class_init().
Cc: sstabellini@kernel.org
Cc: anthony.perard@citrix.com
Cc: xen-devel@lists.xenproject.org
Signed-off-by: Mao Zhongyi <maozhongyi@cmss.chinamobile.com>
Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com>
---
hw/xen/xen_backend.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/hw/xen/xen_backend.c b/hw/xen/xen_backend.c
index 9a8e8771ec..73b0ed0169 100644
--- a/hw/xen/xen_backend.c
+++ b/hw/xen/xen_backend.c
@@ -809,9 +809,8 @@ static const TypeInfo xensysbus_info = {
}
};
-static int xen_sysdev_init(SysBusDevice *dev)
+static void xen_sysdev_realize(DeviceState *dev, Error **errp)
{
- return 0;
}
static Property xen_sysdev_properties[] = {
@@ -821,9 +820,8 @@ static Property xen_sysdev_properties[] = {
static void xen_sysdev_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
- SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
- k->init = xen_sysdev_init;
+ dc->realize = xen_sysdev_realize;
dc->props = xen_sysdev_properties;
dc->bus_type = TYPE_XENSYSBUS;
}
--
2.17.1
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply related [flat|nested] 55+ messages in thread
* [Qemu-devel] [PATCH 21/22] event-facility: Change SysBusDeviceClass *sbdc to SysBusDeviceClass *sbc
2018-11-19 12:07 [Qemu-devel] [PATCH 00/22] QOM'ify SysBusDeviceClass->init Mao Zhongyi
` (20 preceding siblings ...)
2018-11-19 12:08 ` Mao Zhongyi
@ 2018-11-19 12:08 ` Mao Zhongyi
2018-11-19 12:25 ` Cornelia Huck
2018-11-19 12:08 ` [Qemu-devel] [PATCH 22/22] core/sysbus: remove the SysBusDeviceClass::init path Mao Zhongyi
2018-11-19 12:27 ` Cornelia Huck
23 siblings, 1 reply; 55+ messages in thread
From: Mao Zhongyi @ 2018-11-19 12:08 UTC (permalink / raw)
To: qemu-devel
Cc: Mao Zhongyi, cohuck, borntraeger, rth, david, qemu-s390x, Zhang Shengju
Most of the SysBusDeviceClass variables are named sbc,
and sbdc here is a bit weird, so changing sbdc to keep
it consistent with others might look good.
Cc: cohuck@redhat.com
Cc: borntraeger@de.ibm.com
Cc: rth@twiddle.net
Cc: david@redhat.com
Cc: qemu-s390x@nongnu.org
Signed-off-by: Mao Zhongyi <maozhongyi@cmss.chinamobile.com>
Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com>
---
hw/s390x/event-facility.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/hw/s390x/event-facility.c b/hw/s390x/event-facility.c
index ee5b83448b..759e7bee01 100644
--- a/hw/s390x/event-facility.c
+++ b/hw/s390x/event-facility.c
@@ -484,8 +484,8 @@ static void reset_event_facility(DeviceState *dev)
static void init_event_facility_class(ObjectClass *klass, void *data)
{
- SysBusDeviceClass *sbdc = SYS_BUS_DEVICE_CLASS(klass);
- DeviceClass *dc = DEVICE_CLASS(sbdc);
+ SysBusDeviceClass *sbc = SYS_BUS_DEVICE_CLASS(klass);
+ DeviceClass *dc = DEVICE_CLASS(sbc);
SCLPEventFacilityClass *k = EVENT_FACILITY_CLASS(dc);
dc->reset = reset_event_facility;
--
2.17.1
^ permalink raw reply related [flat|nested] 55+ messages in thread
* Re: [Qemu-devel] [PATCH 21/22] event-facility: Change SysBusDeviceClass *sbdc to SysBusDeviceClass *sbc
2018-11-19 12:08 ` [Qemu-devel] [PATCH 21/22] event-facility: Change SysBusDeviceClass *sbdc to SysBusDeviceClass *sbc Mao Zhongyi
@ 2018-11-19 12:25 ` Cornelia Huck
2018-11-19 14:10 ` [Qemu-devel] [qemu-s390x] " Thomas Huth
0 siblings, 1 reply; 55+ messages in thread
From: Cornelia Huck @ 2018-11-19 12:25 UTC (permalink / raw)
To: Mao Zhongyi
Cc: qemu-devel, borntraeger, rth, david, qemu-s390x, Zhang Shengju
On Mon, 19 Nov 2018 20:08:19 +0800
Mao Zhongyi <maozhongyi@cmss.chinamobile.com> wrote:
> Most of the SysBusDeviceClass variables are named sbc,
> and sbdc here is a bit weird, so changing sbdc to keep
> it consistent with others might look good.
A quick git grep also gives sbd and k as variable names, and it is used
in a total of two lines which have not been touched since 2013, so...
meh. If others like the change, I'm not opposed to merging, though.
>
> Cc: cohuck@redhat.com
> Cc: borntraeger@de.ibm.com
> Cc: rth@twiddle.net
> Cc: david@redhat.com
> Cc: qemu-s390x@nongnu.org
>
> Signed-off-by: Mao Zhongyi <maozhongyi@cmss.chinamobile.com>
> Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com>
> ---
> hw/s390x/event-facility.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/hw/s390x/event-facility.c b/hw/s390x/event-facility.c
> index ee5b83448b..759e7bee01 100644
> --- a/hw/s390x/event-facility.c
> +++ b/hw/s390x/event-facility.c
> @@ -484,8 +484,8 @@ static void reset_event_facility(DeviceState *dev)
>
> static void init_event_facility_class(ObjectClass *klass, void *data)
> {
> - SysBusDeviceClass *sbdc = SYS_BUS_DEVICE_CLASS(klass);
> - DeviceClass *dc = DEVICE_CLASS(sbdc);
> + SysBusDeviceClass *sbc = SYS_BUS_DEVICE_CLASS(klass);
> + DeviceClass *dc = DEVICE_CLASS(sbc);
> SCLPEventFacilityClass *k = EVENT_FACILITY_CLASS(dc);
>
> dc->reset = reset_event_facility;
^ permalink raw reply [flat|nested] 55+ messages in thread
* Re: [Qemu-devel] [qemu-s390x] [PATCH 21/22] event-facility: Change SysBusDeviceClass *sbdc to SysBusDeviceClass *sbc
2018-11-19 12:25 ` Cornelia Huck
@ 2018-11-19 14:10 ` Thomas Huth
2018-11-20 1:10 ` [Qemu-devel] [qemu-s390x] [PATCH 21/22] event-facility: ChangeSysBusDeviceClass " maozy
0 siblings, 1 reply; 55+ messages in thread
From: Thomas Huth @ 2018-11-19 14:10 UTC (permalink / raw)
To: Cornelia Huck, Mao Zhongyi
Cc: david, qemu-devel, borntraeger, qemu-s390x, Zhang Shengju, rth
On 2018-11-19 13:25, Cornelia Huck wrote:
> On Mon, 19 Nov 2018 20:08:19 +0800
> Mao Zhongyi <maozhongyi@cmss.chinamobile.com> wrote:
>
>> Most of the SysBusDeviceClass variables are named sbc,
>> and sbdc here is a bit weird, so changing sbdc to keep
>> it consistent with others might look good.
>
> A quick git grep also gives sbd and k as variable names, and it is used
> in a total of two lines which have not been touched since 2013, so...
> meh. If others like the change, I'm not opposed to merging, though.
I think I agree with Cornelia, just changing the variable name because
it's named differently in a couple of other places is just unnecessary
code churn, which makes "git blame" output harder to read later. I'd
suggest to drop this patch, too.
Thomas
^ permalink raw reply [flat|nested] 55+ messages in thread
* Re: [Qemu-devel] [qemu-s390x] [PATCH 21/22] event-facility: ChangeSysBusDeviceClass *sbdc to SysBusDeviceClass *sbc
2018-11-19 14:10 ` [Qemu-devel] [qemu-s390x] " Thomas Huth
@ 2018-11-20 1:10 ` maozy
0 siblings, 0 replies; 55+ messages in thread
From: maozy @ 2018-11-20 1:10 UTC (permalink / raw)
To: Thomas Huth, Cornelia Huck
Cc: david, qemu-devel, borntraeger, qemu-s390x, Zhang Shengju, rth
On 11/19/18 10:10 PM, Thomas Huth wrote:
> On 2018-11-19 13:25, Cornelia Huck wrote:
>> On Mon, 19 Nov 2018 20:08:19 +0800
>> Mao Zhongyi <maozhongyi@cmss.chinamobile.com> wrote:
>>
>>> Most of the SysBusDeviceClass variables are named sbc,
>>> and sbdc here is a bit weird, so changing sbdc to keep
>>> it consistent with others might look good.
>>
>> A quick git grep also gives sbd and k as variable names, and it is used
>> in a total of two lines which have not been touched since 2013, so...
>> meh. If others like the change, I'm not opposed to merging, though.
>
> I think I agree with Cornelia, just changing the variable name because
> it's named differently in a couple of other places is just unnecessary
> code churn, which makes "git blame" output harder to read later. I'd
> suggest to drop this patch, too.
>
Ok, I got it. :)
Thanks,
Mao
> Thomas
>
^ permalink raw reply [flat|nested] 55+ messages in thread
* [Qemu-devel] [PATCH 22/22] core/sysbus: remove the SysBusDeviceClass::init path
2018-11-19 12:07 [Qemu-devel] [PATCH 00/22] QOM'ify SysBusDeviceClass->init Mao Zhongyi
` (21 preceding siblings ...)
2018-11-19 12:08 ` [Qemu-devel] [PATCH 21/22] event-facility: Change SysBusDeviceClass *sbdc to SysBusDeviceClass *sbc Mao Zhongyi
@ 2018-11-19 12:08 ` Mao Zhongyi
2018-11-19 23:31 ` Eduardo Habkost
2018-11-19 12:27 ` Cornelia Huck
23 siblings, 1 reply; 55+ messages in thread
From: Mao Zhongyi @ 2018-11-19 12:08 UTC (permalink / raw)
To: qemu-devel
Cc: Mao Zhongyi, ehabkost, thuth, pbonzini, armbru, peter.maydell,
richard.henderson, alistair.francis, Zhang Shengju
Currently, all sysbus devices have been converted to realize(),
so remove this path.
Cc: ehabkost@redhat.com
Cc: thuth@redhat.com
Cc: pbonzini@redhat.com
Cc: armbru@redhat.com
Cc: peter.maydell@linaro.org
Cc: richard.henderson@linaro.org
Cc: alistair.francis@wdc.com
Signed-off-by: Mao Zhongyi <maozhongyi@cmss.chinamobile.com>
Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com>
---
hw/core/sysbus.c | 15 ---------------
include/hw/sysbus.h | 3 ---
2 files changed, 18 deletions(-)
diff --git a/hw/core/sysbus.c b/hw/core/sysbus.c
index 7ac36ad3e7..030ad426c1 100644
--- a/hw/core/sysbus.c
+++ b/hw/core/sysbus.c
@@ -201,20 +201,6 @@ void sysbus_init_ioports(SysBusDevice *dev, uint32_t ioport, uint32_t size)
}
}
-/* TODO remove once all sysbus devices have been converted to realize */
-static void sysbus_realize(DeviceState *dev, Error **errp)
-{
- SysBusDevice *sd = SYS_BUS_DEVICE(dev);
- SysBusDeviceClass *sbc = SYS_BUS_DEVICE_GET_CLASS(sd);
-
- if (!sbc->init) {
- return;
- }
- if (sbc->init(sd) < 0) {
- error_setg(errp, "Device initialization failed");
- }
-}
-
DeviceState *sysbus_create_varargs(const char *name,
hwaddr addr, ...)
{
@@ -327,7 +313,6 @@ MemoryRegion *sysbus_address_space(SysBusDevice *dev)
static void sysbus_device_class_init(ObjectClass *klass, void *data)
{
DeviceClass *k = DEVICE_CLASS(klass);
- k->realize = sysbus_realize;
k->bus_type = TYPE_SYSTEM_BUS;
/*
* device_add plugs devices into a suitable bus. For "real" buses,
diff --git a/include/hw/sysbus.h b/include/hw/sysbus.h
index 0b59a3b8d6..1aedcf05c9 100644
--- a/include/hw/sysbus.h
+++ b/include/hw/sysbus.h
@@ -38,9 +38,6 @@ typedef struct SysBusDevice SysBusDevice;
typedef struct SysBusDeviceClass {
/*< private >*/
DeviceClass parent_class;
- /*< public >*/
-
- int (*init)(SysBusDevice *dev);
/*
* Let the sysbus device format its own non-PIO, non-MMIO unit address.
--
2.17.1
^ permalink raw reply related [flat|nested] 55+ messages in thread
* Re: [Qemu-devel] [PATCH 22/22] core/sysbus: remove the SysBusDeviceClass::init path
2018-11-19 12:08 ` [Qemu-devel] [PATCH 22/22] core/sysbus: remove the SysBusDeviceClass::init path Mao Zhongyi
@ 2018-11-19 23:31 ` Eduardo Habkost
2018-11-19 23:39 ` Eduardo Habkost
2018-11-23 3:10 ` [Qemu-devel] [PATCH 22/22] core/sysbus: remove the SysBusDeviceClass::initpath maozy
0 siblings, 2 replies; 55+ messages in thread
From: Eduardo Habkost @ 2018-11-19 23:31 UTC (permalink / raw)
To: Mao Zhongyi
Cc: qemu-devel, thuth, pbonzini, armbru, peter.maydell,
richard.henderson, alistair.francis, Zhang Shengju
On Mon, Nov 19, 2018 at 08:08:20PM +0800, Mao Zhongyi wrote:
> Currently, all sysbus devices have been converted to realize(),
> so remove this path.
>
> Cc: ehabkost@redhat.com
> Cc: thuth@redhat.com
> Cc: pbonzini@redhat.com
> Cc: armbru@redhat.com
> Cc: peter.maydell@linaro.org
> Cc: richard.henderson@linaro.org
> Cc: alistair.francis@wdc.com
>
> Signed-off-by: Mao Zhongyi <maozhongyi@cmss.chinamobile.com>
> Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com>
> ---
> hw/core/sysbus.c | 15 ---------------
> include/hw/sysbus.h | 3 ---
> 2 files changed, 18 deletions(-)
>
> diff --git a/hw/core/sysbus.c b/hw/core/sysbus.c
> index 7ac36ad3e7..030ad426c1 100644
> --- a/hw/core/sysbus.c
> +++ b/hw/core/sysbus.c
> @@ -201,20 +201,6 @@ void sysbus_init_ioports(SysBusDevice *dev, uint32_t ioport, uint32_t size)
> }
> }
>
> -/* TODO remove once all sysbus devices have been converted to realize */
> -static void sysbus_realize(DeviceState *dev, Error **errp)
> -{
> - SysBusDevice *sd = SYS_BUS_DEVICE(dev);
> - SysBusDeviceClass *sbc = SYS_BUS_DEVICE_GET_CLASS(sd);
> -
> - if (!sbc->init) {
> - return;
> - }
> - if (sbc->init(sd) < 0) {
> - error_setg(errp, "Device initialization failed");
> - }
> -}
Nice. :)
> -
> DeviceState *sysbus_create_varargs(const char *name,
> hwaddr addr, ...)
> {
> @@ -327,7 +313,6 @@ MemoryRegion *sysbus_address_space(SysBusDevice *dev)
> static void sysbus_device_class_init(ObjectClass *klass, void *data)
> {
> DeviceClass *k = DEVICE_CLASS(klass);
> - k->realize = sysbus_realize;
Have you ensured this won't break any subclasses that
saved the original realize function on a parent_realize field?
Now they will have parent_realize set to NULL.
Most of them use device_class_set_parent_realize() to implement
that.
> k->bus_type = TYPE_SYSTEM_BUS;
> /*
> * device_add plugs devices into a suitable bus. For "real" buses,
> diff --git a/include/hw/sysbus.h b/include/hw/sysbus.h
> index 0b59a3b8d6..1aedcf05c9 100644
> --- a/include/hw/sysbus.h
> +++ b/include/hw/sysbus.h
> @@ -38,9 +38,6 @@ typedef struct SysBusDevice SysBusDevice;
> typedef struct SysBusDeviceClass {
> /*< private >*/
> DeviceClass parent_class;
> - /*< public >*/
> -
> - int (*init)(SysBusDevice *dev);
>
> /*
> * Let the sysbus device format its own non-PIO, non-MMIO unit address.
> --
> 2.17.1
>
>
>
--
Eduardo
^ permalink raw reply [flat|nested] 55+ messages in thread
* Re: [Qemu-devel] [PATCH 22/22] core/sysbus: remove the SysBusDeviceClass::init path
2018-11-19 23:31 ` Eduardo Habkost
@ 2018-11-19 23:39 ` Eduardo Habkost
2018-11-23 3:10 ` [Qemu-devel] [PATCH 22/22] core/sysbus: remove the SysBusDeviceClass::initpath maozy
1 sibling, 0 replies; 55+ messages in thread
From: Eduardo Habkost @ 2018-11-19 23:39 UTC (permalink / raw)
To: Mao Zhongyi
Cc: qemu-devel, thuth, pbonzini, armbru, peter.maydell,
richard.henderson, alistair.francis, Zhang Shengju
On Mon, Nov 19, 2018 at 09:31:39PM -0200, Eduardo Habkost wrote:
> On Mon, Nov 19, 2018 at 08:08:20PM +0800, Mao Zhongyi wrote:
> > Currently, all sysbus devices have been converted to realize(),
> > so remove this path.
> >
> > Cc: ehabkost@redhat.com
> > Cc: thuth@redhat.com
> > Cc: pbonzini@redhat.com
> > Cc: armbru@redhat.com
> > Cc: peter.maydell@linaro.org
> > Cc: richard.henderson@linaro.org
> > Cc: alistair.francis@wdc.com
> >
> > Signed-off-by: Mao Zhongyi <maozhongyi@cmss.chinamobile.com>
> > Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com>
> > ---
> > hw/core/sysbus.c | 15 ---------------
> > include/hw/sysbus.h | 3 ---
> > 2 files changed, 18 deletions(-)
> >
> > diff --git a/hw/core/sysbus.c b/hw/core/sysbus.c
> > index 7ac36ad3e7..030ad426c1 100644
> > --- a/hw/core/sysbus.c
> > +++ b/hw/core/sysbus.c
> > @@ -201,20 +201,6 @@ void sysbus_init_ioports(SysBusDevice *dev, uint32_t ioport, uint32_t size)
> > }
> > }
> >
> > -/* TODO remove once all sysbus devices have been converted to realize */
> > -static void sysbus_realize(DeviceState *dev, Error **errp)
> > -{
> > - SysBusDevice *sd = SYS_BUS_DEVICE(dev);
> > - SysBusDeviceClass *sbc = SYS_BUS_DEVICE_GET_CLASS(sd);
> > -
> > - if (!sbc->init) {
> > - return;
> > - }
> > - if (sbc->init(sd) < 0) {
> > - error_setg(errp, "Device initialization failed");
> > - }
> > -}
>
> Nice. :)
>
>
> > -
> > DeviceState *sysbus_create_varargs(const char *name,
> > hwaddr addr, ...)
> > {
> > @@ -327,7 +313,6 @@ MemoryRegion *sysbus_address_space(SysBusDevice *dev)
> > static void sysbus_device_class_init(ObjectClass *klass, void *data)
> > {
> > DeviceClass *k = DEVICE_CLASS(klass);
> > - k->realize = sysbus_realize;
>
> Have you ensured this won't break any subclasses that
> saved the original realize function on a parent_realize field?
> Now they will have parent_realize set to NULL.
>
> Most of them use device_class_set_parent_realize() to implement
> that.
Found one:
$ ./aarch64-softmmu/qemu-system-aarch64 -machine virt,iommu=smmuv3
Segmentation fault (core dumped)
(gdb) bt
#0 0x0000000000000000 in ()
#1 0x000055555596eabe in smmu_base_realize (dev=0x555556ac0cb0, errp=0x7fffffffc450) at /home/ehabkost/rh/proj/virt/qemu/hw/arm/smmu-common.c:428
#2 0x0000555555970322 in smmu_realize (d=0x555556ac0cb0, errp=0x7fffffffc4c0) at /home/ehabkost/rh/proj/virt/qemu/hw/arm/smmuv3.c:1390
#3 0x0000555555ac8f00 in device_set_realized (obj=<optimized out>, value=<optimized out>, errp=0x7fffffffc5b0) at hw/core/qdev.c:826
#4 0x0000555555c424a7 in property_set_bool (obj=0x555556ac0cb0, v=<optimized out>, name=<optimized out>, opaque=0x555556a05b70, errp=0x7fffffffc5b0) at qom/object.c:1991
#5 0x0000555555c468df in object_property_set_qobject (obj=obj@entry=0x555556ac0cb0, value=value@entry=0x555556ac2520, name=name@entry=0x555555de03f9 "realized", errp=errp@entry=0x7fffffffc5b0) at qom/qom-qobject.c:27
#6 0x0000555555c44355 in object_property_set_bool (obj=0x555556ac0cb0, value=<optimized out>, name=0x555555de03f9 "realized", errp=0x7fffffffc5b0) at qom/object.c:1249
#7 0x0000555555ac7e22 in qdev_init_nofail (dev=dev@entry=0x555556ac0cb0) at hw/core/qdev.c:313
#8 0x000055555592ef97 in create_smmu (bus=0x5555569970a0, pic=0x7fffffffc900, vms=<optimized out>) at /home/ehabkost/rh/proj/virt/qemu/hw/arm/virt.c:1058
#9 0x000055555592ef97 in create_pcie (pic=0x7fffffffc900, vms=<optimized out>) at /home/ehabkost/rh/proj/virt/qemu/hw/arm/virt.c:1208
#10 0x000055555592ef97 in machvirt_init (machine=0x55555663e9c0) at /home/ehabkost/rh/proj/virt/qemu/hw/arm/virt.c:1549
#11 0x0000555555acf013 in machine_run_board_init (machine=0x55555663e9c0) at hw/core/machine.c:834
#12 0x000055555581dab8 in main (argc=<optimized out>, argv=<optimized out>, envp=<optimized out>) at vl.c:4518
>
> > k->bus_type = TYPE_SYSTEM_BUS;
> > /*
> > * device_add plugs devices into a suitable bus. For "real" buses,
> > diff --git a/include/hw/sysbus.h b/include/hw/sysbus.h
> > index 0b59a3b8d6..1aedcf05c9 100644
> > --- a/include/hw/sysbus.h
> > +++ b/include/hw/sysbus.h
> > @@ -38,9 +38,6 @@ typedef struct SysBusDevice SysBusDevice;
> > typedef struct SysBusDeviceClass {
> > /*< private >*/
> > DeviceClass parent_class;
> > - /*< public >*/
> > -
> > - int (*init)(SysBusDevice *dev);
> >
> > /*
> > * Let the sysbus device format its own non-PIO, non-MMIO unit address.
> > --
> > 2.17.1
> >
> >
> >
>
> --
> Eduardo
--
Eduardo
^ permalink raw reply [flat|nested] 55+ messages in thread
* Re: [Qemu-devel] [PATCH 22/22] core/sysbus: remove the SysBusDeviceClass::initpath
2018-11-19 23:31 ` Eduardo Habkost
2018-11-19 23:39 ` Eduardo Habkost
@ 2018-11-23 3:10 ` maozy
2018-11-23 9:02 ` Peter Maydell
2018-11-23 18:16 ` Eduardo Habkost
1 sibling, 2 replies; 55+ messages in thread
From: maozy @ 2018-11-23 3:10 UTC (permalink / raw)
To: Eduardo Habkost
Cc: qemu-devel, thuth, pbonzini, armbru, peter.maydell,
richard.henderson, alistair.francis, Zhang Shengju
Hi, Eduardo
On 11/20/18 7:31 AM, Eduardo Habkost wrote:
> On Mon, Nov 19, 2018 at 08:08:20PM +0800, Mao Zhongyi wrote:
>> Currently, all sysbus devices have been converted to realize(),
>> so remove this path.
>>
>> Cc: ehabkost@redhat.com
>> Cc: thuth@redhat.com
>> Cc: pbonzini@redhat.com
>> Cc: armbru@redhat.com
>> Cc: peter.maydell@linaro.org
>> Cc: richard.henderson@linaro.org
>> Cc: alistair.francis@wdc.com
>>
>> Signed-off-by: Mao Zhongyi <maozhongyi@cmss.chinamobile.com>
>> Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com>
>> ---
>> hw/core/sysbus.c | 15 ---------------
>> include/hw/sysbus.h | 3 ---
>> 2 files changed, 18 deletions(-)
>>
>> diff --git a/hw/core/sysbus.c b/hw/core/sysbus.c
>> index 7ac36ad3e7..030ad426c1 100644
>> --- a/hw/core/sysbus.c
>> +++ b/hw/core/sysbus.c
>> @@ -201,20 +201,6 @@ void sysbus_init_ioports(SysBusDevice *dev, uint32_t ioport, uint32_t size)
>> }
>> }
>>
>> -/* TODO remove once all sysbus devices have been converted to realize */
>> -static void sysbus_realize(DeviceState *dev, Error **errp)
>> -{
>> - SysBusDevice *sd = SYS_BUS_DEVICE(dev);
>> - SysBusDeviceClass *sbc = SYS_BUS_DEVICE_GET_CLASS(sd);
>> -
>> - if (!sbc->init) {
>> - return;
>> - }
>> - if (sbc->init(sd) < 0) {
>> - error_setg(errp, "Device initialization failed");
>> - }
>> -}
>
> Nice. :)
>
>
>> -
>> DeviceState *sysbus_create_varargs(const char *name,
>> hwaddr addr, ...)
>> {
>> @@ -327,7 +313,6 @@ MemoryRegion *sysbus_address_space(SysBusDevice *dev)
>> static void sysbus_device_class_init(ObjectClass *klass, void *data)
>> {
>> DeviceClass *k = DEVICE_CLASS(klass);
>> - k->realize = sysbus_realize;
>
> Have you ensured this won't break any subclasses that
> saved the original realize function on a parent_realize field?
Thanks for the catch.
> Now they will have parent_realize set to NULL.
In order to void the subclasses whose parent_realize field is
set to NULL, the k->realize function must be retained even
though it doesn't do anything practical. Just like this:
-/* TODO remove once all sysbus devices have been converted to realize*/
static void sysbus_realize(DeviceState *dev, Error **errp)
{
- SysBusDevice *sd = SYS_BUS_DEVICE(dev);
- SysBusDeviceClass *sbc = SYS_BUS_DEVICE_GET_CLASS(sd);
-
- if (!sbc->init) {
- return;
- }
- if (sbc->init(sd) < 0) {
- error_setg(errp, "Device initialization failed");
- }
}
it doesn't look elegant, but I didn't think of a better way, if you
can give me some hints, I really appreciate it. :)
Thanks,
Mao
>
> Most of them use device_class_set_parent_realize() to implement
> that.
>
>> k->bus_type = TYPE_SYSTEM_BUS;
>> /*
>> * device_add plugs devices into a suitable bus. For "real" buses,
>> diff --git a/include/hw/sysbus.h b/include/hw/sysbus.h
>> index 0b59a3b8d6..1aedcf05c9 100644
>> --- a/include/hw/sysbus.h
>> +++ b/include/hw/sysbus.h
>> @@ -38,9 +38,6 @@ typedef struct SysBusDevice SysBusDevice;
>> typedef struct SysBusDeviceClass {
>> /*< private >*/
>> DeviceClass parent_class;
>> - /*< public >*/
>> -
>> - int (*init)(SysBusDevice *dev);
>>
>> /*
>> * Let the sysbus device format its own non-PIO, non-MMIO unit address.
>> --
>> 2.17.1
>>
>>
>>
>
^ permalink raw reply [flat|nested] 55+ messages in thread
* Re: [Qemu-devel] [PATCH 22/22] core/sysbus: remove the SysBusDeviceClass::initpath
2018-11-23 3:10 ` [Qemu-devel] [PATCH 22/22] core/sysbus: remove the SysBusDeviceClass::initpath maozy
@ 2018-11-23 9:02 ` Peter Maydell
2018-11-23 9:37 ` maozy
2018-11-23 18:16 ` Eduardo Habkost
1 sibling, 1 reply; 55+ messages in thread
From: Peter Maydell @ 2018-11-23 9:02 UTC (permalink / raw)
To: maozy
Cc: Eduardo Habkost, QEMU Developers, Thomas Huth, Paolo Bonzini,
Markus Armbruster, Richard Henderson, Alistair Francis,
Zhang Shengju
On 23 November 2018 at 03:10, maozy <maozhongyi@cmss.chinamobile.com> wrote:
> In order to void the subclasses whose parent_realize field is
> set to NULL, the k->realize function must be retained even
> though it doesn't do anything practical. Just like this:
>
>
> -/* TODO remove once all sysbus devices have been converted to realize*/
> static void sysbus_realize(DeviceState *dev, Error **errp)
> {
> - SysBusDevice *sd = SYS_BUS_DEVICE(dev);
> - SysBusDeviceClass *sbc = SYS_BUS_DEVICE_GET_CLASS(sd);
> -
> - if (!sbc->init) {
> - return;
> - }
> - if (sbc->init(sd) < 0) {
> - error_setg(errp, "Device initialization failed");
> - }
> }
>
> it doesn't look elegant, but I didn't think of a better way, if you
> can give me some hints, I really appreciate it. :)
If we do take this approach, we should have a comment which
says why we have an empty realize function, so that we don't
in future forget and delete the apparently unnecessary code...
thanks
-- PMM
^ permalink raw reply [flat|nested] 55+ messages in thread
* Re: [Qemu-devel] [PATCH 22/22] core/sysbus: remove the SysBusDeviceClass::initpath
2018-11-23 9:02 ` Peter Maydell
@ 2018-11-23 9:37 ` maozy
0 siblings, 0 replies; 55+ messages in thread
From: maozy @ 2018-11-23 9:37 UTC (permalink / raw)
To: Peter Maydell
Cc: Eduardo Habkost, QEMU Developers, Thomas Huth, Paolo Bonzini,
Markus Armbruster, Richard Henderson, Alistair Francis,
Zhang Shengju
On 11/23/18 5:02 PM, Peter Maydell wrote:
> On 23 November 2018 at 03:10, maozy <maozhongyi@cmss.chinamobile.com> wrote:
>> In order to void the subclasses whose parent_realize field is
>> set to NULL, the k->realize function must be retained even
>> though it doesn't do anything practical. Just like this:
>>
>>
>> -/* TODO remove once all sysbus devices have been converted to realize*/
>> static void sysbus_realize(DeviceState *dev, Error **errp)
>> {
>> - SysBusDevice *sd = SYS_BUS_DEVICE(dev);
>> - SysBusDeviceClass *sbc = SYS_BUS_DEVICE_GET_CLASS(sd);
>> -
>> - if (!sbc->init) {
>> - return;
>> - }
>> - if (sbc->init(sd) < 0) {
>> - error_setg(errp, "Device initialization failed");
>> - }
>> }
>>
>> it doesn't look elegant, but I didn't think of a better way, if you
>> can give me some hints, I really appreciate it. :)
>
> If we do take this approach, we should have a comment which
> says why we have an empty realize function, so that we don't
> in future forget and delete the apparently unnecessary code...
>
OK, I got you, will do it.
Thanks,
Mao
> thanks
> -- PMM
>
^ permalink raw reply [flat|nested] 55+ messages in thread
* Re: [Qemu-devel] [PATCH 22/22] core/sysbus: remove the SysBusDeviceClass::initpath
2018-11-23 3:10 ` [Qemu-devel] [PATCH 22/22] core/sysbus: remove the SysBusDeviceClass::initpath maozy
2018-11-23 9:02 ` Peter Maydell
@ 2018-11-23 18:16 ` Eduardo Habkost
2018-11-23 18:19 ` Peter Maydell
1 sibling, 1 reply; 55+ messages in thread
From: Eduardo Habkost @ 2018-11-23 18:16 UTC (permalink / raw)
To: maozy
Cc: qemu-devel, thuth, pbonzini, armbru, peter.maydell,
richard.henderson, alistair.francis, Zhang Shengju
On Fri, Nov 23, 2018 at 11:10:40AM +0800, maozy wrote:
> Hi, Eduardo
>
> On 11/20/18 7:31 AM, Eduardo Habkost wrote:
> > On Mon, Nov 19, 2018 at 08:08:20PM +0800, Mao Zhongyi wrote:
> > > Currently, all sysbus devices have been converted to realize(),
> > > so remove this path.
> > >
> > > Cc: ehabkost@redhat.com
> > > Cc: thuth@redhat.com
> > > Cc: pbonzini@redhat.com
> > > Cc: armbru@redhat.com
> > > Cc: peter.maydell@linaro.org
> > > Cc: richard.henderson@linaro.org
> > > Cc: alistair.francis@wdc.com
> > >
> > > Signed-off-by: Mao Zhongyi <maozhongyi@cmss.chinamobile.com>
> > > Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com>
> > > ---
> > > hw/core/sysbus.c | 15 ---------------
> > > include/hw/sysbus.h | 3 ---
> > > 2 files changed, 18 deletions(-)
> > >
> > > diff --git a/hw/core/sysbus.c b/hw/core/sysbus.c
> > > index 7ac36ad3e7..030ad426c1 100644
> > > --- a/hw/core/sysbus.c
> > > +++ b/hw/core/sysbus.c
> > > @@ -201,20 +201,6 @@ void sysbus_init_ioports(SysBusDevice *dev, uint32_t ioport, uint32_t size)
> > > }
> > > }
> > > -/* TODO remove once all sysbus devices have been converted to realize */
> > > -static void sysbus_realize(DeviceState *dev, Error **errp)
> > > -{
> > > - SysBusDevice *sd = SYS_BUS_DEVICE(dev);
> > > - SysBusDeviceClass *sbc = SYS_BUS_DEVICE_GET_CLASS(sd);
> > > -
> > > - if (!sbc->init) {
> > > - return;
> > > - }
> > > - if (sbc->init(sd) < 0) {
> > > - error_setg(errp, "Device initialization failed");
> > > - }
> > > -}
> >
> > Nice. :)
> >
> >
> > > -
> > > DeviceState *sysbus_create_varargs(const char *name,
> > > hwaddr addr, ...)
> > > {
> > > @@ -327,7 +313,6 @@ MemoryRegion *sysbus_address_space(SysBusDevice *dev)
> > > static void sysbus_device_class_init(ObjectClass *klass, void *data)
> > > {
> > > DeviceClass *k = DEVICE_CLASS(klass);
> > > - k->realize = sysbus_realize;
> >
> > Have you ensured this won't break any subclasses that
> > saved the original realize function on a parent_realize field?
>
> Thanks for the catch.
>
> > Now they will have parent_realize set to NULL.
>
> In order to void the subclasses whose parent_realize field is
> set to NULL, the k->realize function must be retained even
> though it doesn't do anything practical. Just like this:
>
>
> -/* TODO remove once all sysbus devices have been converted to realize*/
> static void sysbus_realize(DeviceState *dev, Error **errp)
> {
> - SysBusDevice *sd = SYS_BUS_DEVICE(dev);
> - SysBusDeviceClass *sbc = SYS_BUS_DEVICE_GET_CLASS(sd);
> -
> - if (!sbc->init) {
> - return;
> - }
> - if (sbc->init(sd) < 0) {
> - error_setg(errp, "Device initialization failed");
> - }
> }
>
> it doesn't look elegant, but I didn't think of a better way, if you
> can give me some hints, I really appreciate it. :)
I think this is good enough for now (as long as there's a comment
like Peter suggested). Allowing parent_realize to be NULL would
be inconvenient to all code that uses parent_realize today.
Personally, I would love to get rid of parent_realize entirely.
We could simply provide a helper to let device subclasses call
the parent's realize function without the need to copy function
pointers around.
--
Eduardo
^ permalink raw reply [flat|nested] 55+ messages in thread
* Re: [Qemu-devel] [PATCH 22/22] core/sysbus: remove the SysBusDeviceClass::initpath
2018-11-23 18:16 ` Eduardo Habkost
@ 2018-11-23 18:19 ` Peter Maydell
2018-11-25 1:24 ` maozy
0 siblings, 1 reply; 55+ messages in thread
From: Peter Maydell @ 2018-11-23 18:19 UTC (permalink / raw)
To: Eduardo Habkost
Cc: Mao Zhongyi, QEMU Developers, Thomas Huth, Paolo Bonzini,
Markus Armbruster, Richard Henderson, Alistair Francis,
Zhang Shengju
On Fri, 23 Nov 2018 at 18:16, Eduardo Habkost <ehabkost@redhat.com> wrote:
> I think this is good enough for now (as long as there's a comment
> like Peter suggested). Allowing parent_realize to be NULL would
> be inconvenient to all code that uses parent_realize today.
>
> Personally, I would love to get rid of parent_realize entirely.
> We could simply provide a helper to let device subclasses call
> the parent's realize function without the need to copy function
> pointers around.
Agreed -- parent_realize is a hack that is working around
a deficiency in our object model, and it would be nice to
deal with that. But let's do our cleanups one at a time :-)
thanks
-- PMM
^ permalink raw reply [flat|nested] 55+ messages in thread
* Re: [Qemu-devel] [PATCH 22/22] core/sysbus: remove the SysBusDeviceClass::initpath
2018-11-23 18:19 ` Peter Maydell
@ 2018-11-25 1:24 ` maozy
0 siblings, 0 replies; 55+ messages in thread
From: maozy @ 2018-11-25 1:24 UTC (permalink / raw)
To: Peter Maydell, Eduardo Habkost
Cc: QEMU Developers, Thomas Huth, Paolo Bonzini, Markus Armbruster,
Richard Henderson, Alistair Francis, Zhang Shengju
On 11/24/18 2:19 AM, Peter Maydell wrote:
> On Fri, 23 Nov 2018 at 18:16, Eduardo Habkost <ehabkost@redhat.com> wrote:
>> I think this is good enough for now (as long as there's a comment
>> like Peter suggested). Allowing parent_realize to be NULL would
>> be inconvenient to all code that uses parent_realize today.
It was done in v2, please review.
>>
>> Personally, I would love to get rid of parent_realize entirely.
>> We could simply provide a helper to let device subclasses call
>> the parent's realize function without the need to copy function
>> pointers around.
well, I will do it later.
>
> Agreed -- parent_realize is a hack that is working around
> a deficiency in our object model, and it would be nice to
> deal with that. But let's do our cleanups one at a time :-)
OK, I see.
Thanks,
Mao
>
> thanks
> -- PMM
>
^ permalink raw reply [flat|nested] 55+ messages in thread
* Re: [Qemu-devel] [PATCH 00/22] QOM'ify SysBusDeviceClass->init
2018-11-19 12:07 [Qemu-devel] [PATCH 00/22] QOM'ify SysBusDeviceClass->init Mao Zhongyi
@ 2018-11-19 12:27 ` Cornelia Huck
2018-11-19 12:08 ` [Qemu-devel] [PATCH 02/22] block/noenand: " Mao Zhongyi
` (22 subsequent siblings)
23 siblings, 0 replies; 55+ messages in thread
From: Cornelia Huck @ 2018-11-19 12:27 UTC (permalink / raw)
To: Mao Zhongyi
Cc: qemu-devel, alistair.francis, anthony.perard, armbru,
borntraeger, chouteau, david, david, edgar.iglesias, ehabkost,
f4bug, gxt, jan.kiszka, kraxel, kwolf, marcandre.lureau,
marcel.apfelbaum, michael, mreitz, mst, pbonzini, peter.maydell,
qemu-arm, qemu-block, qemu-ppc, qemu-s390x, richard.henderson,
rth, sstabellini, thuth, xen-devel
On Mon, 19 Nov 2018 20:07:58 +0800
Mao Zhongyi <maozhongyi@cmss.chinamobile.com> wrote:
> The SysBusDeviceClass::init() interface is considered
> as a legacy interface and there are currently some
> efforts going on to get rid of it. Thus convert
> SysBusDeviceClass::init to DeviceClass::realize.
In case my comment to the s390 change comes off as negative: I like
getting rid of the legacy interface :)
^ permalink raw reply [flat|nested] 55+ messages in thread
* Re: [PATCH 00/22] QOM'ify SysBusDeviceClass->init
@ 2018-11-19 12:27 ` Cornelia Huck
0 siblings, 0 replies; 55+ messages in thread
From: Cornelia Huck @ 2018-11-19 12:27 UTC (permalink / raw)
To: Mao Zhongyi
Cc: peter.maydell, david, qemu-devel, alistair.francis, kraxel,
edgar.iglesias, gxt, sstabellini, qemu-block, mst, armbru,
borntraeger, marcel.apfelbaum, anthony.perard, marcandre.lureau,
rth, thuth, ehabkost, richard.henderson, chouteau, qemu-s390x,
qemu-arm, jan.kiszka, xen-devel, david, kwolf, f4bug, mreitz,
michael, qemu-ppc, pbonzini
On Mon, 19 Nov 2018 20:07:58 +0800
Mao Zhongyi <maozhongyi@cmss.chinamobile.com> wrote:
> The SysBusDeviceClass::init() interface is considered
> as a legacy interface and there are currently some
> efforts going on to get rid of it. Thus convert
> SysBusDeviceClass::init to DeviceClass::realize.
In case my comment to the s390 change comes off as negative: I like
getting rid of the legacy interface :)
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply [flat|nested] 55+ messages in thread