qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eduardo Habkost <ehabkost@redhat.com>
To: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
Cc: Markus Armbruster <armbru@redhat.com>,
	Peter Maydell <peter.maydell@linaro.org>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Eric Blake <eblake@redhat.com>,
	Marcel Apfelbaum <marcel@redhat.com>,
	qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 02/11] smbus_eeprom: replace SMBusDeviceClass::init by DeviceClass::reset
Date: Fri, 19 Jan 2018 16:15:48 -0200	[thread overview]
Message-ID: <20180119181548.GL15832@localhost.localdomain> (raw)
In-Reply-To: <20180116131555.14242-3-f4bug@amsat.org>

On Tue, Jan 16, 2018 at 10:15:46AM -0300, Philippe Mathieu-Daudé wrote:
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>  hw/i2c/smbus_eeprom.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/hw/i2c/smbus_eeprom.c b/hw/i2c/smbus_eeprom.c
> index b13ec0fe7a..7e81ae4fe5 100644
> --- a/hw/i2c/smbus_eeprom.c
> +++ b/hw/i2c/smbus_eeprom.c
> @@ -97,12 +97,11 @@ static uint8_t eeprom_read_data(SMBusDevice *dev, uint8_t cmd, int n)
>      return eeprom_receive_byte(dev);
>  }
>  
> -static int smbus_eeprom_initfn(SMBusDevice *dev)
> +static void smbus_eeprom_reset(DeviceState *dev)
>  {
>      SMBusEEPROMDevice *eeprom = (SMBusEEPROMDevice *)dev;
>  
>      eeprom->offset = 0;
> -    return 0;
>  }
>  
>  static Property smbus_eeprom_properties[] = {
> @@ -115,7 +114,7 @@ static void smbus_eeprom_class_initfn(ObjectClass *klass, void *data)
>      DeviceClass *dc = DEVICE_CLASS(klass);
>      SMBusDeviceClass *sc = SMBUS_DEVICE_CLASS(klass);
>  
> -    sc->init = smbus_eeprom_initfn;
> +    dc->reset = smbus_eeprom_reset;

Trying to track down when each of these methods is called:

sc->init (SMBusDeviceClass::init)
 -> called by i2c_slave_qdev_init() (DeviceClass:init)
   -> called by device_realize() (DeviceClass::realize)
     -> called by device_set_realized()
       -> QOM setter for "realized" property
         -> (multiple callers)

(eww, so many indirections)

dc->reset (DeviceClass::reset)
  -> called by device_reset()
    -> (multiple callers)

(much better!)


It looks like this changes how the device behaves.  Is this
fixing a device emulation bug?  If not, why should the device set
offset=0 on DeviceClass::reset, and not DeviceClass::realize?


>      sc->quick_cmd = eeprom_quick_cmd;
>      sc->send_byte = eeprom_send_byte;
>      sc->receive_byte = eeprom_receive_byte;
> -- 
> 2.15.1
> 
> 

-- 
Eduardo

  reply	other threads:[~2018-01-19 18:16 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-16 13:15 [Qemu-devel] [PATCH 00/11] qdev: remove DeviceClass::init/exit() Philippe Mathieu-Daudé
2018-01-16 13:15 ` [Qemu-devel] [PATCH 01/11] smbus: add a NULL check for SMBusDeviceClass::init callbacks Philippe Mathieu-Daudé
2018-01-19 17:58   ` Eduardo Habkost
2018-01-16 13:15 ` [Qemu-devel] [PATCH 02/11] smbus_eeprom: replace SMBusDeviceClass::init by DeviceClass::reset Philippe Mathieu-Daudé
2018-01-19 18:15   ` Eduardo Habkost [this message]
2018-01-19 21:41     ` Philippe Mathieu-Daudé
2018-01-16 13:15 ` [Qemu-devel] [PATCH 03/11] hw/i2c: convert I2CSlaveClass::init -> realize Philippe Mathieu-Daudé
2018-01-16 14:09   ` Philippe Mathieu-Daudé
2018-01-19 18:18   ` Eduardo Habkost
2018-01-19 18:53     ` Philippe Mathieu-Daudé
2018-01-16 13:15 ` [Qemu-devel] [PATCH 04/11] usb-ccid: convert CCIDCardClass::init " Philippe Mathieu-Daudé
2018-01-18 17:05   ` Philippe Mathieu-Daudé
2018-01-16 13:15 ` [Qemu-devel] [PATCH 05/11] virtio-ccw: convert VirtIOCCWDeviceClass::init " Philippe Mathieu-Daudé
2018-01-16 13:41   ` Farhan Ali
2018-01-16 14:07     ` Philippe Mathieu-Daudé
2018-01-16 16:11       ` Farhan Ali
2018-01-16 16:52   ` Cornelia Huck
2018-01-17 12:30     ` Philippe Mathieu-Daudé
2018-01-16 13:15 ` [Qemu-devel] [PATCH 06/11] sysbus: add realize() and unrealize() Philippe Mathieu-Daudé
2018-01-19 18:03   ` Eduardo Habkost
2018-01-19 19:03     ` Philippe Mathieu-Daudé
2018-01-16 13:15 ` [Qemu-devel] [PATCH 07/11] qdev: simplify the SysBusDeviceClass::init path Philippe Mathieu-Daudé
2018-01-19 18:24   ` Eduardo Habkost
2018-01-16 13:15 ` [Qemu-devel] [PATCH 08/11] qdev: remove DeviceClass::init Philippe Mathieu-Daudé
2018-01-16 13:15 ` [Qemu-devel] [PATCH 09/11] qdev: remove DeviceClass::exit Philippe Mathieu-Daudé
2018-01-16 13:15 ` [Qemu-devel] [PATCH 10/11] qdev: remove empty realize/unrealize stubs Philippe Mathieu-Daudé
2018-01-16 13:15 ` [Qemu-devel] [PATCH 11/11] qdev: rename typedef qdev_resetfn() -> DeviceReset() Philippe Mathieu-Daudé
2018-01-17  5:45 ` [Qemu-devel] [PATCH 00/11] qdev: remove DeviceClass::init/exit() no-reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180119181548.GL15832@localhost.localdomain \
    --to=ehabkost@redhat.com \
    --cc=armbru@redhat.com \
    --cc=eblake@redhat.com \
    --cc=f4bug@amsat.org \
    --cc=marcel@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).