Skip to contentSkip to conversation

hw/adc: Convert ADC devices to Resettable interface

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

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

PATCH 2/2 hw/adc/zynq-xadc: 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 zynq_xadc_reset_hold().

---
 hw/adc/zynq-xadc.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
hw/adc/zynq-xadc.c +4 -3
index 1934ef0..ad747fa 100644
@@ -89,9 +89,9 @@ static void zynq_xadc_update_ints(ZynqXADCState *s)
     qemu_set_irq(s->irq, !!(s->regs[INT_STS] & ~s->regs[INT_MASK]));
 }
 
-static void zynq_xadc_reset(DeviceState *d)
+static void zynq_xadc_reset_hold(Object *obj, ResetType type)
 {
-    ZynqXADCState *s = ZYNQ_XADC(d);
+    ZynqXADCState *s = ZYNQ_XADC(obj);
 
     s->regs[CFG] = 0x14 << CFG_IGAP_SHIFT |
                    CFG_TCKRATE_DIV(4) << CFG_TCKRATE_SHIFT | CFG_REDGE;
@@ -284,9 +284,10 @@ static const VMStateDescription vmstate_zynq_xadc = {
 static void zynq_xadc_class_init(ObjectClass *klass, const void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
+    ResettableClass *rc = RESETTABLE_CLASS(klass);
 
     dc->vmsd = &vmstate_zynq_xadc;
-    device_class_set_legacy_reset(dc, zynq_xadc_reset);
+    rc->phases.hold = zynq_xadc_reset_hold;
 }
 
 static const TypeInfo zynq_xadc_info = {
Signature · 1 line
2.53.0
#0 lore raw

cover hw/adc: Convert ADC devices to Resettable interface

Convert the remaining ADC devices in hw/adc/ 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 (2):
hw/adc/stm32f2xx_adc: Convert to Resettable interface hw/adc/zynq-xadc: Convert to Resettable interface

 hw/adc/stm32f2xx_adc.c | 7 ++++---
 hw/adc/zynq-xadc.c     | 7 ++++---
 2 files changed, 8 insertions(+), 6 deletions(-)

---
base-commit: 9751c62358073580cbf330a4df22077a7c6a407c
change-id: 20261201-adc-resettable-1e846593aa1d

Best regards,

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

PATCH 1/2 hw/adc/stm32f2xx_adc: Convert to Resettable interface

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

---
 hw/adc/stm32f2xx_adc.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
hw/adc/stm32f2xx_adc.c +4 -3
index c8e05de..3151b74 100644
@@ -41,9 +41,9 @@
 
 #define DB_PRINT(fmt, args...) DB_PRINT_L(1, fmt, ## args)
 
-static void stm32f2xx_adc_reset(DeviceState *dev)
+static void stm32f2xx_adc_reset_hold(Object *obj, ResetType type)
 {
-    STM32F2XXADCState *s = STM32F2XX_ADC(dev);
+    STM32F2XXADCState *s = STM32F2XX_ADC(obj);
 
     s->adc_sr = 0x00000000;
     s->adc_cr1 = 0x00000000;
@@ -295,8 +295,9 @@ static void stm32f2xx_adc_init(Object *obj)
 static void stm32f2xx_adc_class_init(ObjectClass *klass, const void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
+    ResettableClass *rc = RESETTABLE_CLASS(klass);
 
-    device_class_set_legacy_reset(dc, stm32f2xx_adc_reset);
+    rc->phases.hold = stm32f2xx_adc_reset_hold;
     dc->vmsd = &vmstate_stm32f2xx_adc;
 }
 
Signature · 1 line
2.53.0