Skip to contentSkip to conversation

rtc: initialize irq even if caller doesn't use rtc_init() function

PATCH In review Hervé Poussineau 2 participants 4 messages Jan 23, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rtc: initialize irq even if caller doesn't use rtc_init() function

rtc instanciated with -device has now a working irq line

---
 hw/mc146818rtc.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
hw/mc146818rtc.c +2 -2
index 657fa10..3067022 100644
@@ -672,6 +672,7 @@ static int rtc_initfn(ISADevice *dev)
 
     memory_region_init_io(&s->io, &cmos_ops, s, "rtc", 2);
     isa_register_ioport(dev, &s->io, base);
+    isa_init_irq(dev, &s->irq, RTC_ISA_IRQ);
 
     qdev_set_legacy_instance_id(&dev->qdev, base, 2);
     qemu_register_reset(rtc_reset, s);
@@ -692,9 +693,8 @@ ISADevice *rtc_init(ISABus *bus, int base_year, qemu_irq intercept_irq)
     qdev_prop_set_int32(&dev->qdev, "base_year", base_year);
     qdev_init_nofail(&dev->qdev);
     if (intercept_irq) {
+        /* Use provided IRQ instead of default one */
         s->irq = intercept_irq;
-    } else {
-        isa_init_irq(dev, &s->irq, RTC_ISA_IRQ);
     }
     return dev;
 }
Signature · 1 line
1.7.7.3
#1 lore raw
Quoted 1 line · Hervé Poussineau

rtc instanciated with -device has now a working irq line

That makes no sense. The mc146818rtc is no_user - for a reason.

What is the use case you are trying to address?

Jan

Quoted 29 lines
---
 hw/mc146818rtc.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
hw/mc146818rtc.c +2 -2
index 657fa10..3067022 100644
@@ -672,6 +672,7 @@ static int rtc_initfn(ISADevice *dev)
 
     memory_region_init_io(&s->io, &cmos_ops, s, "rtc", 2);
     isa_register_ioport(dev, &s->io, base);
+    isa_init_irq(dev, &s->irq, RTC_ISA_IRQ);
 
     qdev_set_legacy_instance_id(&dev->qdev, base, 2);
     qemu_register_reset(rtc_reset, s);
@@ -692,9 +693,8 @@ ISADevice *rtc_init(ISABus *bus, int base_year, qemu_irq intercept_irq)
     qdev_prop_set_int32(&dev->qdev, "base_year", base_year);
     qdev_init_nofail(&dev->qdev);
     if (intercept_irq) {
+        /* Use provided IRQ instead of default one */
         s->irq = intercept_irq;
-    } else {
-        isa_init_irq(dev, &s->irq, RTC_ISA_IRQ);
     }
     return dev;
 }
Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
#2 lore raw
Quoted 7 lines · Jan Kiszka
Quoted 1 line · Hervé Poussineau

rtc instanciated with -device has now a working irq line

That makes no sense. The mc146818rtc is no_user - for a reason.

What is the use case you are trying to address?

I wanted to be able to instanciate it with isa_create_simple(isa_bus, "mc146818rtc") in machine init code. I don't see any good reason why a rtc created this way can't work.

The commit message can be changed to:
"rtc: initialize irq even if caller doesn't use rtc_init() function rtc instancianted with isa_create_simple() has now a working irq line" if you prefer...

Hervé

#3 lore raw
Quoted 11 lines · Hervé Poussineau
Quoted 7 lines · Jan Kiszka
Quoted 1 line · Hervé Poussineau

rtc instanciated with -device has now a working irq line

That makes no sense. The mc146818rtc is no_user - for a reason.

What is the use case you are trying to address?

I wanted to be able to instanciate it with isa_create_simple(isa_bus, "mc146818rtc") in machine init code.

Why?

Quoted 1 line

I don't see any good reason why a rtc created this way can't work.

You will still need to set the base year then, manually. And your machine has no legacy RTC replacement logic like the PC?

I just don't get the benefit.

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux