Message ID | 20171213204436.5379-6-f4bug@amsat.org |
---|---|
State | Superseded, archived |
Headers | show |
Series | QOM'ify SDBus, housekeeping | expand |
On Wed, Dec 13, 2017 at 12:44 PM, Philippe Mathieu-Daudé <f4bug@amsat.org> wrote: > The slave qdev is created connected to the parent SDBus. > > Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> > --- > include/hw/sd/sd.h | 2 ++ > hw/sd/core.c | 14 ++++++++++++++ > 2 files changed, 16 insertions(+) > > diff --git a/include/hw/sd/sd.h b/include/hw/sd/sd.h > index dc9d697c12..d402231724 100644 > --- a/include/hw/sd/sd.h > +++ b/include/hw/sd/sd.h > @@ -52,6 +52,8 @@ struct SDBus { > > /* Functions to be used by qdevified callers */ > SDBus *sdbus_create_bus(DeviceState *parent, const char *name); > +DeviceState *sdbus_create_slave(SDBus *bus, const char *name); > +DeviceState *sdbus_create_slave_no_init(SDBus *bus, const char *name); > int sdbus_do_command(SDBus *sd, SDRequest *req, uint8_t *response); > void sdbus_write_data(SDBus *sd, uint8_t value); > uint8_t sdbus_read_data(SDBus *sd); > diff --git a/hw/sd/core.c b/hw/sd/core.c > index 021a8d7258..fc9ccfedb2 100644 > --- a/hw/sd/core.c > +++ b/hw/sd/core.c > @@ -188,6 +188,20 @@ static void sd_bus_register_types(void) > > type_init(sd_bus_register_types) > > +DeviceState *sdbus_create_slave_no_init(SDBus *bus, const char *name) > +{ > + assert(bus); > + return qdev_create(BUS(bus), name); > +} > + > +DeviceState *sdbus_create_slave(SDBus *bus, const char *name) > +{ > + DeviceState *dev = sdbus_create_slave_no_init(bus, name); > + > + qdev_init_nofail(dev); > + return dev; > +} This looks un-QOM which I thought we are trying to get away from. Alistair > + > SDBus *sdbus_create_bus(DeviceState *parent, const char *name) > { > return SD_BUS(qbus_create(TYPE_SD_BUS, parent, name)); > -- > 2.15.1 > >
diff --git a/include/hw/sd/sd.h b/include/hw/sd/sd.h index dc9d697c12..d402231724 100644 --- a/include/hw/sd/sd.h +++ b/include/hw/sd/sd.h @@ -52,6 +52,8 @@ struct SDBus { /* Functions to be used by qdevified callers */ SDBus *sdbus_create_bus(DeviceState *parent, const char *name); +DeviceState *sdbus_create_slave(SDBus *bus, const char *name); +DeviceState *sdbus_create_slave_no_init(SDBus *bus, const char *name); int sdbus_do_command(SDBus *sd, SDRequest *req, uint8_t *response); void sdbus_write_data(SDBus *sd, uint8_t value); uint8_t sdbus_read_data(SDBus *sd); diff --git a/hw/sd/core.c b/hw/sd/core.c index 021a8d7258..fc9ccfedb2 100644 --- a/hw/sd/core.c +++ b/hw/sd/core.c @@ -188,6 +188,20 @@ static void sd_bus_register_types(void) type_init(sd_bus_register_types) +DeviceState *sdbus_create_slave_no_init(SDBus *bus, const char *name) +{ + assert(bus); + return qdev_create(BUS(bus), name); +} + +DeviceState *sdbus_create_slave(SDBus *bus, const char *name) +{ + DeviceState *dev = sdbus_create_slave_no_init(bus, name); + + qdev_init_nofail(dev); + return dev; +} + SDBus *sdbus_create_bus(DeviceState *parent, const char *name) { return SD_BUS(qbus_create(TYPE_SD_BUS, parent, name));
The slave qdev is created connected to the parent SDBus. Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> --- include/hw/sd/sd.h | 2 ++ hw/sd/core.c | 14 ++++++++++++++ 2 files changed, 16 insertions(+)