From: Corey Minyard <cminyard@mvista.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: "Magnus Damm" <magnus.damm@gmail.com>,
"Daniel P. Berrangé" <berrange@redhat.com>,
"Eduardo Habkost" <ehabkost@redhat.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
"Mark Cave-Ayland" <mark.cave-ayland@ilande.co.uk>,
"Jason Wang" <jasowang@redhat.com>,
"Hervé Poussineau" <hpoussin@reactos.org>,
"Edgar E. Iglesias" <edgar.iglesias@gmail.com>,
"QEMU Developers" <qemu-devel@nongnu.org>,
"Fabien Chouteau" <chouteau@adacore.com>,
"Aleksandar Markovic" <amarkovic@wavecomp.com>,
"KONRAD Frederic" <frederic.konrad@adacore.com>,
qemu-arm <qemu-arm@nongnu.org>, qemu-ppc <qemu-ppc@nongnu.org>,
"Aurelien Jarno" <aurelien@aurel32.net>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Marc-André Lureau" <marcandre.lureau@redhat.com>,
"Artyom Tarasenko" <atar4qemu@gmail.com>,
"Richard Henderson" <rth@twiddle.net>
Subject: Re: [PATCH 09/14] smbus-eeprom: remove PROP_PTR
Date: Mon, 21 Oct 2019 09:52:31 -0500 [thread overview]
Message-ID: <20191021145231.GI25427@t560> (raw)
In-Reply-To: <CAFEAcA-4A=SyrxsMwN0_HzSi89JAYZz8KzuDWh8O47X_WF0NtQ@mail.gmail.com>
On Fri, Oct 18, 2019 at 06:20:40PM +0100, Peter Maydell wrote:
> On Fri, 18 Oct 2019 at 16:43, Marc-André Lureau
> <marcandre.lureau@redhat.com> wrote:
> >
> > Instead, set the initial data field directly. Since it is only 256
> > bytes, let's simply copy it to avoid invalid pointers issues.
>
> (Commit message says you copy the 256 bytes, but the code
> doesn't seem to do any copying?)
>
> > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
>
> Ah, the smbus code. Corey had a go at cleaning this up
> a while back; I can't remember if we found a reason why
> we had to keep the weird use of a pointer property here, or
> if we just wanted to avoid dragging yet another thing into
> an already large patchset.
>
> What we're actually trying to set up here is always 256
> bytes of data. What's the right way to pass a QOM device
> a small chunk of data like that?
Yeah, we discussed this at the time, and IIRC we decided to leave it
like it is until someone came up with a use case. My guess is that
the intent was to be able to pass in a buffer from the command line
or something like that, but that was never completed.
I'm ok with this change, the code is strange as it is, and I don't see
any uses of this propery in a quick scan of the code.
-corey
>
> > ---
> > 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
>
> thanks
> -- PMM
next prev parent reply other threads:[~2019-10-21 14:55 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-18 15:41 [PATCH 00/14] Clean-ups: remove QDEV_PROP_PTR Marc-André Lureau
2019-10-18 15:41 ` [PATCH 01/14] sm501: replace PROP_PTR with PROP_LINK Marc-André Lureau
2019-10-18 16:22 ` Peter Maydell
2019-10-18 16:36 ` Marc-André Lureau
2019-10-18 16:50 ` Peter Maydell
2019-10-18 15:42 ` [PATCH 02/14] vmmouse: " Marc-André Lureau
2019-10-21 10:10 ` Peter Maydell
2019-10-18 15:42 ` [PATCH 03/14] lance: " Marc-André Lureau
2019-10-21 10:05 ` Peter Maydell
2019-10-18 15:42 ` [PATCH 04/14] etraxfs: remove PROP_PTR usage Marc-André Lureau
2019-10-18 15:59 ` Peter Maydell
2019-10-18 16:11 ` Marc-André Lureau
2019-10-18 16:34 ` Peter Maydell
2019-10-21 10:41 ` Peter Maydell
2019-10-18 15:42 ` [PATCH 05/14] dp8393x: replace PROP_PTR with PROP_LINK Marc-André Lureau
2019-10-18 17:49 ` Peter Maydell
2019-10-18 18:14 ` Aleksandar Markovic
2019-10-18 15:42 ` [PATCH 06/14] leon3: " Marc-André Lureau
2019-10-18 17:45 ` Peter Maydell
2019-10-18 15:42 ` [PATCH 07/14] RFC: mips/cps: fix setting saar property Marc-André Lureau
2019-10-18 17:04 ` Philippe Mathieu-Daudé
2019-10-18 17:42 ` Aleksandar Markovic
2019-10-18 15:42 ` [PATCH 08/14] cris: replace PROP_PTR with PROP_LINK for interrupt vector Marc-André Lureau
2019-10-18 17:37 ` Peter Maydell
2019-10-18 15:42 ` [PATCH 09/14] smbus-eeprom: remove PROP_PTR Marc-André Lureau
2019-10-18 17:20 ` Peter Maydell
2019-10-21 14:52 ` Corey Minyard [this message]
2019-10-21 21:28 ` Marc-André Lureau
2019-10-18 15:42 ` [PATCH 10/14] omap-intc: " Marc-André Lureau
2019-10-18 16:55 ` Peter Maydell
2019-10-18 15:42 ` [PATCH 11/14] omap-i2c: " Marc-André Lureau
2019-10-18 16:56 ` Peter Maydell
2019-10-21 15:03 ` Corey Minyard
2019-10-18 15:42 ` [PATCH 12/14] omap-gpio: " Marc-André Lureau
2019-10-18 16:58 ` Peter Maydell
2019-10-18 15:42 ` [PATCH 13/14] qdev: remove PROP_MEMORY_REGION Marc-André Lureau
2019-10-18 16:58 ` Peter Maydell
2019-10-18 15:42 ` [PATCH 14/14] Remove QDEV_PROP_PTR Marc-André Lureau
2019-10-18 16:59 ` Peter Maydell
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=20191021145231.GI25427@t560 \
--to=cminyard@mvista.com \
--cc=amarkovic@wavecomp.com \
--cc=atar4qemu@gmail.com \
--cc=aurelien@aurel32.net \
--cc=berrange@redhat.com \
--cc=chouteau@adacore.com \
--cc=edgar.iglesias@gmail.com \
--cc=ehabkost@redhat.com \
--cc=frederic.konrad@adacore.com \
--cc=hpoussin@reactos.org \
--cc=jasowang@redhat.com \
--cc=magnus.damm@gmail.com \
--cc=marcandre.lureau@redhat.com \
--cc=mark.cave-ayland@ilande.co.uk \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=rth@twiddle.net \
/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).