mirror of https://github.com/proxmox/mirror_qemu
smbus-eeprom: remove PROP_PTR
Instead, set the initial data field directly. (the initial data is an array of 256 bytes. As I don't know if it may change over time, I keep the pointer to original buffer as is, but it might be worth to consider to copy it instead) Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Corey Minyard <cminyard@mvista.com>master
parent
f4f643882d
commit
b9751d205f
|
@ -44,7 +44,7 @@
|
||||||
typedef struct SMBusEEPROMDevice {
|
typedef struct SMBusEEPROMDevice {
|
||||||
SMBusDevice smbusdev;
|
SMBusDevice smbusdev;
|
||||||
uint8_t data[SMBUS_EEPROM_SIZE];
|
uint8_t data[SMBUS_EEPROM_SIZE];
|
||||||
void *init_data;
|
uint8_t *init_data;
|
||||||
uint8_t offset;
|
uint8_t offset;
|
||||||
bool accessed;
|
bool accessed;
|
||||||
} SMBusEEPROMDevice;
|
} SMBusEEPROMDevice;
|
||||||
|
@ -129,13 +129,13 @@ static void smbus_eeprom_reset(DeviceState *dev)
|
||||||
|
|
||||||
static void smbus_eeprom_realize(DeviceState *dev, Error **errp)
|
static void smbus_eeprom_realize(DeviceState *dev, Error **errp)
|
||||||
{
|
{
|
||||||
smbus_eeprom_reset(dev);
|
SMBusEEPROMDevice *eeprom = SMBUS_EEPROM(dev);
|
||||||
}
|
|
||||||
|
|
||||||
static Property smbus_eeprom_properties[] = {
|
smbus_eeprom_reset(dev);
|
||||||
DEFINE_PROP_PTR("data", SMBusEEPROMDevice, init_data),
|
if (eeprom->init_data == NULL) {
|
||||||
DEFINE_PROP_END_OF_LIST(),
|
error_setg(errp, "init_data cannot be NULL");
|
||||||
};
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void smbus_eeprom_class_initfn(ObjectClass *klass, void *data)
|
static void smbus_eeprom_class_initfn(ObjectClass *klass, void *data)
|
||||||
{
|
{
|
||||||
|
@ -146,9 +146,8 @@ static void smbus_eeprom_class_initfn(ObjectClass *klass, void *data)
|
||||||
dc->reset = smbus_eeprom_reset;
|
dc->reset = smbus_eeprom_reset;
|
||||||
sc->receive_byte = eeprom_receive_byte;
|
sc->receive_byte = eeprom_receive_byte;
|
||||||
sc->write_data = eeprom_write_data;
|
sc->write_data = eeprom_write_data;
|
||||||
dc->props = smbus_eeprom_properties;
|
|
||||||
dc->vmsd = &vmstate_smbus_eeprom;
|
dc->vmsd = &vmstate_smbus_eeprom;
|
||||||
/* Reason: pointer property "data" */
|
/* Reason: init_data */
|
||||||
dc->user_creatable = false;
|
dc->user_creatable = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -172,7 +171,8 @@ void smbus_eeprom_init_one(I2CBus *smbus, uint8_t address, uint8_t *eeprom_buf)
|
||||||
|
|
||||||
dev = qdev_create((BusState *) smbus, TYPE_SMBUS_EEPROM);
|
dev = qdev_create((BusState *) smbus, TYPE_SMBUS_EEPROM);
|
||||||
qdev_prop_set_uint8(dev, "address", address);
|
qdev_prop_set_uint8(dev, "address", address);
|
||||||
qdev_prop_set_ptr(dev, "data", eeprom_buf);
|
/* FIXME: use an array of byte or block backend property? */
|
||||||
|
SMBUS_EEPROM(dev)->init_data = eeprom_buf;
|
||||||
qdev_init_nofail(dev);
|
qdev_init_nofail(dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue