From: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
To: xiaoqiang zhao <zxq_yx_007@163.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 2/2] hw/net: QOM'ify etraxfs_eth.c
Date: Tue, 3 Jan 2017 16:45:55 +0100 [thread overview]
Message-ID: <20170103154555.GU9606@toto> (raw)
In-Reply-To: <20161023070653.1665-3-zxq_yx_007@163.com>
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
>
>
next prev parent reply other threads:[~2017-01-03 15:46 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2016-12-25 4:00 ` [Qemu-devel] [PATCH 0/2] QOM'ify work for etraxfs 赵小强
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170103154555.GU9606@toto \
--to=edgar.iglesias@gmail.com \
--cc=qemu-devel@nongnu.org \
--cc=zxq_yx_007@163.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.