Skip to contentSkip to conversation

hw/rtc: Convert RTC devices to Resettable interface

PATCH New Oscar Alejandro Sánchez Lucero 1 participant 8 messages Dec 1

Subsystems (3)
lore
Share & tools
lore
#3 lore raw

PATCH 3/7 hw/rtc/goldfish_rtc: Convert to Resettable interface

In reply to Oscar Alejandro Sánchez Lucero

Replace the deprecated device_class_set_legacy_reset() with the Resettable interface by implementing the hold phase in goldfish_rtc_reset_hold().

---
 hw/rtc/goldfish_rtc.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
hw/rtc/goldfish_rtc.c +4 -3
index 5354a6b..f57d021 100644
@@ -236,9 +236,9 @@ static const VMStateDescription goldfish_rtc_vmstate = {
     }
 };
 
-static void goldfish_rtc_reset(DeviceState *dev)
+static void goldfish_rtc_reset_hold(Object *obj, ResetType type)
 {
-    GoldfishRTCState *s = GOLDFISH_RTC(dev);
+    GoldfishRTCState *s = GOLDFISH_RTC(obj);
 
     timer_del(s->timer);
     s->alarm_next = 0;
@@ -276,10 +276,11 @@ static const Property goldfish_rtc_properties[] = {
 static void goldfish_rtc_class_init(ObjectClass *klass, const void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
+    ResettableClass *rc = RESETTABLE_CLASS(klass);
 
     device_class_set_props(dc, goldfish_rtc_properties);
     dc->realize = goldfish_rtc_realize;
-    device_class_set_legacy_reset(dc, goldfish_rtc_reset);
+    rc->phases.hold = goldfish_rtc_reset_hold;
     dc->vmsd = &goldfish_rtc_vmstate;
 }
 
Signature · 1 line
2.53.0
#2 lore raw

PATCH 2/7 hw/rtc/exynos4210_rtc: Convert to Resettable interface

In reply to Oscar Alejandro Sánchez Lucero

Replace the deprecated device_class_set_legacy_reset() with the Resettable interface by implementing the hold phase in exynos4210_rtc_reset_hold().

---
 hw/rtc/exynos4210_rtc.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
hw/rtc/exynos4210_rtc.c +4 -3
index 846839d..720b1c9 100644
@@ -518,9 +518,9 @@ static void exynos4210_rtc_write(void *opaque, hwaddr offset,
 /*
  * Set default values to timer fields and registers
  */
-static void exynos4210_rtc_reset(DeviceState *d)
+static void exynos4210_rtc_reset_hold(Object *obj, ResetType type)
 {
-    Exynos4210RTCState *s = EXYNOS4210_RTC(d);
+    Exynos4210RTCState *s = EXYNOS4210_RTC(obj);
 
     qemu_get_timedate(&s->current_tm, 0);
 
@@ -595,8 +595,9 @@ static void exynos4210_rtc_finalize(Object *obj)
 static void exynos4210_rtc_class_init(ObjectClass *klass, const void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
+    ResettableClass *rc = RESETTABLE_CLASS(klass);
 
-    device_class_set_legacy_reset(dc, exynos4210_rtc_reset);
+    rc->phases.hold = exynos4210_rtc_reset_hold;
     dc->vmsd = &vmstate_exynos4210_rtc_state;
 }
 
Signature · 1 line
2.53.0
#4 lore raw

PATCH 4/7 hw/rtc/ls7a_rtc: Convert to Resettable interface

In reply to Oscar Alejandro Sánchez Lucero

Replace the deprecated device_class_set_legacy_reset() with the Resettable interface by implementing the hold phase in ls7a_rtc_reset_hold().

---
 hw/rtc/ls7a_rtc.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
hw/rtc/ls7a_rtc.c +5 -4
index 158c815..2f08edc 100644
@@ -406,11 +406,10 @@ static void ls7a_rtc_realize(DeviceState *dev, Error **errp)
 }
 
 /* delete timer and clear reg when reset */
-static void ls7a_rtc_reset(DeviceState *dev)
+static void ls7a_rtc_reset_hold(Object *obj, ResetType type)
 {
     int i;
-    SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
-    LS7ARtcState *d = LS7A_RTC(sbd);
+    LS7ARtcState *d = LS7A_RTC(obj);
     for (i = 0; i < TIMER_NUMS; i++) {
         if (toy_enabled(d)) {
             timer_del(d->toy_timer[i]);
@@ -467,9 +466,11 @@ static const VMStateDescription vmstate_ls7a_rtc = {
 static void ls7a_rtc_class_init(ObjectClass *klass, const void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
+    ResettableClass *rc = RESETTABLE_CLASS(klass);
+
     dc->vmsd = &vmstate_ls7a_rtc;
     dc->realize = ls7a_rtc_realize;
-    device_class_set_legacy_reset(dc, ls7a_rtc_reset);
+    rc->phases.hold = ls7a_rtc_reset_hold;
     dc->desc = "ls7a rtc";
 }
 
Signature · 1 line
2.53.0
#0 lore raw

cover hw/rtc: Convert RTC devices to Resettable interface

Convert all remaining RTC devices in hw/rtc/ away from the deprecated device_class_set_legacy_reset() wrapper to the ResettableClass interface (hold phase), moving towards removing the legacy_reset callback from DeviceClass once all callers are migrated (as noted in include/hw/core/qdev.h).

---
Oscar Alejandro Sánchez Lucero (7):
hw/rtc/allwinner-rtc: Convert to Resettable interface hw/rtc/exynos4210_rtc: Convert to Resettable interface hw/rtc/goldfish_rtc: Convert to Resettable interface hw/rtc/ls7a_rtc: Convert to Resettable interface hw/rtc/m48t59-isa: Convert to Resettable interface hw/rtc/m48t59: Convert to Resettable interface hw/rtc/xlnx-zynqmp-rtc: Convert to Resettable interface

 hw/rtc/allwinner-rtc.c   | 7 ++++---
 hw/rtc/exynos4210_rtc.c  | 7 ++++---
 hw/rtc/goldfish_rtc.c    | 7 ++++---
 hw/rtc/ls7a_rtc.c        | 9 +++++----
 hw/rtc/m48t59-isa.c      | 7 ++++---
 hw/rtc/m48t59.c          | 7 ++++---
 hw/rtc/xlnx-zynqmp-rtc.c | 7 ++++---
 7 files changed, 29 insertions(+), 22 deletions(-)

---
base-commit: bbece0805c03c25f51a8cd89c39142f4f76a6567
change-id: 20261201-rtc-resettable-6fedc67cdd15

Best regards,

Signature · 1 line
Oscar Alejandro Sánchez Lucero <[email protected]>
#1 lore raw

PATCH 1/7 hw/rtc/allwinner-rtc: Convert to Resettable interface

Replace the deprecated device_class_set_legacy_reset() with the Resettable interface by implementing the hold phase in allwinner_rtc_reset_hold().

---
 hw/rtc/allwinner-rtc.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
hw/rtc/allwinner-rtc.c +4 -3
index 52006a0..3db7825 100644
@@ -267,9 +267,9 @@ static const MemoryRegionOps allwinner_rtc_ops = {
     .impl.min_access_size = 4,
 };
 
-static void allwinner_rtc_reset(DeviceState *dev)
+static void allwinner_rtc_reset_hold(Object *obj, ResetType type)
 {
-    AwRtcState *s = AW_RTC(dev);
+    AwRtcState *s = AW_RTC(obj);
     struct tm now;
 
     /* Clear registers */
@@ -318,8 +318,9 @@ static const Property allwinner_rtc_properties[] = {
 static void allwinner_rtc_class_init(ObjectClass *klass, const void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
+    ResettableClass *rc = RESETTABLE_CLASS(klass);
 
-    device_class_set_legacy_reset(dc, allwinner_rtc_reset);
+    rc->phases.hold = allwinner_rtc_reset_hold;
     dc->vmsd = &allwinner_rtc_vmstate;
     device_class_set_props(dc, allwinner_rtc_properties);
 }
Signature · 1 line
2.53.0
#6 lore raw

PATCH 6/7 hw/rtc/m48t59: Convert to Resettable interface

In reply to Oscar Alejandro Sánchez Lucero

Replace the deprecated device_class_set_legacy_reset() with the Resettable interface by implementing the hold phase in m48t59_reset_sysbus_hold().

---
 hw/rtc/m48t59.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
hw/rtc/m48t59.c +4 -3
index be4196b..f6fc638 100644
@@ -545,9 +545,9 @@ void m48t59_reset_common(M48t59State *NVRAM)
         timer_del(NVRAM->wd_timer);
 }
 
-static void m48t59_reset_sysbus(DeviceState *d)
+static void m48t59_reset_sysbus_hold(Object *obj, ResetType type)
 {
-    M48txxSysBusState *sys = M48TXX_SYS_BUS(d);
+    M48txxSysBusState *sys = M48TXX_SYS_BUS(obj);
     M48t59State *NVRAM = &sys->state;
 
     m48t59_reset_common(NVRAM);
@@ -626,9 +626,10 @@ static void m48txx_sysbus_class_init(ObjectClass *klass, const void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
     NvramClass *nc = NVRAM_CLASS(klass);
+    ResettableClass *rc = RESETTABLE_CLASS(klass);
 
     dc->realize = m48t59_realize;
-    device_class_set_legacy_reset(dc, m48t59_reset_sysbus);
+    rc->phases.hold = m48t59_reset_sysbus_hold;
     device_class_set_props(dc, m48t59_sysbus_properties);
     dc->vmsd = &vmstate_m48t59;
     nc->read = m48txx_sysbus_read;
Signature · 1 line
2.53.0
#7 lore raw

PATCH 7/7 hw/rtc/xlnx-zynqmp-rtc: Convert to Resettable interface

In reply to Oscar Alejandro Sánchez Lucero

Replace the deprecated device_class_set_legacy_reset() with the Resettable interface by implementing the hold phase in rtc_reset_hold().

---
 hw/rtc/xlnx-zynqmp-rtc.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
hw/rtc/xlnx-zynqmp-rtc.c +4 -3
index 28ae7a2..cf6e7bb 100644
@@ -158,9 +158,9 @@ static const RegisterAccessInfo rtc_regs_info[] = {
     }
 };
 
-static void rtc_reset(DeviceState *dev)
+static void rtc_reset_hold(Object *obj, ResetType type)
 {
-    XlnxZynqMPRTC *s = XLNX_ZYNQMP_RTC(dev);
+    XlnxZynqMPRTC *s = XLNX_ZYNQMP_RTC(obj);
     unsigned int i;
 
     for (i = 0; i < ARRAY_SIZE(s->regs_info); ++i) {
@@ -254,8 +254,9 @@ static const VMStateDescription vmstate_rtc = {
 static void rtc_class_init(ObjectClass *klass, const void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
+    ResettableClass *rc = RESETTABLE_CLASS(klass);
 
-    device_class_set_legacy_reset(dc, rtc_reset);
+    rc->phases.hold = rtc_reset_hold;
     dc->vmsd = &vmstate_rtc;
 }
 
Signature · 1 line
2.53.0
#5 lore raw

PATCH 5/7 hw/rtc/m48t59-isa: Convert to Resettable interface

In reply to Oscar Alejandro Sánchez Lucero

Replace the deprecated device_class_set_legacy_reset() with the Resettable interface by implementing the hold phase in m48t59_reset_isa_hold().

---
 hw/rtc/m48t59-isa.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
hw/rtc/m48t59-isa.c +4 -3
index ea0f307..e40746e 100644
@@ -83,9 +83,9 @@ static const Property m48t59_isa_properties[] = {
     DEFINE_PROP_UINT8("irq", M48txxISAState, isairq, 8),
 };
 
-static void m48t59_reset_isa(DeviceState *d)
+static void m48t59_reset_isa_hold(Object *obj, ResetType type)
 {
-    M48txxISAState *isa = M48TXX_ISA(d);
+    M48txxISAState *isa = M48TXX_ISA(obj);
     M48t59State *NVRAM = &isa->state;
 
     m48t59_reset_common(NVRAM);
@@ -117,9 +117,10 @@ static void m48txx_isa_class_init(ObjectClass *klass, const void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
     NvramClass *nc = NVRAM_CLASS(klass);
+    ResettableClass *rc = RESETTABLE_CLASS(klass);
 
     dc->realize = m48t59_isa_realize;
-    device_class_set_legacy_reset(dc, m48t59_reset_isa);
+    rc->phases.hold = m48t59_reset_isa_hold;
     device_class_set_props(dc, m48t59_isa_properties);
     nc->read = m48txx_isa_read;
     nc->write = m48txx_isa_write;
Signature · 1 line
2.53.0