hw/i2c/smbus_eeprom.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
Replace the deprecated device_class_set_legacy_reset() with the Resettable interface by implementing the hold phase in smbus_eeprom_reset_hold().
Signed-off-by: Oscar Alejandro Sánchez Lucero <aleszlucero@gmail.com>
---
hw/i2c/smbus_eeprom.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/hw/i2c/smbus_eeprom.c b/hw/i2c/smbus_eeprom.c
index 693d476..d1ed109 100644
--- a/hw/i2c/smbus_eeprom.c
+++ b/hw/i2c/smbus_eeprom.c
@@ -117,9 +117,9 @@ static const VMStateDescription vmstate_smbus_eeprom = {
* the contents and restore that on startup, and not do this on reset.
* But until that time, act as if we had been stopped and restarted.
*/
-static void smbus_eeprom_reset(DeviceState *dev)
+static void smbus_eeprom_reset_hold(Object *obj, ResetType type)
{
- SMBusEEPROMDevice *eeprom = SMBUS_EEPROM(dev);
+ SMBusEEPROMDevice *eeprom = SMBUS_EEPROM(obj);
memcpy(eeprom->data, eeprom->init_data, SMBUS_EEPROM_SIZE);
eeprom->offset = 0;
@@ -129,7 +129,7 @@ static void smbus_eeprom_realize(DeviceState *dev, Error **errp)
{
SMBusEEPROMDevice *eeprom = SMBUS_EEPROM(dev);
- smbus_eeprom_reset(dev);
+ device_cold_reset(dev);
if (eeprom->init_data == NULL) {
error_setg(errp, "init_data cannot be NULL");
}
@@ -138,10 +138,11 @@ static void smbus_eeprom_realize(DeviceState *dev, Error **errp)
static void smbus_eeprom_class_initfn(ObjectClass *klass, const void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
+ ResettableClass *rc = RESETTABLE_CLASS(klass);
SMBusDeviceClass *sc = SMBUS_DEVICE_CLASS(klass);
dc->realize = smbus_eeprom_realize;
- device_class_set_legacy_reset(dc, smbus_eeprom_reset);
+ rc->phases.hold = smbus_eeprom_reset_hold;
sc->receive_byte = eeprom_receive_byte;
sc->write_data = eeprom_write_data;
dc->vmsd = &vmstate_smbus_eeprom;
---
base-commit: 9751c62358073580cbf330a4df22077a7c6a407c
change-id: 20261202-i2c-smbus-eeprom-resettable-48df1ba471dd
Best regards,
--
Oscar Alejandro Sánchez Lucero <aleszlucero@gmail.com>
© 2016 - 2026 Red Hat, Inc.