aboutsummaryrefslogtreecommitdiff
path: root/hw/i2c/smbus_eeprom.c
diff options
context:
space:
mode:
Diffstat (limited to 'hw/i2c/smbus_eeprom.c')
-rw-r--r--hw/i2c/smbus_eeprom.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/hw/i2c/smbus_eeprom.c b/hw/i2c/smbus_eeprom.c
index 125c887d1f..f18aa3de35 100644
--- a/hw/i2c/smbus_eeprom.c
+++ b/hw/i2c/smbus_eeprom.c
@@ -139,6 +139,16 @@ static void smbus_eeprom_register_types(void)
type_init(smbus_eeprom_register_types)
+void smbus_eeprom_init_one(I2CBus *smbus, uint8_t address, uint8_t *eeprom_buf)
+{
+ DeviceState *dev;
+
+ dev = qdev_create((BusState *) smbus, "smbus-eeprom");
+ qdev_prop_set_uint8(dev, "address", address);
+ qdev_prop_set_ptr(dev, "data", eeprom_buf);
+ qdev_init_nofail(dev);
+}
+
void smbus_eeprom_init(I2CBus *smbus, int nb_eeprom,
const uint8_t *eeprom_spd, int eeprom_spd_size)
{
@@ -149,10 +159,6 @@ void smbus_eeprom_init(I2CBus *smbus, int nb_eeprom,
}
for (i = 0; i < nb_eeprom; i++) {
- DeviceState *eeprom;
- eeprom = qdev_create((BusState *)smbus, "smbus-eeprom");
- qdev_prop_set_uint8(eeprom, "address", 0x50 + i);
- qdev_prop_set_ptr(eeprom, "data", eeprom_buf + (i * 256));
- qdev_init_nofail(eeprom);
+ smbus_eeprom_init_one(smbus, 0x50 + i, eeprom_buf + (i * 256));
}
}