* [PATCH v2 0/2] hw/ipack: Minor dust removal @ 2025-01-21 8:44 Philippe Mathieu-Daudé 2025-01-21 8:44 ` [PATCH v2 1/2] hw/ipack: Clarify KConfig symbols Philippe Mathieu-Daudé 2025-01-21 8:44 ` [PATCH v2 2/2] hw/ipack: Remove legacy qemu_allocate_irqs() use Philippe Mathieu-Daudé 0 siblings, 2 replies; 6+ messages in thread From: Philippe Mathieu-Daudé @ 2025-01-21 8:44 UTC (permalink / raw) To: qemu-devel Cc: Alberto Garcia, Fabiano Rosas, Laurent Vivier, Bernhard Beschow, Marc-André Lureau, Paolo Bonzini, Philippe Mathieu-Daudé Clarify what is what in Kconfig, replace qemu_allocate_irqs() by qemu_init_irq(). Since v1: - s/qemu_irq/IRQState/ in IPackDevice state Philippe Mathieu-Daudé (2): hw/ipack: Clarify KConfig symbols hw/ipack: Remove legacy qemu_allocate_irqs() use include/hw/ipack/ipack.h | 7 ++----- hw/char/ipoctal232.c | 4 ++-- hw/ipack/ipack.c | 7 +++---- hw/ipack/tpci200.c | 6 +++--- hw/char/Kconfig | 5 +++++ hw/char/meson.build | 2 +- hw/ipack/Kconfig | 4 ++++ hw/ipack/meson.build | 3 ++- tests/qtest/libqos/meson.build | 4 +++- tests/qtest/meson.build | 4 +++- 10 files changed, 28 insertions(+), 18 deletions(-) -- 2.47.1 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2 1/2] hw/ipack: Clarify KConfig symbols 2025-01-21 8:44 [PATCH v2 0/2] hw/ipack: Minor dust removal Philippe Mathieu-Daudé @ 2025-01-21 8:44 ` Philippe Mathieu-Daudé 2025-01-21 8:44 ` [PATCH v2 2/2] hw/ipack: Remove legacy qemu_allocate_irqs() use Philippe Mathieu-Daudé 1 sibling, 0 replies; 6+ messages in thread From: Philippe Mathieu-Daudé @ 2025-01-21 8:44 UTC (permalink / raw) To: qemu-devel Cc: Alberto Garcia, Fabiano Rosas, Laurent Vivier, Bernhard Beschow, Marc-André Lureau, Paolo Bonzini, Philippe Mathieu-Daudé Split IPACK Kconfig key as {IPACK, TPCI200, IP_OCTAL_232} - IPack is a bus - TPCI200 is a PCI device providing an IPack bus - IP-Octal232 is an IPack device plugged on an IPack bus Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> --- hw/char/Kconfig | 5 +++++ hw/char/meson.build | 2 +- hw/ipack/Kconfig | 4 ++++ hw/ipack/meson.build | 3 ++- tests/qtest/libqos/meson.build | 4 +++- tests/qtest/meson.build | 4 +++- 6 files changed, 18 insertions(+), 4 deletions(-) diff --git a/hw/char/Kconfig b/hw/char/Kconfig index 4b73a803bf3..1dc20ee4c2c 100644 --- a/hw/char/Kconfig +++ b/hw/char/Kconfig @@ -78,3 +78,8 @@ config GOLDFISH_TTY config SHAKTI_UART bool + +config IP_OCTAL_232 + bool + default y + depends on IPACK diff --git a/hw/char/meson.build b/hw/char/meson.build index 1750834385a..ed3529cbbb7 100644 --- a/hw/char/meson.build +++ b/hw/char/meson.build @@ -4,7 +4,7 @@ system_ss.add(when: 'CONFIG_ESCC', if_true: files('escc.c')) system_ss.add(when: 'CONFIG_GRLIB', if_true: files('grlib_apbuart.c')) system_ss.add(when: 'CONFIG_IBEX', if_true: files('ibex_uart.c')) system_ss.add(when: 'CONFIG_IMX', if_true: files('imx_serial.c')) -system_ss.add(when: 'CONFIG_IPACK', if_true: files('ipoctal232.c')) +system_ss.add(when: 'CONFIG_IP_OCTAL_232', if_true: files('ipoctal232.c')) system_ss.add(when: 'CONFIG_ISA_BUS', if_true: files('parallel-isa.c')) system_ss.add(when: 'CONFIG_ISA_DEBUG', if_true: files('debugcon.c')) system_ss.add(when: 'CONFIG_NRF51_SOC', if_true: files('nrf51_uart.c')) diff --git a/hw/ipack/Kconfig b/hw/ipack/Kconfig index f8da24a62be..28d668727c8 100644 --- a/hw/ipack/Kconfig +++ b/hw/ipack/Kconfig @@ -1,4 +1,8 @@ config IPACK bool + +config TPCI200 + bool + select IPACK default y if PCI_DEVICES depends on PCI diff --git a/hw/ipack/meson.build b/hw/ipack/meson.build index 26567f1068e..e4805228926 100644 --- a/hw/ipack/meson.build +++ b/hw/ipack/meson.build @@ -1 +1,2 @@ -system_ss.add(when: 'CONFIG_IPACK', if_true: files('ipack.c', 'tpci200.c')) +system_ss.add(when: 'CONFIG_IPACK', if_true: files('ipack.c')) +system_ss.add(when: 'CONFIG_TPCI200', if_true: files('tpci200.c')) diff --git a/tests/qtest/libqos/meson.build b/tests/qtest/libqos/meson.build index 46f130ccfdb..1ddaf7b095b 100644 --- a/tests/qtest/libqos/meson.build +++ b/tests/qtest/libqos/meson.build @@ -32,7 +32,6 @@ libqos_srcs = files( 'i2c-omap.c', 'igb.c', 'sdhci.c', - 'tpci200.c', 'virtio.c', 'virtio-balloon.c', 'virtio-blk.c', @@ -70,6 +69,9 @@ endif if config_all_devices.has_key('CONFIG_RISCV_IOMMU') libqos_srcs += files('riscv-iommu.c') endif +if config_all_devices.has_key('CONFIG_TPCI200') + libqos_srcs += files('tpci200.c') +endif libqos = static_library('qos', libqos_srcs + genh, build_by_default: false) diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build index 94b28e5a534..e60e92fe9de 100644 --- a/tests/qtest/meson.build +++ b/tests/qtest/meson.build @@ -286,7 +286,6 @@ qos_test_ss.add( 'e1000-test.c', 'eepro100-test.c', 'es1370-test.c', - 'ipoctal232-test.c', 'lsm303dlhc-mag-test.c', 'isl_pmbus_vr-test.c', 'max34451-test.c', @@ -317,6 +316,9 @@ qos_test_ss.add( if config_all_devices.has_key('CONFIG_VIRTIO_SERIAL') qos_test_ss.add(files('virtio-serial-test.c')) endif +if config_all_devices.has_key('CONFIG_IP_OCTAL_232') + qos_test_ss.add(files('ipoctal232-test.c')) +endif if host_os != 'windows' qos_test_ss.add(files('e1000e-test.c')) -- 2.47.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v2 2/2] hw/ipack: Remove legacy qemu_allocate_irqs() use 2025-01-21 8:44 [PATCH v2 0/2] hw/ipack: Minor dust removal Philippe Mathieu-Daudé 2025-01-21 8:44 ` [PATCH v2 1/2] hw/ipack: Clarify KConfig symbols Philippe Mathieu-Daudé @ 2025-01-21 8:44 ` Philippe Mathieu-Daudé 2025-01-21 9:24 ` Bernhard Beschow 1 sibling, 1 reply; 6+ messages in thread From: Philippe Mathieu-Daudé @ 2025-01-21 8:44 UTC (permalink / raw) To: qemu-devel Cc: Alberto Garcia, Fabiano Rosas, Laurent Vivier, Bernhard Beschow, Marc-André Lureau, Paolo Bonzini, Philippe Mathieu-Daudé 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/char/ipoctal232.c | 4 ++-- hw/ipack/ipack.c | 7 +++---- hw/ipack/tpci200.c | 6 +++--- 4 files changed, 10 insertions(+), 14 deletions(-) diff --git a/include/hw/ipack/ipack.h b/include/hw/ipack/ipack.h index cbcdda509d3..00f397fd020 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; + IRQState irq[2]; }; extern const VMStateDescription vmstate_ipack_device; diff --git a/hw/char/ipoctal232.c b/hw/char/ipoctal232.c index d1e5f6dad2e..a2879977fb3 100644 --- a/hw/char/ipoctal232.c +++ b/hw/char/ipoctal232.c @@ -184,9 +184,9 @@ static void update_irq(IPOctalState *dev, unsigned block) unsigned intno = block / 2; if ((blk0->isr & blk0->imr) || (blk1->isr & blk1->imr)) { - qemu_irq_raise(idev->irq[intno]); + qemu_irq_raise(&idev->irq[intno]); } else { - qemu_irq_lower(idev->irq[intno]); + qemu_irq_lower(&idev->irq[intno]); } } diff --git a/hw/ipack/ipack.c b/hw/ipack/ipack.c index ed75f791832..eeb48dd331c 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[] = { diff --git a/hw/ipack/tpci200.c b/hw/ipack/tpci200.c index 88eef4b8308..470a4203ae4 100644 --- a/hw/ipack/tpci200.c +++ b/hw/ipack/tpci200.c @@ -275,11 +275,11 @@ static void tpci200_write_las0(void *opaque, hwaddr addr, uint64_t val, if (ip != NULL) { if (val & STATUS_INT(i, 0)) { DPRINTF("Clear IP %c INT0# status\n", 'A' + i); - qemu_irq_lower(ip->irq[0]); + qemu_irq_lower(&ip->irq[0]); } if (val & STATUS_INT(i, 1)) { DPRINTF("Clear IP %c INT1# status\n", 'A' + i); - qemu_irq_lower(ip->irq[1]); + qemu_irq_lower(&ip->irq[1]); } } @@ -344,7 +344,7 @@ static uint64_t tpci200_read_las1(void *opaque, hwaddr addr, unsigned size) bool int_set = s->status & STATUS_INT(ip_n, intno); bool int_edge_sensitive = s->ctrl[ip_n] & CTRL_INT_EDGE(intno); if (int_set && !int_edge_sensitive) { - qemu_irq_lower(ip->irq[intno]); + qemu_irq_lower(&ip->irq[intno]); } } -- 2.47.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v2 2/2] hw/ipack: Remove legacy qemu_allocate_irqs() use 2025-01-21 8:44 ` [PATCH v2 2/2] hw/ipack: Remove legacy qemu_allocate_irqs() use Philippe Mathieu-Daudé @ 2025-01-21 9:24 ` Bernhard Beschow 2025-01-21 10:04 ` Philippe Mathieu-Daudé 0 siblings, 1 reply; 6+ messages in thread From: Bernhard Beschow @ 2025-01-21 9:24 UTC (permalink / raw) To: Philippe Mathieu-Daudé, qemu-devel Cc: Alberto Garcia, Fabiano Rosas, Laurent Vivier, Marc-André Lureau, Paolo Bonzini Am 21. Januar 2025 08:44:52 UTC schrieb "Philippe Mathieu-Daudé" <philmd@linaro.org>: >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/char/ipoctal232.c | 4 ++-- > hw/ipack/ipack.c | 7 +++---- > hw/ipack/tpci200.c | 6 +++--- > 4 files changed, 10 insertions(+), 14 deletions(-) > >diff --git a/include/hw/ipack/ipack.h b/include/hw/ipack/ipack.h >index cbcdda509d3..00f397fd020 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; >+ IRQState irq[2]; > }; > > extern const VMStateDescription vmstate_ipack_device; >diff --git a/hw/char/ipoctal232.c b/hw/char/ipoctal232.c >index d1e5f6dad2e..a2879977fb3 100644 >--- a/hw/char/ipoctal232.c >+++ b/hw/char/ipoctal232.c >@@ -184,9 +184,9 @@ static void update_irq(IPOctalState *dev, unsigned block) > unsigned intno = block / 2; > > if ((blk0->isr & blk0->imr) || (blk1->isr & blk1->imr)) { >- qemu_irq_raise(idev->irq[intno]); >+ qemu_irq_raise(&idev->irq[intno]); > } else { >- qemu_irq_lower(idev->irq[intno]); >+ qemu_irq_lower(&idev->irq[intno]); > } > } > >diff --git a/hw/ipack/ipack.c b/hw/ipack/ipack.c >index ed75f791832..eeb48dd331c 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); I wonder if we eventually need a qemu_init_irqs() (note the plural) as we remove further uses of qemu_allocate_irqs(). >+ } > > 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[] = { >diff --git a/hw/ipack/tpci200.c b/hw/ipack/tpci200.c >index 88eef4b8308..470a4203ae4 100644 >--- a/hw/ipack/tpci200.c >+++ b/hw/ipack/tpci200.c >@@ -275,11 +275,11 @@ static void tpci200_write_las0(void *opaque, hwaddr addr, uint64_t val, > if (ip != NULL) { > if (val & STATUS_INT(i, 0)) { > DPRINTF("Clear IP %c INT0# status\n", 'A' + i); >- qemu_irq_lower(ip->irq[0]); >+ qemu_irq_lower(&ip->irq[0]); > } > if (val & STATUS_INT(i, 1)) { > DPRINTF("Clear IP %c INT1# status\n", 'A' + i); >- qemu_irq_lower(ip->irq[1]); >+ qemu_irq_lower(&ip->irq[1]); > } > } > >@@ -344,7 +344,7 @@ static uint64_t tpci200_read_las1(void *opaque, hwaddr addr, unsigned size) > bool int_set = s->status & STATUS_INT(ip_n, intno); > bool int_edge_sensitive = s->ctrl[ip_n] & CTRL_INT_EDGE(intno); > if (int_set && !int_edge_sensitive) { >- qemu_irq_lower(ip->irq[intno]); >+ qemu_irq_lower(&ip->irq[intno]); > } > } > With the above addressed: Reviewed-by: Bernhard Beschow <shentey@gmail.com> ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 2/2] hw/ipack: Remove legacy qemu_allocate_irqs() use 2025-01-21 9:24 ` Bernhard Beschow @ 2025-01-21 10:04 ` Philippe Mathieu-Daudé 2025-01-21 15:32 ` Bernhard Beschow 0 siblings, 1 reply; 6+ messages in thread From: Philippe Mathieu-Daudé @ 2025-01-21 10:04 UTC (permalink / raw) To: Bernhard Beschow, qemu-devel Cc: Alberto Garcia, Fabiano Rosas, Laurent Vivier, Marc-André Lureau, Paolo Bonzini On 21/1/25 10:24, Bernhard Beschow wrote: > > > Am 21. Januar 2025 08:44:52 UTC schrieb "Philippe Mathieu-Daudé" <philmd@linaro.org>: >> 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/char/ipoctal232.c | 4 ++-- >> hw/ipack/ipack.c | 7 +++---- >> hw/ipack/tpci200.c | 6 +++--- >> 4 files changed, 10 insertions(+), 14 deletions(-) >> >> diff --git a/include/hw/ipack/ipack.h b/include/hw/ipack/ipack.h >> index cbcdda509d3..00f397fd020 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; >> + IRQState irq[2]; >> }; >> >> extern const VMStateDescription vmstate_ipack_device; >> diff --git a/hw/char/ipoctal232.c b/hw/char/ipoctal232.c >> index d1e5f6dad2e..a2879977fb3 100644 >> --- a/hw/char/ipoctal232.c >> +++ b/hw/char/ipoctal232.c >> @@ -184,9 +184,9 @@ static void update_irq(IPOctalState *dev, unsigned block) >> unsigned intno = block / 2; >> >> if ((blk0->isr & blk0->imr) || (blk1->isr & blk1->imr)) { >> - qemu_irq_raise(idev->irq[intno]); >> + qemu_irq_raise(&idev->irq[intno]); >> } else { >> - qemu_irq_lower(idev->irq[intno]); >> + qemu_irq_lower(&idev->irq[intno]); >> } >> } >> >> diff --git a/hw/ipack/ipack.c b/hw/ipack/ipack.c >> index ed75f791832..eeb48dd331c 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); > > I wonder if we eventually need a qemu_init_irqs() (note the plural) as we remove further uses of qemu_allocate_irqs(). Yeah I thought about it, but looking at other "Initialize pre-allocated QOM object in place", we don't have helpers for arrays. Usually because we can set properties, and array initializer doesn't scale then. For now IRQ doesn't have properties, so can do. > With the above addressed: > Reviewed-by: Bernhard Beschow <shentey@gmail.com> Thanks! ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 2/2] hw/ipack: Remove legacy qemu_allocate_irqs() use 2025-01-21 10:04 ` Philippe Mathieu-Daudé @ 2025-01-21 15:32 ` Bernhard Beschow 0 siblings, 0 replies; 6+ messages in thread From: Bernhard Beschow @ 2025-01-21 15:32 UTC (permalink / raw) To: Philippe Mathieu-Daudé, qemu-devel Cc: Alberto Garcia, Fabiano Rosas, Laurent Vivier, Marc-André Lureau, Paolo Bonzini Am 21. Januar 2025 10:04:43 UTC schrieb "Philippe Mathieu-Daudé" <philmd@linaro.org>: >On 21/1/25 10:24, Bernhard Beschow wrote: >> >> >> Am 21. Januar 2025 08:44:52 UTC schrieb "Philippe Mathieu-Daudé" <philmd@linaro.org>: >>> 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/char/ipoctal232.c | 4 ++-- >>> hw/ipack/ipack.c | 7 +++---- >>> hw/ipack/tpci200.c | 6 +++--- >>> 4 files changed, 10 insertions(+), 14 deletions(-) >>> >>> diff --git a/include/hw/ipack/ipack.h b/include/hw/ipack/ipack.h >>> index cbcdda509d3..00f397fd020 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; >>> + IRQState irq[2]; >>> }; >>> >>> extern const VMStateDescription vmstate_ipack_device; >>> diff --git a/hw/char/ipoctal232.c b/hw/char/ipoctal232.c >>> index d1e5f6dad2e..a2879977fb3 100644 >>> --- a/hw/char/ipoctal232.c >>> +++ b/hw/char/ipoctal232.c >>> @@ -184,9 +184,9 @@ static void update_irq(IPOctalState *dev, unsigned block) >>> unsigned intno = block / 2; >>> >>> if ((blk0->isr & blk0->imr) || (blk1->isr & blk1->imr)) { >>> - qemu_irq_raise(idev->irq[intno]); >>> + qemu_irq_raise(&idev->irq[intno]); >>> } else { >>> - qemu_irq_lower(idev->irq[intno]); >>> + qemu_irq_lower(&idev->irq[intno]); >>> } >>> } >>> >>> diff --git a/hw/ipack/ipack.c b/hw/ipack/ipack.c >>> index ed75f791832..eeb48dd331c 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); >> >> I wonder if we eventually need a qemu_init_irqs() (note the plural) as we remove further uses of qemu_allocate_irqs(). > >Yeah I thought about it, but looking at other "Initialize pre-allocated >QOM object in place", we don't have helpers for arrays. Usually because >we can set properties, and array initializer doesn't scale then. Fair enough. I'd call this "addressed". > >For now IRQ doesn't have properties, so can do. > >> With the above addressed: >> Reviewed-by: Bernhard Beschow <shentey@gmail.com> > >Thanks! ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-01-21 15:32 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2025-01-21 8:44 [PATCH v2 0/2] hw/ipack: Minor dust removal Philippe Mathieu-Daudé 2025-01-21 8:44 ` [PATCH v2 1/2] hw/ipack: Clarify KConfig symbols Philippe Mathieu-Daudé 2025-01-21 8:44 ` [PATCH v2 2/2] hw/ipack: Remove legacy qemu_allocate_irqs() use Philippe Mathieu-Daudé 2025-01-21 9:24 ` Bernhard Beschow 2025-01-21 10:04 ` Philippe Mathieu-Daudé 2025-01-21 15:32 ` Bernhard Beschow
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).