Skip to contentSkip to conversation

net: xgmac: convert SysBus init method to a realize method

PATCH Superseded Cédric Le Goater 4 participants 12 messages Sep 28, 2018 – Oct 10, 2018 2 messages not in the archive

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#7 lore raw

PATCH 11/11 net: xgmac: convert SysBus init method to a realize method

In reply to a message not in the archive
---
 hw/net/xgmac.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
hw/net/xgmac.c +3 -6
index fa001563d3de..63f5a62ebf1b 100644
@@ -374,9 +374,9 @@ static NetClientInfo net_xgmac_enet_info = {
     .receive = eth_rx,
 };
 
-static int xgmac_enet_init(SysBusDevice *sbd)
+static void xgmac_enet_realize(DeviceState *dev, Error **errp)
 {
-    DeviceState *dev = DEVICE(sbd);
+    SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
     XgmacState *s = XGMAC(dev);
 
     memory_region_init_io(&s->iomem, OBJECT(s), &enet_mem_ops, s,
@@ -397,8 +397,6 @@ static int xgmac_enet_init(SysBusDevice *sbd)
                                  (s->conf.macaddr.a[2] << 16) |
                                  (s->conf.macaddr.a[1] << 8) |
                                   s->conf.macaddr.a[0];
-
-    return 0;
 }
 
 static Property xgmac_properties[] = {
@@ -408,10 +406,9 @@ static Property xgmac_properties[] = {
 
 static void xgmac_enet_class_init(ObjectClass *klass, void *data)
 {
-    SysBusDeviceClass *sbc = SYS_BUS_DEVICE_CLASS(klass);
     DeviceClass *dc = DEVICE_CLASS(klass);
 
-    sbc->init = xgmac_enet_init;
+    dc->realize = xgmac_enet_realize;
     dc->vmsd = &vmstate_xgmac;
     dc->props = xgmac_properties;
 }
Signature · 1 line
2.17.1
#1 lore raw

PATCH 9/11 net: stellaris_enet: convert SysBus init method to a realize method

In reply to a message not in the archive
---
 hw/net/stellaris_enet.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
hw/net/stellaris_enet.c +3 -5
index 165562d7886a..3ee1e0f8a43f 100644
@@ -473,9 +473,9 @@ static NetClientInfo net_stellaris_enet_info = {
     .receive = stellaris_enet_receive,
 };
 
-static int stellaris_enet_init(SysBusDevice *sbd)
+static void stellaris_enet_realize(DeviceState *dev, Error **errp)
 {
-    DeviceState *dev = DEVICE(sbd);
+    SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
     stellaris_enet_state *s = STELLARIS_ENET(dev);
 
     memory_region_init_io(&s->mmio, OBJECT(s), &stellaris_enet_ops, s,
@@ -489,7 +489,6 @@ static int stellaris_enet_init(SysBusDevice *sbd)
     qemu_format_nic_info_str(qemu_get_queue(s->nic), s->conf.macaddr.a);
 
     stellaris_enet_reset(s);
-    return 0;
 }
 
 static Property stellaris_enet_properties[] = {
@@ -500,9 +499,8 @@ static Property stellaris_enet_properties[] = {
 static void stellaris_enet_class_init(ObjectClass *klass, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
-    SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
 
-    k->init = stellaris_enet_init;
+    dc->realize = stellaris_enet_realize;
     dc->props = stellaris_enet_properties;
     dc->vmsd = &vmstate_stellaris_enet;
 }
Signature · 1 line
2.17.1
#4 lore raw

PATCH 10/11 net: stellaris_enet: add a reset method

In reply to a message not in the archive
---
 hw/net/stellaris_enet.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
hw/net/stellaris_enet.c +4 -3
index 3ee1e0f8a43f..b3375ebb459c 100644
@@ -457,8 +457,10 @@ static const MemoryRegionOps stellaris_enet_ops = {
     .endianness = DEVICE_NATIVE_ENDIAN,
 };
 
-static void stellaris_enet_reset(stellaris_enet_state *s)
+static void stellaris_enet_reset(DeviceState *dev)
 {
+    stellaris_enet_state *s =  STELLARIS_ENET(dev);
+
     s->mdv = 0x80;
     s->rctl = SE_RCTL_BADCRC;
     s->im = SE_INT_PHY | SE_INT_MD | SE_INT_RXER | SE_INT_FOV | SE_INT_TXEMP
@@ -487,8 +489,6 @@ static void stellaris_enet_realize(DeviceState *dev, Error **errp)
     s->nic = qemu_new_nic(&net_stellaris_enet_info, &s->conf,
                           object_get_typename(OBJECT(dev)), dev->id, s);
     qemu_format_nic_info_str(qemu_get_queue(s->nic), s->conf.macaddr.a);
-
-    stellaris_enet_reset(s);
 }
 
 static Property stellaris_enet_properties[] = {
@@ -501,6 +501,7 @@ static void stellaris_enet_class_init(ObjectClass *klass, void *data)
     DeviceClass *dc = DEVICE_CLASS(klass);
 
     dc->realize = stellaris_enet_realize;
+    dc->reset = stellaris_enet_reset;
     dc->props = stellaris_enet_properties;
     dc->vmsd = &vmstate_stellaris_enet;
 }
Signature · 1 line
2.17.1
Reviewed-by on v1 9/11
#3 lore raw

Re: [Qemu-devel] [PATCH 09/11] net: stellaris_enet: convert SysBus init method to a realize method

In reply to Cédric Le Goater
Quoted 3 lines · Cédric Le Goater
Quoted 40 lines
---
 hw/net/stellaris_enet.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
hw/net/stellaris_enet.c +3 -5
index 165562d7886a..3ee1e0f8a43f 100644
@@ -473,9 +473,9 @@ static NetClientInfo net_stellaris_enet_info = {
     .receive = stellaris_enet_receive,
 };
 
-static int stellaris_enet_init(SysBusDevice *sbd)
+static void stellaris_enet_realize(DeviceState *dev, Error **errp)
 {
-    DeviceState *dev = DEVICE(sbd);
+    SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
     stellaris_enet_state *s = STELLARIS_ENET(dev);
 
     memory_region_init_io(&s->mmio, OBJECT(s), &stellaris_enet_ops, s,
@@ -489,7 +489,6 @@ static int stellaris_enet_init(SysBusDevice *sbd)
     qemu_format_nic_info_str(qemu_get_queue(s->nic), s->conf.macaddr.a);
 
     stellaris_enet_reset(s);
-    return 0;
 }
 
 static Property stellaris_enet_properties[] = {
@@ -500,9 +499,8 @@ static Property stellaris_enet_properties[] = {
 static void stellaris_enet_class_init(ObjectClass *klass, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
-    SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
 
-    k->init = stellaris_enet_init;
+    dc->realize = stellaris_enet_realize;
     dc->props = stellaris_enet_properties;
     dc->vmsd = &vmstate_stellaris_enet;
 }
Reviewed-by on v1 10/11
#6 lore raw

Re: [Qemu-devel] [PATCH 10/11] net: stellaris_enet: add a reset method

In reply to Cédric Le Goater
Quoted 3 lines · Cédric Le Goater
Quoted 38 lines
---
 hw/net/stellaris_enet.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
hw/net/stellaris_enet.c +4 -3
index 3ee1e0f8a43f..b3375ebb459c 100644
@@ -457,8 +457,10 @@ static const MemoryRegionOps stellaris_enet_ops = {
     .endianness = DEVICE_NATIVE_ENDIAN,
 };
 
-static void stellaris_enet_reset(stellaris_enet_state *s)
+static void stellaris_enet_reset(DeviceState *dev)
 {
+    stellaris_enet_state *s =  STELLARIS_ENET(dev);
+
     s->mdv = 0x80;
     s->rctl = SE_RCTL_BADCRC;
     s->im = SE_INT_PHY | SE_INT_MD | SE_INT_RXER | SE_INT_FOV | SE_INT_TXEMP
@@ -487,8 +489,6 @@ static void stellaris_enet_realize(DeviceState *dev, Error **errp)
     s->nic = qemu_new_nic(&net_stellaris_enet_info, &s->conf,
                           object_get_typename(OBJECT(dev)), dev->id, s);
     qemu_format_nic_info_str(qemu_get_queue(s->nic), s->conf.macaddr.a);
-
-    stellaris_enet_reset(s);
 }
 
 static Property stellaris_enet_properties[] = {
@@ -501,6 +501,7 @@ static void stellaris_enet_class_init(ObjectClass *klass, void *data)
     DeviceClass *dc = DEVICE_CLASS(klass);
 
     dc->realize = stellaris_enet_realize;
+    dc->reset = stellaris_enet_reset;
     dc->props = stellaris_enet_properties;
     dc->vmsd = &vmstate_stellaris_enet;
 }
Reviewed-by on v1 11/11
#9 lore raw
In reply to Cédric Le Goater
Quoted 4 lines · Cédric Le Goater
Quoted 42 lines
---
 hw/net/xgmac.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
hw/net/xgmac.c +3 -6
index fa001563d3de..63f5a62ebf1b 100644
@@ -374,9 +374,9 @@ static NetClientInfo net_xgmac_enet_info = {
     .receive = eth_rx,
 };
 
-static int xgmac_enet_init(SysBusDevice *sbd)
+static void xgmac_enet_realize(DeviceState *dev, Error **errp)
 {
-    DeviceState *dev = DEVICE(sbd);
+    SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
     XgmacState *s = XGMAC(dev);
 
     memory_region_init_io(&s->iomem, OBJECT(s), &enet_mem_ops, s,
@@ -397,8 +397,6 @@ static int xgmac_enet_init(SysBusDevice *sbd)
                                  (s->conf.macaddr.a[2] << 16) |
                                  (s->conf.macaddr.a[1] << 8) |
                                   s->conf.macaddr.a[0];
-
-    return 0;
 }
 
 static Property xgmac_properties[] = {
@@ -408,10 +406,9 @@ static Property xgmac_properties[] = {
 
 static void xgmac_enet_class_init(ObjectClass *klass, void *data)
 {
-    SysBusDeviceClass *sbc = SYS_BUS_DEVICE_CLASS(klass);
     DeviceClass *dc = DEVICE_CLASS(klass);
 
-    sbc->init = xgmac_enet_init;
+    dc->realize = xgmac_enet_realize;
     dc->vmsd = &vmstate_xgmac;
     dc->props = xgmac_properties;
 }
Tested-by
#11 lore raw

Re: [Qemu-devel] [PATCH 04/11] net: lance: convert SysBus init method to a realize method

In reply to a message not in the archive
Quoted 31 lines · Cédric Le Goater
---
 hw/net/lance.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
hw/net/lance.c +2 -3
index a08d5ac6a848..f987b2fd180f 100644
@@ -97,9 +97,9 @@ static const VMStateDescription vmstate_lance = {
     }
 };
 
-static int lance_init(SysBusDevice *sbd)
+static void lance_realize(DeviceState *dev, Error **errp)
 {
-    DeviceState *dev = DEVICE(sbd);
+    SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
     SysBusPCNetState *d = SYSBUS_PCNET(dev);
     PCNetState *s = &d->state;
 
@@ -115,7 +115,6 @@ static int lance_init(SysBusDevice *sbd)
     s->phys_mem_read = ledma_memory_read;
     s->phys_mem_write = ledma_memory_write;
     pcnet_common_init(dev, s, &net_lance_info);
-    return 0;
 }
 
 static void lance_reset(DeviceState *dev)

hw/net/lance.c static Property lance_properties[] = { · line 150

Quoted 10 lines
hw/net/lance.c +1 -2
@@ -144,9 +143,8 @@ static Property lance_properties[] = {
 static void lance_class_init(ObjectClass *klass, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
-    SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
 
-    k->init = lance_init;
+    dc->realize = lance_realize;
     set_bit(DEVICE_CATEGORY_NETWORK, dc->categories);
     dc->fw_name = "ethernet";
     dc->reset = lance_reset;
#12 lore raw

Re: [Qemu-devel] [PATCH 00/11] net: convert SysBus init method to a realize method

In reply to a message not in the archive

Hello,

Quoted 7 lines · Cédric Le Goater

Hello,

Here is my take to the SysBus init to realize method conversion. I picked the /net directory and did them all. Also added a couple of reset methods in separate patches.

make check tested

Do we have enough review for this series ? if so, may be it could go through Jason's tree ?

Thanks,

C.

Quoted 25 lines

Cédric Le Goater (11):
net: etraxfs_eth: convert SysBus init method to a realize method
net: etraxfs_eth: add a reset method
net: lan9118: convert SysBus init method to a realize method
net: lance: convert SysBus init method to a realize method
net: milkymist_minimac2: convert SysBus init method to a realize
method
net: mipsnet: convert SysBus init method to a realize method
net: opencores_eth: convert SysBus init method to a realize method
net: smc91c111: convert SysBus init method to a realize method
net: stellaris_enet: convert SysBus init method to a realize method
net: stellaris_enet: add a reset method
net: xgmac: convert SysBus init method to a realize method

 hw/net/etraxfs_eth.c        | 23 ++++++++++++++---------
 hw/net/lan9118.c            | 24 ++++++++++--------------
 hw/net/lance.c              |  8 +++-----
 hw/net/milkymist-minimac2.c |  9 +++------
 hw/net/mipsnet.c            |  9 +++------
 hw/net/opencores_eth.c      |  8 +++-----
 hw/net/smc91c111.c          | 22 +++++++++-------------
 hw/net/stellaris_enet.c     | 15 +++++++--------
 hw/net/xgmac.c              |  9 +++------
 9 files changed, 55 insertions(+), 72 deletions(-)
#13 lore raw

Re: [Qemu-devel] [PATCH 00/11] net: convert SysBus init method to a realize method

Quoted 5 lines · Cédric Le Goater

Hello,

Quoted 2 lines · Cédric Le Goater

Hello,

Quoted 8 lines
Quoted 5 lines

Here is my take to the SysBus init to realize method conversion. I picked the /net directory and did them all. Also added a couple of reset methods in separate patches.

make check tested

Do we have enough review for this series ? if so, may be it could go through Jason's tree ?

I meant v2.

	https://patchwork.ozlabs.org/project/qemu-devel/list/?series=68378

Thanks,

C.