From: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: "Corey Minyard" <cminyard@mvista.com>,
"Andrew Jeffery" <andrew@aj.id.au>,
"QEMU Developers" <qemu-devel@nongnu.org>,
"Markus Armbruster" <armbru@redhat.com>,
qemu-arm <qemu-arm@nongnu.org>, "Joel Stanley" <joel@jms.id.au>,
"Cédric Le Goater" <clg@kaod.org>
Subject: Re: [PATCH v6 1/9] hw/i2c/core: Add i2c_try_create_slave() and i2c_realize_and_unref()
Date: Fri, 26 Jun 2020 23:28:09 +0200 [thread overview]
Message-ID: <CAAdtpL4zXbwZuTPVQUbXyDftMCpw+Yx_cZXU3yZvB+EUXZBrhg@mail.gmail.com> (raw)
In-Reply-To: <CAFEAcA9-Vjh-hkB9i9fvp9yEHuKW7cGeEDQ-kKmiiao2WogQDQ@mail.gmail.com>
On Fri, Jun 26, 2020 at 8:27 PM Peter Maydell <peter.maydell@linaro.org> wrote:
> On Tue, 23 Jun 2020 at 08:27, Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
> > Extract i2c_try_create_slave() and i2c_realize_and_unref()
> > from i2c_create_slave().
> > We can now set properties on a I2CSlave before it is realized.
> >
> > This is in line with the recent qdev/QOM changes merged
> > in commit 6675a653d2e.
> >
> > Reviewed-by: Corey Minyard <cminyard@mvista.com>
> > Reviewed-by: Cédric Le Goater <clg@kaod.org>
> > Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
>
> Couple of things I belatedly noticed on this patch, which I don't
> think are important enough for me to drop it from my pullreq,
> but which I think it would be nice to address in a followup:
>
> > diff --git a/include/hw/i2c/i2c.h b/include/hw/i2c/i2c.h
> > index 4117211565..d6e3d85faf 100644
> > --- a/include/hw/i2c/i2c.h
> > +++ b/include/hw/i2c/i2c.h
> > @@ -80,6 +80,8 @@ int i2c_send(I2CBus *bus, uint8_t data);
> > uint8_t i2c_recv(I2CBus *bus);
> >
> > DeviceState *i2c_create_slave(I2CBus *bus, const char *name, uint8_t addr);
> > +DeviceState *i2c_try_create_slave(const char *name, uint8_t addr);
> > +bool i2c_realize_and_unref(DeviceState *dev, I2CBus *bus, Error **errp);
>
> Can we have doc-comments for new global-scope functions, please ?
Sure.
>
> > --- a/hw/i2c/core.c
> > +++ b/hw/i2c/core.c
> > @@ -267,13 +267,27 @@ const VMStateDescription vmstate_i2c_slave = {
> > }
> > };
> >
> > -DeviceState *i2c_create_slave(I2CBus *bus, const char *name, uint8_t addr)
> > +DeviceState *i2c_try_create_slave(const char *name, uint8_t addr)
> > {
> > DeviceState *dev;
> >
> > dev = qdev_new(name);
> > qdev_prop_set_uint8(dev, "address", addr);
> > - qdev_realize_and_unref(dev, &bus->qbus, &error_fatal);
> > + return dev;
> > +}
> > +
> > +bool i2c_realize_and_unref(DeviceState *dev, I2CBus *bus, Error **errp)
> > +{
> > + return qdev_realize_and_unref(dev, &bus->qbus, errp);
> > +}
> > +
> > +DeviceState *i2c_create_slave(I2CBus *bus, const char *name, uint8_t addr)
> > +{
> > + DeviceState *dev;
> > +
> > + dev = i2c_try_create_slave(name, addr);
> > + i2c_realize_and_unref(dev, bus, &error_fatal);
> > +
>
> We now have a _try_ function which isn't "same behaviour as
> the non-try function, but give me back an error status rather
> than just killing QEMU". That seems confusing -- is there a
> better name we can use ?
Yes, Markus asked me to change that, but as it could be done on top,
he didn't block the series.
I'll address that next week.
> thanks
> -- PMM
next prev parent reply other threads:[~2020-06-26 21:29 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-23 7:27 [PATCH v6 0/9] hw/misc/pca9552: Trace GPIO change events Philippe Mathieu-Daudé
2020-06-23 7:27 ` [PATCH v6 1/9] hw/i2c/core: Add i2c_try_create_slave() and i2c_realize_and_unref() Philippe Mathieu-Daudé
2020-06-23 11:07 ` Philippe Mathieu-Daudé
2020-06-26 18:23 ` Peter Maydell
2020-06-26 21:28 ` Philippe Mathieu-Daudé [this message]
2020-06-23 7:27 ` [PATCH v6 2/9] hw/misc/pca9552: Rename 'nr_leds' as 'pin_count' Philippe Mathieu-Daudé
2020-06-23 7:27 ` [PATCH v6 3/9] hw/misc/pca9552: Rename generic code as pca955x Philippe Mathieu-Daudé
2020-06-23 7:27 ` [PATCH v6 4/9] hw/misc/pca9552: Add generic PCA955xClass, parent of TYPE_PCA9552 Philippe Mathieu-Daudé
2020-06-23 7:27 ` [PATCH v6 5/9] hw/misc/pca9552: Add a 'description' property for debugging purpose Philippe Mathieu-Daudé
2020-06-23 7:27 ` [PATCH v6 6/9] hw/misc/pca9552: Trace GPIO High/Low events Philippe Mathieu-Daudé
2020-06-23 7:27 ` [PATCH v6 7/9] hw/arm/aspeed: Describe each PCA9552 device Philippe Mathieu-Daudé
2020-06-23 11:08 ` Philippe Mathieu-Daudé
2020-06-23 16:30 ` Corey Minyard
2020-06-23 7:27 ` [PATCH v6 8/9] hw/misc/pca9552: Trace GPIO change events Philippe Mathieu-Daudé
2020-06-23 7:27 ` [PATCH v6 9/9] hw/misc/pca9552: Model qdev output GPIOs Philippe Mathieu-Daudé
2020-06-23 8:14 ` [PATCH v6 0/9] hw/misc/pca9552: Trace GPIO change events Cédric Le Goater
2020-06-23 11:09 ` Philippe Mathieu-Daudé
2020-06-25 15:53 ` 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=CAAdtpL4zXbwZuTPVQUbXyDftMCpw+Yx_cZXU3yZvB+EUXZBrhg@mail.gmail.com \
--to=f4bug@amsat.org \
--cc=andrew@aj.id.au \
--cc=armbru@redhat.com \
--cc=clg@kaod.org \
--cc=cminyard@mvista.com \
--cc=joel@jms.id.au \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.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).