[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 02/13] pcspk: convert "pit" property type from p
From: |
Paolo Bonzini |
Subject: |
Re: [Qemu-devel] [PATCH 02/13] pcspk: convert "pit" property type from ptr to link |
Date: |
Fri, 17 Jun 2016 15:20:23 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.1.0 |
On 17/06/2016 15:10, Efimov Vasily wrote:
> The speaker device needs pointer to ISA PIT device to operate. But according
> to
> qdev-properties.h, properties of pointer type should be avoided. It seems a
> link type property is a good substitution.
>
> Signed-off-by: Efimov Vasily <address@hidden>
> ---
> hw/audio/pcspk.c | 7 +++++--
> include/hw/audio/pcspk.h | 2 +-
> 2 files changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/hw/audio/pcspk.c b/hw/audio/pcspk.c
> index d259960..aa198d6 100644
> --- a/hw/audio/pcspk.c
> +++ b/hw/audio/pcspk.c
> @@ -31,6 +31,7 @@
> #include "qemu/timer.h"
> #include "hw/timer/i8254.h"
> #include "hw/audio/pcspk.h"
> +#include "qapi/error.h"
>
> #define PCSPK_BUF_LEN 1792
> #define PCSPK_SAMPLE_RATE 32000
> @@ -169,6 +170,9 @@ static void pcspk_initfn(Object *obj)
> PCSpkState *s = PC_SPEAKER(obj);
>
> memory_region_init_io(&s->ioport, OBJECT(s), &pcspk_io_ops, s, "pcspk",
> 1);
> +
> + object_property_add_link(obj, "pit", TYPE_I8254,
> + (Object **)&s->pit, object_property_allow_set_link, 0, &error_abort);
Actually, this should use qdev_prop_allow_set_link_before_realize.
Paolo
> }
>
> static void pcspk_realizefn(DeviceState *dev, Error **errp)
> @@ -183,7 +187,6 @@ static void pcspk_realizefn(DeviceState *dev, Error
> **errp)
>
> static Property pcspk_properties[] = {
> DEFINE_PROP_UINT32("iobase", PCSpkState, iobase, -1),
> - DEFINE_PROP_PTR("pit", PCSpkState, pit),
> DEFINE_PROP_END_OF_LIST(),
> };
>
> @@ -194,7 +197,7 @@ static void pcspk_class_initfn(ObjectClass *klass, void
> *data)
> dc->realize = pcspk_realizefn;
> set_bit(DEVICE_CATEGORY_SOUND, dc->categories);
> dc->props = pcspk_properties;
> - /* Reason: pointer property "pit", realize sets global pcspk_state */
> + /* Reason: realize sets global pcspk_state */
> dc->cannot_instantiate_with_device_add_yet = true;
> }
>
> diff --git a/include/hw/audio/pcspk.h b/include/hw/audio/pcspk.h
> index ef95dd1..33e46a5 100644
> --- a/include/hw/audio/pcspk.h
> +++ b/include/hw/audio/pcspk.h
> @@ -38,7 +38,7 @@ static inline ISADevice *pcspk_init(ISABus *bus, ISADevice
> *pit)
> isadev = isa_create(bus, TYPE_PC_SPEAKER);
> dev = DEVICE(isadev);
> qdev_prop_set_uint32(dev, "iobase", 0x61);
> - qdev_prop_set_ptr(dev, "pit", pit);
> + object_property_set_link(OBJECT(dev), OBJECT(pit), "pit", NULL);
> qdev_init_nofail(dev);
>
> return isadev;
>
- [Qemu-devel] [PATCH 10/13] ICH9 LPC: handle PIC and I/O APIC IRQs as qdev GPIO, (continued)
- [Qemu-devel] [PATCH 10/13] ICH9 LPC: handle PIC and I/O APIC IRQs as qdev GPIO, Efimov Vasily, 2016/06/17
- [Qemu-devel] [PATCH 05/13] Q35: implement property interfece to several parameters, Efimov Vasily, 2016/06/17
- [Qemu-devel] [PATCH 09/13] ICH9 SMB: make TYPE_ICH9_SMB_DEVICE macro public, Efimov Vasily, 2016/06/17
- [Qemu-devel] [PATCH 04/13] pflash: make TYPE_CFI_PFLASH0{1, 2} macros public, Efimov Vasily, 2016/06/17
- [Qemu-devel] [PATCH 02/13] pcspk: convert "pit" property type from ptr to link, Efimov Vasily, 2016/06/17
- [Qemu-devel] [PATCH 01/13] ide: move headers to include folder, Efimov Vasily, 2016/06/17
- [Qemu-devel] [PATCH 06/13] pc_q35: configure Q35 instance using properties, Efimov Vasily, 2016/06/17
- [Qemu-devel] [PATCH 13/13] ICH9 LPC: configure PCI IRQs routing internally, Efimov Vasily, 2016/06/17
- [Qemu-devel] [PATCH 11/13] ICH9 LPC: move call of isa_bus_irqs to 'realize' method, Efimov Vasily, 2016/06/17