[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v3 16/16] i2c:smbus_eeprom: Add a reset function
From: |
Philippe Mathieu-Daudé |
Subject: |
Re: [Qemu-devel] [PATCH v3 16/16] i2c:smbus_eeprom: Add a reset function to smbus_eeprom |
Date: |
Mon, 26 Nov 2018 21:42:41 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.0 |
Hi Corey,
On 26/11/18 21:04, address@hidden wrote:
> From: Corey Minyard <address@hidden>
>
> Reset the contents to init data and reset the offset on a machine
> reset.
>
> Signed-off-by: Corey Minyard <address@hidden>
> ---
> hw/i2c/smbus_eeprom.c | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/hw/i2c/smbus_eeprom.c b/hw/i2c/smbus_eeprom.c
> index a0dcadbd60..de3a492df4 100644
> --- a/hw/i2c/smbus_eeprom.c
> +++ b/hw/i2c/smbus_eeprom.c
> @@ -107,7 +107,7 @@ static const VMStateDescription vmstate_smbus_eeprom = {
> }
> };
>
> -static void smbus_eeprom_realize(DeviceState *dev, Error **errp)
> +static void smbus_eeprom_reset(DeviceState *dev)
> {
> SMBusEEPROMDevice *eeprom = SMBUS_EEPROM(dev);
>
'git diff -U4' also shows this line:
memcpy(eeprom->data, eeprom->init_data, SMBUS_EEPROM_SIZE);
I don't think this is correct.
One test I'd like to have is a machine booting, updating the EPROM then
rebooting calling hw reset() to use the new values (BIOS use this).
With this patch this won't work, you'll restore the EPROM content on
each machine reset.
I'd move the memcpy() call to the realize() function.
What do you think?
> eeprom->offset = 0;
This is correct, the offset reset belongs to the reset() function.
Regards,
Phil.
> }
>
> +static void smbus_eeprom_realize(DeviceState *dev, Error **errp)
> +{
> + smbus_eeprom_reset(dev);
> +}
> +
> static Property smbus_eeprom_properties[] = {
> DEFINE_PROP_PTR("data", SMBusEEPROMDevice, init_data),
> DEFINE_PROP_END_OF_LIST(),
> @@ -126,6 +131,7 @@ static void smbus_eeprom_class_initfn(ObjectClass *klass,
> void *data)
> SMBusDeviceClass *sc = SMBUS_DEVICE_CLASS(klass);
>
> dc->realize = smbus_eeprom_realize;
> + dc->reset = smbus_eeprom_reset;
> sc->receive_byte = eeprom_receive_byte;
> sc->write_data = eeprom_write_data;
> dc->props = smbus_eeprom_properties;
>
- Re: [Qemu-devel] [PATCH v3 02/16] i2c: have I2C receive operation return uint8_t, (continued)
- [Qemu-devel] [PATCH v3 11/16] i2c:smbus_slave: Add an SMBus vmstate structure, minyard, 2018/11/26
- [Qemu-devel] [PATCH v3 08/16] boards.h: Ignore migration for SMBus devices on older machines, minyard, 2018/11/26
- [Qemu-devel] [PATCH v3 07/16] i2c:pm_smbus: Fix pm_smbus handling of I2C block read, minyard, 2018/11/26
- [Qemu-devel] [PATCH v3 06/16] i2c: Add a length check to the SMBus write handling, minyard, 2018/11/26
- [Qemu-devel] [PATCH v3 15/16] hw/i2c/smbus_eeprom: Create at most SMBUS_EEPROM_MAX EEPROMs on a SMBus, minyard, 2018/11/26
- [Qemu-devel] [PATCH v3 16/16] i2c:smbus_eeprom: Add a reset function to smbus_eeprom, minyard, 2018/11/26
- Re: [Qemu-devel] [PATCH v3 16/16] i2c:smbus_eeprom: Add a reset function to smbus_eeprom,
Philippe Mathieu-Daudé <=
- Re: [Qemu-devel] [PATCH v3 16/16] i2c:smbus_eeprom: Add a reset function to smbus_eeprom, Corey Minyard, 2018/11/26
- Re: [Qemu-devel] [PATCH v3 16/16] i2c:smbus_eeprom: Add a reset function to smbus_eeprom, Philippe Mathieu-Daudé, 2018/11/26
- Re: [Qemu-devel] [PATCH v3 16/16] i2c:smbus_eeprom: Add a reset function to smbus_eeprom, Corey Minyard, 2018/11/26
- Re: [Qemu-devel] [PATCH v3 16/16] i2c:smbus_eeprom: Add a reset function to smbus_eeprom, Philippe Mathieu-Daudé, 2018/11/27
- Re: [Qemu-devel] [PATCH v3 16/16] i2c:smbus_eeprom: Add a reset function to smbus_eeprom, Corey Minyard, 2018/11/27
- Re: [Qemu-devel] [PATCH v3 16/16] i2c:smbus_eeprom: Add a reset function to smbus_eeprom, Philippe Mathieu-Daudé, 2018/11/27
[Qemu-devel] [PATCH v3 14/16] i2c:smbus_eeprom: Add vmstate handling to the smbus eeprom, minyard, 2018/11/26