[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 28/33] smbus-eeprom: remove PROP_PTR
From: |
Marc-André Lureau |
Subject: |
[PATCH v3 28/33] smbus-eeprom: remove PROP_PTR |
Date: |
Wed, 23 Oct 2019 19:31:49 +0200 |
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 <address@hidden>
---
hw/i2c/smbus_eeprom.c | 17 ++++++++---------
1 file changed, 8 insertions(+), 9 deletions(-)
diff --git a/hw/i2c/smbus_eeprom.c b/hw/i2c/smbus_eeprom.c
index 54c86a0112..533c728b3b 100644
--- a/hw/i2c/smbus_eeprom.c
+++ b/hw/i2c/smbus_eeprom.c
@@ -44,7 +44,7 @@
typedef struct SMBusEEPROMDevice {
SMBusDevice smbusdev;
uint8_t data[SMBUS_EEPROM_SIZE];
- void *init_data;
+ uint8_t *init_data;
uint8_t offset;
bool accessed;
} SMBusEEPROMDevice;
@@ -129,14 +129,14 @@ static void smbus_eeprom_reset(DeviceState *dev)
static void smbus_eeprom_realize(DeviceState *dev, Error **errp)
{
+ SMBusEEPROMDevice *eeprom = SMBUS_EEPROM(dev);
+
smbus_eeprom_reset(dev);
+ if (eeprom->init_data == NULL) {
+ error_setg(errp, "init_data cannot be NULL");
+ }
}
-static Property smbus_eeprom_properties[] = {
- DEFINE_PROP_PTR("data", SMBusEEPROMDevice, init_data),
- DEFINE_PROP_END_OF_LIST(),
-};
-
static void smbus_eeprom_class_initfn(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
@@ -146,9 +146,8 @@ static void smbus_eeprom_class_initfn(ObjectClass *klass,
void *data)
dc->reset = smbus_eeprom_reset;
sc->receive_byte = eeprom_receive_byte;
sc->write_data = eeprom_write_data;
- dc->props = smbus_eeprom_properties;
dc->vmsd = &vmstate_smbus_eeprom;
- /* Reason: pointer property "data" */
+ /* Reason: init_data */
dc->user_creatable = false;
}
@@ -172,7 +171,7 @@ void smbus_eeprom_init_one(I2CBus *smbus, uint8_t address,
uint8_t *eeprom_buf)
dev = qdev_create((BusState *) smbus, TYPE_SMBUS_EEPROM);
qdev_prop_set_uint8(dev, "address", address);
- qdev_prop_set_ptr(dev, "data", eeprom_buf);
+ SMBUS_EEPROM(dev)->init_data = eeprom_buf;
qdev_init_nofail(dev);
}
--
2.23.0.606.g08da6496b6
- Re: [PATCH v3 23/33] dp8393x: replace PROP_PTR with PROP_LINK, (continued)
- [PATCH v3 19/33] sm501: make SerialMM a child, export chardev property, Marc-André Lureau, 2019/10/23
- [PATCH v3 22/33] etraxfs: remove PROP_PTR usage, Marc-André Lureau, 2019/10/23
- [PATCH v3 24/33] leon3: use qemu_irq framework instead of callback as property, Marc-André Lureau, 2019/10/23
- [PATCH v3 25/33] sparc: move PIL irq handling to cpu.c, Marc-André Lureau, 2019/10/23
- [PATCH v3 26/33] RFC: mips/cps: fix setting saar property, Marc-André Lureau, 2019/10/23
- [PATCH v3 27/33] cris: improve passing PIC interrupt vector to the CPU, Marc-André Lureau, 2019/10/23
- [PATCH v3 29/33] omap-intc: remove PROP_PTR, Marc-André Lureau, 2019/10/23
- [PATCH v3 28/33] smbus-eeprom: remove PROP_PTR,
Marc-André Lureau <=
- [PATCH v3 30/33] omap-i2c: remove PROP_PTR, Marc-André Lureau, 2019/10/23
- [PATCH v3 31/33] omap-gpio: remove PROP_PTR, Marc-André Lureau, 2019/10/23
- [PATCH v3 32/33] qdev: remove PROP_MEMORY_REGION, Marc-André Lureau, 2019/10/23
- [PATCH v3 33/33] qdev: remove QDEV_PROP_PTR, Marc-André Lureau, 2019/10/23