Message ID | 20170408143639.2524-1-shah.suramya@gmail.com |
---|---|
State | New |
Headers | show |
On 8 April 2017 at 15:36, Suramya Shah <shah.suramya@gmail.com> wrote: > The lance device needs pointer to ISA DMA device to operate. But according to > qdev-properties.h, properties of pointer type should be avoided. > A link type property is a good substitution. > > Changes since v1 > -changed the code in hw/sparc/sun4m.c which uses the device. > > Signed-off-by: Suramya Shah <shah.suramya@gmail.com> > --- > hw/net/lance.c | 8 ++++++-- > hw/sparc/sun4m.c | 2 +- > 2 files changed, 7 insertions(+), 3 deletions(-) > > diff --git a/hw/net/lance.c b/hw/net/lance.c > index 573d724..3996b9c 100644 > --- a/hw/net/lance.c > +++ b/hw/net/lance.c > @@ -44,6 +44,7 @@ > #include "pcnet.h" > #include "trace.h" > #include "sysemu/sysemu.h" > +#include "qapi/error.h" > > #define TYPE_LANCE "lance" > #define SYSBUS_PCNET(obj) \ > @@ -145,10 +146,14 @@ static void lance_instance_init(Object *obj) > device_add_bootindex_property(obj, &s->conf.bootindex, > "bootindex", "/ethernet-phy@0", > DEVICE(obj), NULL); > + > + object_property_add_link(obj, "dma", TYPE_LANCE, > + (Object **)&d->state.dma_opaque, > + qdev_prop_allow_set_link_before_realize, > + 0, &error_abort); > } > > static Property lance_properties[] = { > - DEFINE_PROP_PTR("dma", SysBusPCNetState, state.dma_opaque), > DEFINE_NIC_PROPERTIES(SysBusPCNetState, state.conf), > DEFINE_PROP_END_OF_LIST(), > }; > @@ -164,7 +169,6 @@ static void lance_class_init(ObjectClass *klass, void *data) > dc->reset = lance_reset; > dc->vmsd = &vmstate_lance; > dc->props = lance_properties; > - /* Reason: pointer property "dma" */ > dc->cannot_instantiate_with_device_add_yet = true; Please don't remove the comment but not the line it refers to; either the comment needs updating or the cannot_instantiate setting is no longer correct and needs removing. thanks -- PMM
diff --git a/hw/net/lance.c b/hw/net/lance.c index 573d724..3996b9c 100644 --- a/hw/net/lance.c +++ b/hw/net/lance.c @@ -44,6 +44,7 @@ #include "pcnet.h" #include "trace.h" #include "sysemu/sysemu.h" +#include "qapi/error.h" #define TYPE_LANCE "lance" #define SYSBUS_PCNET(obj) \ @@ -145,10 +146,14 @@ static void lance_instance_init(Object *obj) device_add_bootindex_property(obj, &s->conf.bootindex, "bootindex", "/ethernet-phy@0", DEVICE(obj), NULL); + + object_property_add_link(obj, "dma", TYPE_LANCE, + (Object **)&d->state.dma_opaque, + qdev_prop_allow_set_link_before_realize, + 0, &error_abort); } static Property lance_properties[] = { - DEFINE_PROP_PTR("dma", SysBusPCNetState, state.dma_opaque), DEFINE_NIC_PROPERTIES(SysBusPCNetState, state.conf), DEFINE_PROP_END_OF_LIST(), }; @@ -164,7 +169,6 @@ static void lance_class_init(ObjectClass *klass, void *data) dc->reset = lance_reset; dc->vmsd = &vmstate_lance; dc->props = lance_properties; - /* Reason: pointer property "dma" */ dc->cannot_instantiate_with_device_add_yet = true; } diff --git a/hw/sparc/sun4m.c b/hw/sparc/sun4m.c index 873cd7d..9b3f5a5 100644 --- a/hw/sparc/sun4m.c +++ b/hw/sparc/sun4m.c @@ -336,7 +336,7 @@ static void lance_init(NICInfo *nd, hwaddr leaddr, dev = qdev_create(NULL, "lance"); qdev_set_nic_properties(dev, nd); - qdev_prop_set_ptr(dev, "dma", dma_opaque); + object_property_set_link(OBJECT(dev), OBJECT(dma_opaque), "dma", NULL); qdev_init_nofail(dev); s = SYS_BUS_DEVICE(dev); sysbus_mmio_map(s, 0, leaddr);
The lance device needs pointer to ISA DMA device to operate. But according to qdev-properties.h, properties of pointer type should be avoided. A link type property is a good substitution. Changes since v1 -changed the code in hw/sparc/sun4m.c which uses the device. Signed-off-by: Suramya Shah <shah.suramya@gmail.com> --- hw/net/lance.c | 8 ++++++-- hw/sparc/sun4m.c | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-)