diff mbox series

[v2,02/22] hw/rtc/m48t59-isa: QOM'ify IRQ number

Message ID 20220222193446.156717-3-shentey@gmail.com (mailing list archive)
State New, archived
Headers show
Series isa: Resolve unneeded IRQ attributes from ISADevice | expand

Commit Message

Bernhard Beschow Feb. 22, 2022, 7:34 p.m. UTC
Exposing the IRQ number as a QOM property not only allows it to be
configurable but also to be printed by standard QOM mechanisms. This allows
isabus_dev_print() to be retired eventually.

Signed-off-by: Bernhard Beschow <shentey@gmail.com>
---
 hw/rtc/m48t59-isa.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

Comments

Philippe Mathieu-Daudé Feb. 27, 2022, 10:13 p.m. UTC | #1
On 22/2/22 20:34, Bernhard Beschow wrote:
> Exposing the IRQ number as a QOM property not only allows it to be
> configurable but also to be printed by standard QOM mechanisms. This allows
> isabus_dev_print() to be retired eventually.
> 
> Signed-off-by: Bernhard Beschow <shentey@gmail.com>
> ---
>   hw/rtc/m48t59-isa.c | 9 ++++++++-
>   1 file changed, 8 insertions(+), 1 deletion(-)

> @@ -97,9 +99,14 @@ static void m48t59_isa_realize(DeviceState *dev, Error **errp)
>       M48txxISAState *d = M48TXX_ISA(dev);
>       M48t59State *s = &d->state;
>   
> +    if (d->isairq >= ISA_NUM_IRQS) {
> +        error_setg(errp, "Maximum value for \"irq\" is: %d", ISA_NUM_IRQS - 1);

Format is "%u".

> +        return;
> +    }

Similarly to patch #1, ISA_NUM_IRQS fits in uint8_t. Otherwise:

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
diff mbox series

Patch

diff --git a/hw/rtc/m48t59-isa.c b/hw/rtc/m48t59-isa.c
index dc21fb10a5..cd63138e1e 100644
--- a/hw/rtc/m48t59-isa.c
+++ b/hw/rtc/m48t59-isa.c
@@ -42,6 +42,7 @@  struct M48txxISAState {
     ISADevice parent_obj;
     M48t59State state;
     uint32_t io_base;
+    uint32_t isairq;
     MemoryRegion io;
 };
 
@@ -79,6 +80,7 @@  static void m48txx_isa_toggle_lock(Nvram *obj, int lock)
 static Property m48t59_isa_properties[] = {
     DEFINE_PROP_INT32("base-year", M48txxISAState, state.base_year, 0),
     DEFINE_PROP_UINT32("iobase", M48txxISAState, io_base, 0x74),
+    DEFINE_PROP_UINT32("irq", M48txxISAState, isairq, 8),
     DEFINE_PROP_END_OF_LIST(),
 };
 
@@ -97,9 +99,14 @@  static void m48t59_isa_realize(DeviceState *dev, Error **errp)
     M48txxISAState *d = M48TXX_ISA(dev);
     M48t59State *s = &d->state;
 
+    if (d->isairq >= ISA_NUM_IRQS) {
+        error_setg(errp, "Maximum value for \"irq\" is: %d", ISA_NUM_IRQS - 1);
+        return;
+    }
+
     s->model = u->info.model;
     s->size = u->info.size;
-    isa_init_irq(isadev, &s->IRQ, 8);
+    isa_init_irq(isadev, &s->IRQ, d->isairq);
     m48t59_realize_common(s, errp);
     memory_region_init_io(&d->io, OBJECT(dev), &m48t59_io_ops, s, "m48t59", 4);
     if (d->io_base != 0) {