@@ -502,8 +502,7 @@ void usb_bus_new(USBBus *bus, size_t bus_size,
void usb_bus_release(USBBus *bus);
USBBus *usb_bus_find(int busnr);
void usb_legacy_register(const char *typename, const char *usbdevice_name,
- USBDevice *(*usbdevice_init)(USBBus *bus,
- const char *params));
+ USBDevice *(*usbdevice_init)(const char *params));
USBDevice *usb_new(const char *name);
bool usb_realize_and_unref(USBDevice *dev, USBBus *bus, Error **errp);
USBDevice *usb_create(USBBus *bus, const char *name);
@@ -296,14 +296,13 @@ typedef struct LegacyUSBFactory
{
const char *name;
const char *usbdevice_name;
- USBDevice *(*usbdevice_init)(USBBus *bus, const char *params);
+ USBDevice *(*usbdevice_init)(const char *params);
} LegacyUSBFactory;
static GSList *legacy_usb_factory;
void usb_legacy_register(const char *typename, const char *usbdevice_name,
- USBDevice *(*usbdevice_init)(USBBus *bus,
- const char *params))
+ USBDevice *(*usbdevice_init)(const char *params))
{
if (usbdevice_name) {
LegacyUSBFactory *f = g_malloc0(sizeof(*f));
@@ -710,19 +709,19 @@ USBDevice *usbdevice_create(const char *cmdline)
}
if (f->usbdevice_init) {
- dev = f->usbdevice_init(bus, params);
+ dev = f->usbdevice_init(params);
} else {
if (*params) {
error_report("usbdevice %s accepts no params", driver);
return NULL;
}
- dev = usb_create(bus, f->name);
+ dev = usb_new(f->name);
}
if (!dev) {
error_report("Failed to create USB device '%s'", f->name);
return NULL;
}
- object_property_set_bool(OBJECT(dev), true, "realized", &err);
+ usb_realize_and_unref(dev, bus, &err);
if (err) {
error_reportf_err(err, "Failed to initialize USB device '%s': ",
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);
}
-static USBDevice *usb_braille_init(USBBus *bus, const char *unused)
+static USBDevice *usb_braille_init(const char *unused)
{
USBDevice *dev;
Chardev *cdrv;
@@ -551,7 +551,7 @@ static USBDevice *usb_braille_init(USBBus *bus, const char *unused)
if (!cdrv)
return NULL;
- dev = usb_create(bus, "usb-braille");
+ dev = usb_new("usb-braille");
qdev_prop_set_chr(&dev->qdev, "chardev", cdrv);
return dev;
}