[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-arm] [PATCH 11/19] qdev: Add new qdev_init_gpio_in_named_with_
From: |
Philippe Mathieu-Daudé |
Subject: |
Re: [Qemu-arm] [PATCH 11/19] qdev: Add new qdev_init_gpio_in_named_with_opaque() |
Date: |
Tue, 20 Feb 2018 15:26:03 -0300 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 |
On 02/20/2018 03:03 PM, Peter Maydell wrote:
> The function qdev_init_gpio_in_named() passes the DeviceState pointer
> as the opaque data pointor for the irq handler function. Usually
> this is what you want, but in some cases it would be helpful to use
> some other data pointer.
>
> Add a new function qdev_init_gpio_in_named_with_opaque() which allows
> the caller to specify the data pointer they want.
>
> Signed-off-by: Peter Maydell <address@hidden>
Reviewed-by: Philippe Mathieu-Daudé <address@hidden>
> ---
> include/hw/qdev-core.h | 30 ++++++++++++++++++++++++++++--
> hw/core/qdev.c | 8 +++++---
> 2 files changed, 33 insertions(+), 5 deletions(-)
>
> diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
> index fc9d617a76..9453588160 100644
> --- a/include/hw/qdev-core.h
> +++ b/include/hw/qdev-core.h
> @@ -311,10 +311,36 @@ BusState *qdev_get_child_bus(DeviceState *dev, const
> char *name);
> /* GPIO inputs also double as IRQ sinks. */
> void qdev_init_gpio_in(DeviceState *dev, qemu_irq_handler handler, int n);
> void qdev_init_gpio_out(DeviceState *dev, qemu_irq *pins, int n);
> -void qdev_init_gpio_in_named(DeviceState *dev, qemu_irq_handler handler,
> - const char *name, int n);
> void qdev_init_gpio_out_named(DeviceState *dev, qemu_irq *pins,
> const char *name, int n);
> +/**
> + * qdev_init_gpio_in_named_with_opaque: create an array of input GPIO lines
> + * for the specified device
> + *
> + * @dev: Device to create input GPIOs for
> + * @handler: Function to call when GPIO line value is set
> + * @opaque: Opaque data pointer to pass to @handler
> + * @name: Name of the GPIO input (must be unique for this device)
> + * @n: Number of GPIO lines in this input set
> + */
> +void qdev_init_gpio_in_named_with_opaque(DeviceState *dev,
> + qemu_irq_handler handler,
> + void *opaque,
> + const char *name, int n);
> +
> +/**
> + * qdev_init_gpio_in_named: create an array of input GPIO lines
> + * for the specified device
> + *
> + * Like qdev_init_gpio_in_named_with_opaque(), but the opaque pointer
> + * passed to the handler is @dev (which is the most commonly desired
> behaviour).
> + */
> +static inline void qdev_init_gpio_in_named(DeviceState *dev,
> + qemu_irq_handler handler,
> + const char *name, int n)
> +{
> + qdev_init_gpio_in_named_with_opaque(dev, handler, dev, name, n);
> +}
>
> void qdev_pass_gpios(DeviceState *dev, DeviceState *container,
> const char *name);
> diff --git a/hw/core/qdev.c b/hw/core/qdev.c
> index 7ed1f431f0..f3754ee606 100644
> --- a/hw/core/qdev.c
> +++ b/hw/core/qdev.c
> @@ -385,15 +385,17 @@ static NamedGPIOList
> *qdev_get_named_gpio_list(DeviceState *dev,
> return ngl;
> }
>
> -void qdev_init_gpio_in_named(DeviceState *dev, qemu_irq_handler handler,
> - const char *name, int n)
> +void qdev_init_gpio_in_named_with_opaque(DeviceState *dev,
> + qemu_irq_handler handler,
> + void *opaque,
> + const char *name, int n)
> {
> int i;
> NamedGPIOList *gpio_list = qdev_get_named_gpio_list(dev, name);
>
> assert(gpio_list->num_out == 0 || !name);
> gpio_list->in = qemu_extend_irqs(gpio_list->in, gpio_list->num_in,
> handler,
> - dev, n);
> + opaque, n);
>
> if (!name) {
> name = "unnamed-gpio-in";
>
- [Qemu-arm] [PATCH 00/19] Add Cortex-M33 and mps2-an505 board model, Peter Maydell, 2018/02/20
- [Qemu-arm] [PATCH 11/19] qdev: Add new qdev_init_gpio_in_named_with_opaque(), Peter Maydell, 2018/02/20
- [Qemu-arm] [PATCH 13/19] hw/misc/mps2-fpgaio: FPGA control block for MPS2 AN505, Peter Maydell, 2018/02/20
- [Qemu-arm] [PATCH 12/19] hw/core/split-irq: Device that splits IRQ lines, Peter Maydell, 2018/02/20
- [Qemu-arm] [PATCH 10/19] include/hw/or-irq.h: Add missing include guard, Peter Maydell, 2018/02/20
- [Qemu-arm] [PATCH 09/19] hw/misc/unimp: Move struct to header file, Peter Maydell, 2018/02/20