usb: Convert uses of usb_create()
Replace dev = usb_create(bus, type_name); ... object_property_set_bool(OBJECT(dev), true, "realized", &err); by dev = isa_new(type_name); ... usb_realize_and_unref(dev, bus, &err); Recent commit "qdev: New qdev_new(), qdev_realize(), etc." explains why. Cc: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Message-Id: <20200610053247.1583243-28-armbru@redhat.com>
This commit is contained in:
parent
32aaaebe56
commit
590ce74a08
11
hw/usb/bus.c
11
hw/usb/bus.c
|
@ -296,14 +296,13 @@ typedef struct LegacyUSBFactory
|
||||||
{
|
{
|
||||||
const char *name;
|
const char *name;
|
||||||
const char *usbdevice_name;
|
const char *usbdevice_name;
|
||||||
USBDevice *(*usbdevice_init)(USBBus *bus, const char *params);
|
USBDevice *(*usbdevice_init)(const char *params);
|
||||||
} LegacyUSBFactory;
|
} LegacyUSBFactory;
|
||||||
|
|
||||||
static GSList *legacy_usb_factory;
|
static GSList *legacy_usb_factory;
|
||||||
|
|
||||||
void usb_legacy_register(const char *typename, const char *usbdevice_name,
|
void usb_legacy_register(const char *typename, const char *usbdevice_name,
|
||||||
USBDevice *(*usbdevice_init)(USBBus *bus,
|
USBDevice *(*usbdevice_init)(const char *params))
|
||||||
const char *params))
|
|
||||||
{
|
{
|
||||||
if (usbdevice_name) {
|
if (usbdevice_name) {
|
||||||
LegacyUSBFactory *f = g_malloc0(sizeof(*f));
|
LegacyUSBFactory *f = g_malloc0(sizeof(*f));
|
||||||
|
@ -710,19 +709,19 @@ USBDevice *usbdevice_create(const char *cmdline)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (f->usbdevice_init) {
|
if (f->usbdevice_init) {
|
||||||
dev = f->usbdevice_init(bus, params);
|
dev = f->usbdevice_init(params);
|
||||||
} else {
|
} else {
|
||||||
if (*params) {
|
if (*params) {
|
||||||
error_report("usbdevice %s accepts no params", driver);
|
error_report("usbdevice %s accepts no params", driver);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
dev = usb_create(bus, f->name);
|
dev = usb_new(f->name);
|
||||||
}
|
}
|
||||||
if (!dev) {
|
if (!dev) {
|
||||||
error_report("Failed to create USB device '%s'", f->name);
|
error_report("Failed to create USB device '%s'", f->name);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
object_property_set_bool(OBJECT(dev), true, "realized", &err);
|
usb_realize_and_unref(dev, bus, &err);
|
||||||
if (err) {
|
if (err) {
|
||||||
error_reportf_err(err, "Failed to initialize USB device '%s': ",
|
error_reportf_err(err, "Failed to initialize USB device '%s': ",
|
||||||
f->name);
|
f->name);
|
||||||
|
|
|
@ -542,7 +542,7 @@ static void usb_serial_realize(USBDevice *dev, Error **errp)
|
||||||
s->intr = usb_ep_get(dev, USB_TOKEN_IN, 1);
|
s->intr = usb_ep_get(dev, USB_TOKEN_IN, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static USBDevice *usb_braille_init(USBBus *bus, const char *unused)
|
static USBDevice *usb_braille_init(const char *unused)
|
||||||
{
|
{
|
||||||
USBDevice *dev;
|
USBDevice *dev;
|
||||||
Chardev *cdrv;
|
Chardev *cdrv;
|
||||||
|
@ -551,7 +551,7 @@ static USBDevice *usb_braille_init(USBBus *bus, const char *unused)
|
||||||
if (!cdrv)
|
if (!cdrv)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
dev = usb_create(bus, "usb-braille");
|
dev = usb_new("usb-braille");
|
||||||
qdev_prop_set_chr(&dev->qdev, "chardev", cdrv);
|
qdev_prop_set_chr(&dev->qdev, "chardev", cdrv);
|
||||||
return dev;
|
return dev;
|
||||||
}
|
}
|
||||||
|
|
|
@ -502,8 +502,7 @@ void usb_bus_new(USBBus *bus, size_t bus_size,
|
||||||
void usb_bus_release(USBBus *bus);
|
void usb_bus_release(USBBus *bus);
|
||||||
USBBus *usb_bus_find(int busnr);
|
USBBus *usb_bus_find(int busnr);
|
||||||
void usb_legacy_register(const char *typename, const char *usbdevice_name,
|
void usb_legacy_register(const char *typename, const char *usbdevice_name,
|
||||||
USBDevice *(*usbdevice_init)(USBBus *bus,
|
USBDevice *(*usbdevice_init)(const char *params));
|
||||||
const char *params));
|
|
||||||
USBDevice *usb_new(const char *name);
|
USBDevice *usb_new(const char *name);
|
||||||
bool usb_realize_and_unref(USBDevice *dev, USBBus *bus, Error **errp);
|
bool usb_realize_and_unref(USBDevice *dev, USBBus *bus, Error **errp);
|
||||||
USBDevice *usb_create(USBBus *bus, const char *name);
|
USBDevice *usb_create(USBBus *bus, const char *name);
|
||||||
|
|
Loading…
Reference in a new issue