qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [RFC v1 17/25] sysbus: Use TYPE_DEVICE GPIO functionali


From: Peter Crosthwaite
Subject: Re: [Qemu-devel] [RFC v1 17/25] sysbus: Use TYPE_DEVICE GPIO functionality
Date: Mon, 19 May 2014 11:59:16 +1000

On Fri, May 16, 2014 at 11:59 AM, Peter Crosthwaite
<address@hidden> wrote:
> Re-implement the Sysbus GPIOs to use the existing TYPE_DEVICE
> GPIO named framework. A constant string name is chosen to avoid
> conflicts with existing unnamed GPIOs.
>
> This unifies GPIOs are IRQs for sysbus devices and allows removal
> of all Sysbus state for GPIOs.
>
> Any existing and future-added functionality for GPIOs is now
> also available for sysbus IRQs.
>
> For the anti-sysbus campaigners, this patch brings us one step
> closer to deleting the abstraction completely.
>
> Signed-off-by: Peter Crosthwaite <address@hidden>
> ---
>
>  hw/core/sysbus.c    | 20 +++-----------------
>  include/hw/sysbus.h |  7 +++----
>  2 files changed, 6 insertions(+), 21 deletions(-)
>
> diff --git a/hw/core/sysbus.c b/hw/core/sysbus.c
> index f4e760d..2fae2bd 100644
> --- a/hw/core/sysbus.c
> +++ b/hw/core/sysbus.c
> @@ -41,11 +41,7 @@ static const TypeInfo system_bus_info = {
>
>  void sysbus_connect_irq(SysBusDevice *dev, int n, qemu_irq irq)
>  {
> -    assert(n >= 0 && n < dev->num_irq);
> -    dev->irqs[n] = NULL;
> -    if (dev->irqp[n]) {
> -        *dev->irqp[n] = irq;
> -    }
> +    qdev_connect_gpio_out_named(DEVICE(dev), SYSBUS_DEVICE_GPIO_IRQ, n, irq);
>  }
>
>  static void sysbus_mmio_map_common(SysBusDevice *dev, int n, hwaddr addr,
> @@ -89,22 +85,13 @@ void sysbus_mmio_map_overlap(SysBusDevice *dev, int n, 
> hwaddr addr,
>  /* Request an IRQ source.  The actual IRQ object may be populated later.  */
>  void sysbus_init_irq(SysBusDevice *dev, qemu_irq *p)
>  {
> -    int n;
> -
> -    assert(dev->num_irq < QDEV_MAX_IRQ);
> -    n = dev->num_irq++;
> -    dev->irqp[n] = p;
> +    qdev_init_gpio_out_named(DEVICE(dev), p, SYSBUS_DEVICE_GPIO_IRQ, 1);

This is not repeatable as qemu_init_gpio_out() doesnt allow repeated
calls for the same GPIO output set (doh!) - that feature only exists
for GPIO inputs. Rather than investing further into unnamed GPIOs on
the DEVICE level though, I think it's better to just name each sysbus
IRQ individually. If you really really want arrayified IRQs then you
can still use the DEVICE GPIO API directly. To fix in V2:

 /* Request an IRQ source.  The actual IRQ object may be populated later.  */
 void sysbus_init_irq(SysBusDevice *dev, qemu_irq *p)
 {
-    qdev_init_gpio_out_named(DEVICE(dev), p, SYSBUS_DEVICE_GPIO_IRQ, 1);
+    char *irq_name = g_strdup_printf(SYSBUS_DEVICE_GPIO_IRQ "-%d",
+                                     dev->num_irq++);
+    qdev_init_gpio_out_named(DEVICE(dev), p, irq_name, 1);
+    g_free(irq_name);
 }

Regards,
Peter



reply via email to

[Prev in Thread] Current Thread [Next in Thread]