[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v1 08/16] qdev: gpio: Add API for intercepting a
From: |
Peter Crosthwaite |
Subject: |
Re: [Qemu-devel] [PATCH v1 08/16] qdev: gpio: Add API for intercepting an IRQ |
Date: |
Tue, 12 Aug 2014 20:40:02 +1000 |
On Tue, Aug 12, 2014 at 7:16 PM, Alexander Graf <address@hidden> wrote:
>
> On 04.08.14 03:55, Peter Crosthwaite wrote:
>>
>> To replace the old qemu_irq intercept API (which had users reaching
>> into qdev private state for IRQs).
>>
>> Signed-off-by: Peter Crosthwaite <address@hidden>
>> ---
>>
>> hw/core/qdev.c | 25 +++++++++++++++++++++++++
>> include/hw/qdev-core.h | 2 ++
>> 2 files changed, 27 insertions(+)
>>
>> diff --git a/hw/core/qdev.c b/hw/core/qdev.c
>> index e6b2231..4cbf773 100644
>> --- a/hw/core/qdev.c
>> +++ b/hw/core/qdev.c
>> @@ -412,6 +412,31 @@ void qdev_connect_gpio_out_named(DeviceState *dev,
>> const char *name, int n,
>> g_free(propname);
>> }
>> +/* disconnect a GPIO ouput, returning the disconnected input (if any)
>> */
>> +
>> +static qemu_irq qdev_disconnect_gpio_out_named(DeviceState *dev,
>> + const char *name, int n)
>> +{
>> + char *propname = g_strdup_printf("%s[%d]",
>> + name ? name : "unnamed-gpio-out",
>> n);
>> +
>> + qemu_irq ret = (qemu_irq)object_property_get_link(OBJECT(dev),
>> propname,
>> + NULL);
>> + if (ret) {
>> + object_property_set_link(OBJECT(dev), NULL, propname, NULL);
>> + }
>> + g_free(propname);
>> + return ret;
>> +}
>> +
>> +void qdev_intercept_gpio_out(DeviceState *dev, qemu_irq_handler handler,
>> + const char *name, int n)
>> +{
>> + qemu_irq disconnected = qdev_disconnect_gpio_out_named(dev, name, n);
>> + qemu_irq icpt = qemu_allocate_irq(handler, disconnected, n);
>
>
> This means that we can't pass in any other opaque to the intercepting
> handler which sounds suboptimal to me. Can't we pass in a qemu_irq as
> parameter and a pointer to a field where we can store the disconnected
> qemu_irq?
>
> Then the caller can allocate its own qemu_irq with all the opaque data it
> wants and just have the intercept function overwrite a single field in the
> passed down opaque.
>
> Or you just return the disconnected qemu_irq. Then the caller can do
> whatever it likes with it, such as set icpt->opaque to it.
>
Good idea. Ill play with these options and see what works best.
Regards,
Peter
>
> Alex
>
>
- [Qemu-devel] [PATCH v1 00/16] GPIO/IRQ QOMification: Phase 2 - Getting rid of SYSBUS IRQs, Peter Crosthwaite, 2014/08/03
- [Qemu-devel] [PATCH v1 01/16] qdev: gpio: Don't allow name share between I and O, Peter Crosthwaite, 2014/08/03
- [Qemu-devel] [PATCH v1 02/16] qdev: gpio: Register GPIO inputs as child objects, Peter Crosthwaite, 2014/08/03
- [Qemu-devel] [PATCH v1 03/16] qdev: gpio: Register GPIO outputs as QOM links, Peter Crosthwaite, 2014/08/03
- [Qemu-devel] [PATCH v1 04/16] qmp: qstring: Handle NULL strings, Peter Crosthwaite, 2014/08/03
- [Qemu-devel] [PATCH v1 05/16] qom: Allow clearing of a Link property, Peter Crosthwaite, 2014/08/03
- [Qemu-devel] [PATCH v1 06/16] qom: Demote already-has-a-parent to a regular error, Peter Crosthwaite, 2014/08/03
- [Qemu-devel] [PATCH v1 07/16] qdev: gpio: Re-impement qdev_connect_gpio QOM style, Peter Crosthwaite, 2014/08/03
- [Qemu-devel] [PATCH v1 08/16] qdev: gpio: Add API for intercepting an IRQ, Peter Crosthwaite, 2014/08/03
- [Qemu-devel] [PATCH v1 09/16] qtest/irq: Rework IRQ interception, Peter Crosthwaite, 2014/08/03
- [Qemu-devel] [PATCH v1 10/16] irq: Remove qemu_irq_intercept_out, Peter Crosthwaite, 2014/08/03
- [Qemu-devel] [PATCH v1 11/16] qdev: gpio: delete NamedGPIOList::out, Peter Crosthwaite, 2014/08/03
- [Qemu-devel] [PATCH v1 12/16] qdev: gpio: Remove qdev_init_gpio_out x1 restriction, Peter Crosthwaite, 2014/08/03
- [Qemu-devel] [PATCH v1 13/16] qdev: gpio: Define qdev_pass_gpios(), Peter Crosthwaite, 2014/08/03