hw/net: convert "dma" property type from ptr to link
PATCH 1/1 hw/net: convert "dma" property type from ptr to link
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.
--- hw/net/lance.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
hw/net/lance.c +6 -2
@@ -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; }
Signature · 1 line
2.9.3
Quoted 51 lines · Suramya Shah
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.Signed-off-by Suramya Shah <[email protected]>--- hw/net/lance.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)hw/net/lance.c +6
-3@@ -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; } --2.9.3
Quoted 27 lines · Suramya Shah
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.Signed-off-by Suramya Shah <[email protected]>--- hw/net/lance.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)hw/net/lance.c +3
-0@@ -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,
hw/net/lance.c static void lance_instance_init(Object *obj) · line 159
Quoted 10 lines
hw/net/lance.c +3
-1+ (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 (), };
Hi. I'm afraid that this doesn't pass "make check":
TEST: tests/qom-test... (pid=5185)
/sparc/qom/SS-10:
qemu-system-sparc:/home/petmay01/linaro/qemu-from-laptop/qemu/hw/core/qdev-properties.c:1037:qdev_prop_set_ptr: Assertion `prop && prop->info == &qdev_prop_ptr' failed.
Broken pipe
FAIL
This is because you've changed the device implementation from a pointer property to a link, but you haven't changed the code that uses it, so now when that code tries to set the pointer property it crashes.
It's always a good idea to use "make check" to do at least a basic test of your changes (and if you can find test images that exercise the devices you're changing that's also good, because 'make check' often doesn't cover as much as we'd like).
hw/net/lance.c static void lance_class_init(ObjectClass *klass, void *data) · line 172
Quoted 6 lines
hw/net/lance.c +0
-1@@ -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;
This comment is describing the reason why the line below it sets dc->cannot_instantiate_with_device_add_yet, so you can't remove only the comment. Either:
(1) this change means it is now possible to instantiate with
device-add, in which case remove both the comment and the setting of the flag, or
(2) it's still not possible to instantiate with device-add,
in which case update the comment to give the new reason.
thanks
-- PMM