qemu-arm
[Top][All Lists]
Advanced

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

Re: [PATCH 45/50] lasips2: use qdev gpio for output IRQ


From: Peter Maydell
Subject: Re: [PATCH 45/50] lasips2: use qdev gpio for output IRQ
Date: Thu, 9 Jun 2022 12:18:23 +0100

On Sun, 22 May 2022 at 19:20, Mark Cave-Ayland
<mark.cave-ayland@ilande.co.uk> wrote:
>
> This enables the IRQ to be wired up using qdev_connect_gpio_out() in
> lasips2_initfn().
>
> Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
> ---
>  hw/input/lasips2.c         | 8 ++++----
>  include/hw/input/lasips2.h | 2 ++
>  2 files changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/hw/input/lasips2.c b/hw/input/lasips2.c
> index 6849b71e5c..644cf70955 100644
> --- a/hw/input/lasips2.c
> +++ b/hw/input/lasips2.c
> @@ -247,16 +247,14 @@ static void lasips2_port_set_irq(void *opaque, int 
> level)
>
>  LASIPS2State *lasips2_initfn(hwaddr base, qemu_irq irq)
>  {
> -    LASIPS2State *s;
>      DeviceState *dev;
>
>      dev = qdev_new(TYPE_LASIPS2);
>      qdev_prop_set_uint64(dev, "base", base);
>      sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
> -    s = LASIPS2(dev);
> +    qdev_connect_gpio_out(dev, LASIPS2_IRQ, irq);
>
> -    s->irq = irq;
> -    return s;
> +    return LASIPS2(dev);
>  }
>
>  static void lasips2_realize(DeviceState *dev, Error **errp)
> @@ -285,6 +283,8 @@ static void lasips2_init(Object *obj)
>
>      sysbus_init_mmio(SYS_BUS_DEVICE(obj), &s->kbd.reg);
>      sysbus_init_mmio(SYS_BUS_DEVICE(obj), &s->mouse.reg);
> +
> +    qdev_init_gpio_out(DEVICE(obj), &s->irq, 1);
>  }
>
>  static Property lasips2_properties[] = {
> diff --git a/include/hw/input/lasips2.h b/include/hw/input/lasips2.h
> index 7e4437b925..d3e9719d65 100644
> --- a/include/hw/input/lasips2.h
> +++ b/include/hw/input/lasips2.h
> @@ -22,6 +22,8 @@ typedef struct LASIPS2Port {
>      bool irq;
>  } LASIPS2Port;
>
> +#define LASIPS2_IRQ    0

If you find yourself #defining names for IRQ lines then this is
probably a sign you should be using named GPIO lines :-)

Alternatively, maybe use sysbus_init_irq()? By convention the
only sysbus IRQ on a device is generally "its IRQ line".

-- PMM



reply via email to

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