Message ID | 20191018154212.13458-6-marcandre.lureau@redhat.com |
---|---|
State | New |
Headers | show |
Series | Clean-ups: remove QDEV_PROP_PTR | expand |
On Fri, 18 Oct 2019 at 16:42, Marc-André Lureau <marcandre.lureau@redhat.com> wrote: > > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> > --- > hw/mips/mips_jazz.c | 3 ++- > hw/net/dp8393x.c | 7 +++---- > 2 files changed, 5 insertions(+), 5 deletions(-) > > diff --git a/hw/mips/mips_jazz.c b/hw/mips/mips_jazz.c > index 8d010a0b6e..878925a963 100644 > --- a/hw/mips/mips_jazz.c > +++ b/hw/mips/mips_jazz.c > @@ -284,7 +284,8 @@ static void mips_jazz_init(MachineState *machine, > dev = qdev_create(NULL, "dp8393x"); > qdev_set_nic_properties(dev, nd); > qdev_prop_set_uint8(dev, "it_shift", 2); > - qdev_prop_set_ptr(dev, "dma_mr", rc4030_dma_mr); > + object_property_set_link(OBJECT(dev), OBJECT(rc4030_dma_mr), > + "dma_mr", &error_abort); > qdev_init_nofail(dev); > sysbus = SYS_BUS_DEVICE(dev); > sysbus_mmio_map(sysbus, 0, 0x80001000); > diff --git a/hw/net/dp8393x.c b/hw/net/dp8393x.c > index a5678e11fa..946c7a8f64 100644 > --- a/hw/net/dp8393x.c > +++ b/hw/net/dp8393x.c > @@ -173,7 +173,7 @@ typedef struct dp8393xState { > int loopback_packet; > > /* Memory access */ > - void *dma_mr; > + MemoryRegion *dma_mr; > AddressSpace as; > } dp8393xState; > > @@ -922,7 +922,8 @@ static const VMStateDescription vmstate_dp8393x = { > > static Property dp8393x_properties[] = { > DEFINE_NIC_PROPERTIES(dp8393xState, conf), > - DEFINE_PROP_PTR("dma_mr", dp8393xState, dma_mr), > + DEFINE_PROP_LINK("dma_mr", dp8393xState, dma_mr, > + TYPE_MEMORY_REGION, MemoryRegion *), > DEFINE_PROP_UINT8("it_shift", dp8393xState, it_shift, 0), > DEFINE_PROP_END_OF_LIST(), > }; Link property is the correct way to pass a MemoryRegion to a device for DMA purposes, so this is a good cleanup. > @@ -936,8 +937,6 @@ static void dp8393x_class_init(ObjectClass *klass, void *data) > dc->reset = dp8393x_reset; > dc->vmsd = &vmstate_dp8393x; > dc->props = dp8393x_properties; > - /* Reason: dma_mr property can't be set */ > - dc->user_creatable = false; > } Sidenote: as a sysbus device, this remains non-usercreatable even though we can drop the specific flag here. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> thanks -- PMM
On Friday, October 18, 2019, Marc-André Lureau <marcandre.lureau@redhat.com> wrote: > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> > --- > hw/mips/mips_jazz.c | 3 ++- > hw/net/dp8393x.c | 7 +++---- > 2 files changed, 5 insertions(+), 5 deletions(-) > > Marc-Andre, Can you put together a paragraph on why we need this patch, and place it in the commit message? Thanks, Aleksandar > diff --git a/hw/mips/mips_jazz.c b/hw/mips/mips_jazz.c > index 8d010a0b6e..878925a963 100644 > --- a/hw/mips/mips_jazz.c > +++ b/hw/mips/mips_jazz.c > @@ -284,7 +284,8 @@ static void mips_jazz_init(MachineState *machine, > dev = qdev_create(NULL, "dp8393x"); > qdev_set_nic_properties(dev, nd); > qdev_prop_set_uint8(dev, "it_shift", 2); > - qdev_prop_set_ptr(dev, "dma_mr", rc4030_dma_mr); > + object_property_set_link(OBJECT(dev), OBJECT(rc4030_dma_mr), > + "dma_mr", &error_abort); > qdev_init_nofail(dev); > sysbus = SYS_BUS_DEVICE(dev); > sysbus_mmio_map(sysbus, 0, 0x80001000); > diff --git a/hw/net/dp8393x.c b/hw/net/dp8393x.c > index a5678e11fa..946c7a8f64 100644 > --- a/hw/net/dp8393x.c > +++ b/hw/net/dp8393x.c > @@ -173,7 +173,7 @@ typedef struct dp8393xState { > int loopback_packet; > > /* Memory access */ > - void *dma_mr; > + MemoryRegion *dma_mr; > AddressSpace as; > } dp8393xState; > > @@ -922,7 +922,8 @@ static const VMStateDescription vmstate_dp8393x = { > > static Property dp8393x_properties[] = { > DEFINE_NIC_PROPERTIES(dp8393xState, conf), > - DEFINE_PROP_PTR("dma_mr", dp8393xState, dma_mr), > + DEFINE_PROP_LINK("dma_mr", dp8393xState, dma_mr, > + TYPE_MEMORY_REGION, MemoryRegion *), > DEFINE_PROP_UINT8("it_shift", dp8393xState, it_shift, 0), > DEFINE_PROP_END_OF_LIST(), > }; > @@ -936,8 +937,6 @@ static void dp8393x_class_init(ObjectClass *klass, > void *data) > dc->reset = dp8393x_reset; > dc->vmsd = &vmstate_dp8393x; > dc->props = dp8393x_properties; > - /* Reason: dma_mr property can't be set */ > - dc->user_creatable = false; > } > > static const TypeInfo dp8393x_info = { > -- > 2.23.0.606.g08da6496b6 > > >
diff --git a/hw/mips/mips_jazz.c b/hw/mips/mips_jazz.c index 8d010a0b6e..878925a963 100644 --- a/hw/mips/mips_jazz.c +++ b/hw/mips/mips_jazz.c @@ -284,7 +284,8 @@ static void mips_jazz_init(MachineState *machine, dev = qdev_create(NULL, "dp8393x"); qdev_set_nic_properties(dev, nd); qdev_prop_set_uint8(dev, "it_shift", 2); - qdev_prop_set_ptr(dev, "dma_mr", rc4030_dma_mr); + object_property_set_link(OBJECT(dev), OBJECT(rc4030_dma_mr), + "dma_mr", &error_abort); qdev_init_nofail(dev); sysbus = SYS_BUS_DEVICE(dev); sysbus_mmio_map(sysbus, 0, 0x80001000); diff --git a/hw/net/dp8393x.c b/hw/net/dp8393x.c index a5678e11fa..946c7a8f64 100644 --- a/hw/net/dp8393x.c +++ b/hw/net/dp8393x.c @@ -173,7 +173,7 @@ typedef struct dp8393xState { int loopback_packet; /* Memory access */ - void *dma_mr; + MemoryRegion *dma_mr; AddressSpace as; } dp8393xState; @@ -922,7 +922,8 @@ static const VMStateDescription vmstate_dp8393x = { static Property dp8393x_properties[] = { DEFINE_NIC_PROPERTIES(dp8393xState, conf), - DEFINE_PROP_PTR("dma_mr", dp8393xState, dma_mr), + DEFINE_PROP_LINK("dma_mr", dp8393xState, dma_mr, + TYPE_MEMORY_REGION, MemoryRegion *), DEFINE_PROP_UINT8("it_shift", dp8393xState, it_shift, 0), DEFINE_PROP_END_OF_LIST(), }; @@ -936,8 +937,6 @@ static void dp8393x_class_init(ObjectClass *klass, void *data) dc->reset = dp8393x_reset; dc->vmsd = &vmstate_dp8393x; dc->props = dp8393x_properties; - /* Reason: dma_mr property can't be set */ - dc->user_creatable = false; } static const TypeInfo dp8393x_info = {
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> --- hw/mips/mips_jazz.c | 3 ++- hw/net/dp8393x.c | 7 +++---- 2 files changed, 5 insertions(+), 5 deletions(-)