Message ID | 20250121074412.70292-3-philmd@linaro.org |
---|---|
State | New |
Headers | show |
Series | hw/ipack: Minor dust removal | expand |
On 21/1/25 08:44, Philippe Mathieu-Daudé wrote: > No need to dynamically allocate IRQ when we know before hands > how many we'll use. Declare the 2 of them in IPackDevice state > and initialize them in the DeviceRealize handler. > > Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> > --- > include/hw/ipack/ipack.h | 7 ++----- > hw/ipack/ipack.c | 7 +++---- > 2 files changed, 5 insertions(+), 9 deletions(-) > > diff --git a/include/hw/ipack/ipack.h b/include/hw/ipack/ipack.h > index cbcdda509d3..14540281496 100644 > --- a/include/hw/ipack/ipack.h > +++ b/include/hw/ipack/ipack.h > struct IPackDevice { > - /*< private >*/ > DeviceState parent_obj; > - /*< public >*/ > > int32_t slot; > /* IRQ objects for the IndustryPack INT0# and INT1# */ > - qemu_irq *irq; > + qemu_irq irq[2]; Oops forgot to commit: - qemu_irq irq[2]; + IRQState irq[2]; > };
diff --git a/include/hw/ipack/ipack.h b/include/hw/ipack/ipack.h index cbcdda509d3..14540281496 100644 --- a/include/hw/ipack/ipack.h +++ b/include/hw/ipack/ipack.h @@ -12,6 +12,7 @@ #define QEMU_IPACK_H #include "hw/qdev-core.h" +#include "hw/irq.h" #include "qom/object.h" @@ -19,10 +20,8 @@ OBJECT_DECLARE_SIMPLE_TYPE(IPackBus, IPACK_BUS) struct IPackBus { - /*< private >*/ BusState parent_obj; - /* All fields are private */ uint8_t n_slots; uint8_t free_slot; qemu_irq_handler set_irq; @@ -58,13 +57,11 @@ struct IPackDeviceClass { }; struct IPackDevice { - /*< private >*/ DeviceState parent_obj; - /*< public >*/ int32_t slot; /* IRQ objects for the IndustryPack INT0# and INT1# */ - qemu_irq *irq; + qemu_irq irq[2]; }; extern const VMStateDescription vmstate_ipack_device; diff --git a/hw/ipack/ipack.c b/hw/ipack/ipack.c index ed75f791832..ef59f5dcd62 100644 --- a/hw/ipack/ipack.c +++ b/hw/ipack/ipack.c @@ -55,22 +55,21 @@ static void ipack_device_realize(DeviceState *dev, Error **errp) } bus->free_slot = idev->slot + 1; - idev->irq = qemu_allocate_irqs(bus->set_irq, idev, 2); + for (int i = 0; i < ARRAY_SIZE(idev->irq); i++) { + qemu_init_irq(idev->irq[i], bus->set_irq, idev, i); + } k->realize(dev, errp); } static void ipack_device_unrealize(DeviceState *dev) { - IPackDevice *idev = IPACK_DEVICE(dev); IPackDeviceClass *k = IPACK_DEVICE_GET_CLASS(dev); if (k->unrealize) { k->unrealize(dev); return; } - - qemu_free_irqs(idev->irq, 2); } static const Property ipack_device_props[] = {
No need to dynamically allocate IRQ when we know before hands how many we'll use. Declare the 2 of them in IPackDevice state and initialize them in the DeviceRealize handler. Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> --- include/hw/ipack/ipack.h | 7 ++----- hw/ipack/ipack.c | 7 +++---- 2 files changed, 5 insertions(+), 9 deletions(-)