* [Qemu-devel] [PATCH 0/2] QOM'ify work for etraxfs @ 2016-10-23 7:06 xiaoqiang zhao 2016-10-23 7:06 ` [Qemu-devel] [PATCH 1/2] hw/timer: QOM'ify etraxfs_timer xiaoqiang zhao ` (2 more replies) 0 siblings, 3 replies; 5+ messages in thread From: xiaoqiang zhao @ 2016-10-23 7:06 UTC (permalink / raw) To: qemu-devel; +Cc: edgar.iglesias This is some QOM'ify work relate with etraxfs. See each commit for details. xiaoqiang zhao (2): hw/timer: QOM'ify etraxfs_timer hw/net: QOM'ify etraxfs_eth.c hw/net/etraxfs_eth.c | 34 +++++++++++++++++++--------------- hw/timer/etraxfs_timer.c | 18 +++++++++--------- 2 files changed, 28 insertions(+), 24 deletions(-) -- 2.9.3 ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Qemu-devel] [PATCH 1/2] hw/timer: QOM'ify etraxfs_timer 2016-10-23 7:06 [Qemu-devel] [PATCH 0/2] QOM'ify work for etraxfs xiaoqiang zhao @ 2016-10-23 7:06 ` xiaoqiang zhao 2016-10-23 7:06 ` [Qemu-devel] [PATCH 2/2] hw/net: QOM'ify etraxfs_eth.c xiaoqiang zhao 2016-12-25 4:00 ` [Qemu-devel] [PATCH 0/2] QOM'ify work for etraxfs 赵小强 2 siblings, 0 replies; 5+ messages in thread From: xiaoqiang zhao @ 2016-10-23 7:06 UTC (permalink / raw) To: qemu-devel; +Cc: edgar.iglesias assign etraxfs_timer_init to etraxfs_timer_info.instance_init and drop the SysBusDeviceClass::init Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> Signed-off-by: xiaoqiang zhao <zxq_yx_007@163.com> --- hw/timer/etraxfs_timer.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/hw/timer/etraxfs_timer.c b/hw/timer/etraxfs_timer.c index 8e18236..bc4bc3a 100644 --- a/hw/timer/etraxfs_timer.c +++ b/hw/timer/etraxfs_timer.c @@ -302,9 +302,9 @@ static const MemoryRegionOps timer_ops = { } }; -static void etraxfs_timer_reset(void *opaque) +static void etraxfs_timer_reset(DeviceState *dev) { - ETRAXTimerState *t = opaque; + ETRAXTimerState *t = ETRAX_TIMER(dev); ptimer_stop(t->ptimer_t0); ptimer_stop(t->ptimer_t1); @@ -315,9 +315,10 @@ static void etraxfs_timer_reset(void *opaque) qemu_irq_lower(t->irq); } -static int etraxfs_timer_init(SysBusDevice *dev) +static void etraxfs_timer_init(Object *obj) { - ETRAXTimerState *t = ETRAX_TIMER(dev); + ETRAXTimerState *t = ETRAX_TIMER(obj); + SysBusDevice *dev = SYS_BUS_DEVICE(obj); t->bh_t0 = qemu_bh_new(timer0_hit, t); t->bh_t1 = qemu_bh_new(timer1_hit, t); @@ -329,24 +330,23 @@ static int etraxfs_timer_init(SysBusDevice *dev) sysbus_init_irq(dev, &t->irq); sysbus_init_irq(dev, &t->nmi); - memory_region_init_io(&t->mmio, OBJECT(t), &timer_ops, t, + memory_region_init_io(&t->mmio, obj, &timer_ops, t, "etraxfs-timer", 0x5c); sysbus_init_mmio(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->reset = etraxfs_timer_reset; } static const TypeInfo etraxfs_timer_info = { .name = TYPE_ETRAX_FS_TIMER, .parent = TYPE_SYS_BUS_DEVICE, .instance_size = sizeof(ETRAXTimerState), + .instance_init = etraxfs_timer_init, .class_init = etraxfs_timer_class_init, }; -- 2.9.3 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* [Qemu-devel] [PATCH 2/2] hw/net: QOM'ify etraxfs_eth.c 2016-10-23 7:06 [Qemu-devel] [PATCH 0/2] QOM'ify work for etraxfs xiaoqiang zhao 2016-10-23 7:06 ` [Qemu-devel] [PATCH 1/2] hw/timer: QOM'ify etraxfs_timer xiaoqiang zhao @ 2016-10-23 7:06 ` xiaoqiang zhao 2017-01-03 15:45 ` Edgar E. Iglesias 2016-12-25 4:00 ` [Qemu-devel] [PATCH 0/2] QOM'ify work for etraxfs 赵小强 2 siblings, 1 reply; 5+ messages in thread From: xiaoqiang zhao @ 2016-10-23 7:06 UTC (permalink / raw) To: qemu-devel; +Cc: edgar.iglesias * Split the old SysBus init into an instance_init and a DeviceClass::realize function * Drop the old SysBus init function and use instance_init Signed-off-by: xiaoqiang zhao <zxq_yx_007@163.com> --- hw/net/etraxfs_eth.c | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/hw/net/etraxfs_eth.c b/hw/net/etraxfs_eth.c index efaa49f..9bb814f 100644 --- a/hw/net/etraxfs_eth.c +++ b/hw/net/etraxfs_eth.c @@ -27,6 +27,7 @@ #include "net/net.h" #include "hw/cris/etraxfs.h" #include "qemu/error-report.h" +#include "qapi/error.h" #define D(x) @@ -584,14 +585,25 @@ static NetClientInfo net_etraxfs_info = { .link_status_changed = eth_set_link, }; -static int fs_eth_init(SysBusDevice *sbd) +static void fs_eth_init(Object *obj) +{ + SysBusDevice *sbd = SYS_BUS_DEVICE(obj); + ETRAXFSEthState *s = ETRAX_FS_ETH(obj); + + memory_region_init_io(&s->mmio, obj, ð_ops, s, + "etraxfs-eth", 0x5c); + sysbus_init_mmio(sbd, &s->mmio); + + tdk_init(&s->phy); +} + +static void fs_eth_realize(DeviceState *dev, Error **errp) { - DeviceState *dev = DEVICE(sbd); ETRAXFSEthState *s = ETRAX_FS_ETH(dev); if (!s->dma_out || !s->dma_in) { - error_report("Unconnected ETRAX-FS Ethernet MAC"); - return -1; + error_setg(errp, "Unconnected ETRAX-FS Ethernet MAC"); + return; } s->dma_out->client.push = eth_tx_push; @@ -599,19 +611,11 @@ static int fs_eth_init(SysBusDevice *sbd) s->dma_in->client.opaque = s; s->dma_in->client.pull = NULL; - memory_region_init_io(&s->mmio, OBJECT(dev), ð_ops, s, - "etraxfs-eth", 0x5c); - sysbus_init_mmio(sbd, &s->mmio); - qemu_macaddr_default_if_unset(&s->conf.macaddr); s->nic = qemu_new_nic(&net_etraxfs_info, &s->conf, - object_get_typename(OBJECT(s)), dev->id, s); + object_get_typename(OBJECT(dev)), dev->id, s); qemu_format_nic_info_str(qemu_get_queue(s->nic), s->conf.macaddr.a); - - - tdk_init(&s->phy); mdio_attach(&s->mdio_bus, &s->phy, s->phyaddr); - return 0; } static Property etraxfs_eth_properties[] = { @@ -625,18 +629,18 @@ static Property etraxfs_eth_properties[] = { static void etraxfs_eth_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); - SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass); - k->init = fs_eth_init; dc->props = etraxfs_eth_properties; /* Reason: pointer properties "dma_out", "dma_in" */ dc->cannot_instantiate_with_device_add_yet = true; + dc->realize = fs_eth_realize; } static const TypeInfo etraxfs_eth_info = { .name = TYPE_ETRAX_FS_ETH, .parent = TYPE_SYS_BUS_DEVICE, .instance_size = sizeof(ETRAXFSEthState), + .instance_init = fs_eth_init, .class_init = etraxfs_eth_class_init, }; -- 2.9.3 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH 2/2] hw/net: QOM'ify etraxfs_eth.c 2016-10-23 7:06 ` [Qemu-devel] [PATCH 2/2] hw/net: QOM'ify etraxfs_eth.c xiaoqiang zhao @ 2017-01-03 15:45 ` Edgar E. Iglesias 0 siblings, 0 replies; 5+ messages in thread From: Edgar E. Iglesias @ 2017-01-03 15:45 UTC (permalink / raw) To: xiaoqiang zhao; +Cc: qemu-devel On Sun, Oct 23, 2016 at 03:06:53PM +0800, xiaoqiang zhao wrote: > * Split the old SysBus init into an instance_init and a > DeviceClass::realize function > * Drop the old SysBus init function and use instance_init some of tdk_init should probably go into a reset function but I think that should be done in a separate patch so: Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> > > Signed-off-by: xiaoqiang zhao <zxq_yx_007@163.com> > --- > hw/net/etraxfs_eth.c | 34 +++++++++++++++++++--------------- > 1 file changed, 19 insertions(+), 15 deletions(-) > > diff --git a/hw/net/etraxfs_eth.c b/hw/net/etraxfs_eth.c > index efaa49f..9bb814f 100644 > --- a/hw/net/etraxfs_eth.c > +++ b/hw/net/etraxfs_eth.c > @@ -27,6 +27,7 @@ > #include "net/net.h" > #include "hw/cris/etraxfs.h" > #include "qemu/error-report.h" > +#include "qapi/error.h" > > #define D(x) > > @@ -584,14 +585,25 @@ static NetClientInfo net_etraxfs_info = { > .link_status_changed = eth_set_link, > }; > > -static int fs_eth_init(SysBusDevice *sbd) > +static void fs_eth_init(Object *obj) > +{ > + SysBusDevice *sbd = SYS_BUS_DEVICE(obj); > + ETRAXFSEthState *s = ETRAX_FS_ETH(obj); > + > + memory_region_init_io(&s->mmio, obj, ð_ops, s, > + "etraxfs-eth", 0x5c); > + sysbus_init_mmio(sbd, &s->mmio); > + > + tdk_init(&s->phy); > +} > + > +static void fs_eth_realize(DeviceState *dev, Error **errp) > { > - DeviceState *dev = DEVICE(sbd); > ETRAXFSEthState *s = ETRAX_FS_ETH(dev); > > if (!s->dma_out || !s->dma_in) { > - error_report("Unconnected ETRAX-FS Ethernet MAC"); > - return -1; > + error_setg(errp, "Unconnected ETRAX-FS Ethernet MAC"); > + return; > } > > s->dma_out->client.push = eth_tx_push; > @@ -599,19 +611,11 @@ static int fs_eth_init(SysBusDevice *sbd) > s->dma_in->client.opaque = s; > s->dma_in->client.pull = NULL; > > - memory_region_init_io(&s->mmio, OBJECT(dev), ð_ops, s, > - "etraxfs-eth", 0x5c); > - sysbus_init_mmio(sbd, &s->mmio); > - > qemu_macaddr_default_if_unset(&s->conf.macaddr); > s->nic = qemu_new_nic(&net_etraxfs_info, &s->conf, > - object_get_typename(OBJECT(s)), dev->id, s); > + object_get_typename(OBJECT(dev)), dev->id, s); > qemu_format_nic_info_str(qemu_get_queue(s->nic), s->conf.macaddr.a); > - > - > - tdk_init(&s->phy); > mdio_attach(&s->mdio_bus, &s->phy, s->phyaddr); > - return 0; > } > > static Property etraxfs_eth_properties[] = { > @@ -625,18 +629,18 @@ static Property etraxfs_eth_properties[] = { > static void etraxfs_eth_class_init(ObjectClass *klass, void *data) > { > DeviceClass *dc = DEVICE_CLASS(klass); > - SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass); > > - k->init = fs_eth_init; > dc->props = etraxfs_eth_properties; > /* Reason: pointer properties "dma_out", "dma_in" */ > dc->cannot_instantiate_with_device_add_yet = true; > + dc->realize = fs_eth_realize; > } > > static const TypeInfo etraxfs_eth_info = { > .name = TYPE_ETRAX_FS_ETH, > .parent = TYPE_SYS_BUS_DEVICE, > .instance_size = sizeof(ETRAXFSEthState), > + .instance_init = fs_eth_init, > .class_init = etraxfs_eth_class_init, > }; > > -- > 2.9.3 > > ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH 0/2] QOM'ify work for etraxfs 2016-10-23 7:06 [Qemu-devel] [PATCH 0/2] QOM'ify work for etraxfs xiaoqiang zhao 2016-10-23 7:06 ` [Qemu-devel] [PATCH 1/2] hw/timer: QOM'ify etraxfs_timer xiaoqiang zhao 2016-10-23 7:06 ` [Qemu-devel] [PATCH 2/2] hw/net: QOM'ify etraxfs_eth.c xiaoqiang zhao @ 2016-12-25 4:00 ` 赵小强 2 siblings, 0 replies; 5+ messages in thread From: 赵小强 @ 2016-12-25 4:00 UTC (permalink / raw) To: xiaoqiang zhao; +Cc: qemu-devel, edgar.iglesias ping ... At 2016-10-23 15:06:51, "xiaoqiang zhao" <zxq_yx_007@163.com> wrote: >This is some QOM'ify work relate with etraxfs. >See each commit for details. > >xiaoqiang zhao (2): > hw/timer: QOM'ify etraxfs_timer > hw/net: QOM'ify etraxfs_eth.c > > hw/net/etraxfs_eth.c | 34 +++++++++++++++++++--------------- > hw/timer/etraxfs_timer.c | 18 +++++++++--------- > 2 files changed, 28 insertions(+), 24 deletions(-) > >-- >2.9.3 > ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2017-01-03 15:46 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2016-10-23 7:06 [Qemu-devel] [PATCH 0/2] QOM'ify work for etraxfs xiaoqiang zhao 2016-10-23 7:06 ` [Qemu-devel] [PATCH 1/2] hw/timer: QOM'ify etraxfs_timer xiaoqiang zhao 2016-10-23 7:06 ` [Qemu-devel] [PATCH 2/2] hw/net: QOM'ify etraxfs_eth.c xiaoqiang zhao 2017-01-03 15:45 ` Edgar E. Iglesias 2016-12-25 4:00 ` [Qemu-devel] [PATCH 0/2] QOM'ify work for etraxfs 赵小强
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).