aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--hw/usb/bus.c22
-rw-r--r--hw/usb/dev-bluetooth.c5
-rw-r--r--hw/usb/dev-network.c1
-rw-r--r--hw/usb/dev-serial.c4
-rw-r--r--hw/usb/dev-storage.c3
-rw-r--r--hw/usb/host-legacy.c1
6 files changed, 19 insertions, 17 deletions
diff --git a/hw/usb/bus.c b/hw/usb/bus.c
index eeb6872324..3f69fe1b23 100644
--- a/hw/usb/bus.c
+++ b/hw/usb/bus.c
@@ -651,10 +651,12 @@ USBDevice *usbdevice_create(const char *cmdline)
{
USBBus *bus = usb_bus_find(-1 /* any */);
LegacyUSBFactory *f = NULL;
+ Error *err = NULL;
GSList *i;
char driver[32];
const char *params;
int len;
+ USBDevice *dev;
params = strchr(cmdline,':');
if (params) {
@@ -689,14 +691,28 @@ USBDevice *usbdevice_create(const char *cmdline)
return NULL;
}
- if (!f->usbdevice_init) {
+ if (f->usbdevice_init) {
+ dev = f->usbdevice_init(bus, params);
+ } else {
if (*params) {
error_report("usbdevice %s accepts no params", driver);
return NULL;
}
- return usb_create_simple(bus, f->name);
+ dev = usb_create(bus, f->name);
+ }
+ if (!dev) {
+ error_report("Failed to create USB device '%s'", f->name);
+ return NULL;
}
- return f->usbdevice_init(bus, params);
+ object_property_set_bool(OBJECT(dev), true, "realized", &err);
+ if (err) {
+ error_report("Failed to initialize USB device '%s': %s",
+ f->name, error_get_pretty(err));
+ error_free(err);
+ object_unparent(OBJECT(dev));
+ return NULL;
+ }
+ return dev;
}
static void usb_device_class_init(ObjectClass *klass, void *data)
diff --git a/hw/usb/dev-bluetooth.c b/hw/usb/dev-bluetooth.c
index 8b3b31694b..9bf673057a 100644
--- a/hw/usb/dev-bluetooth.c
+++ b/hw/usb/dev-bluetooth.c
@@ -536,11 +536,6 @@ static USBDevice *usb_bt_init(USBBus *bus, const char *cmdline)
dev = usb_create(bus, name);
s = DO_UPCAST(struct USBBtState, dev, dev);
s->hci = hci;
- if (qdev_init(&dev->qdev) < 0) {
- error_report("Failed to initialize USB device '%s'", name);
- return NULL;
- }
-
return dev;
}
diff --git a/hw/usb/dev-network.c b/hw/usb/dev-network.c
index 620fc116cf..7131abdb21 100644
--- a/hw/usb/dev-network.c
+++ b/hw/usb/dev-network.c
@@ -1406,7 +1406,6 @@ static USBDevice *usb_net_init(USBBus *bus, const char *cmdline)
dev = usb_create(bus, "usb-net");
qdev_set_nic_properties(&dev->qdev, &nd_table[idx]);
- qdev_init_nofail(&dev->qdev);
return dev;
}
diff --git a/hw/usb/dev-serial.c b/hw/usb/dev-serial.c
index f347c05b54..67c2072ce7 100644
--- a/hw/usb/dev-serial.c
+++ b/hw/usb/dev-serial.c
@@ -549,8 +549,6 @@ static USBDevice *usb_serial_init(USBBus *bus, const char *filename)
qdev_prop_set_uint16(&dev->qdev, "vendorid", vendorid);
if (productid)
qdev_prop_set_uint16(&dev->qdev, "productid", productid);
- qdev_init_nofail(&dev->qdev);
-
return dev;
}
@@ -565,8 +563,6 @@ static USBDevice *usb_braille_init(USBBus *bus, const char *unused)
dev = usb_create(bus, "usb-braille");
qdev_prop_set_chr(&dev->qdev, "chardev", cdrv);
- qdev_init_nofail(&dev->qdev);
-
return dev;
}
diff --git a/hw/usb/dev-storage.c b/hw/usb/dev-storage.c
index 5f222754ba..af2e1b915d 100644
--- a/hw/usb/dev-storage.c
+++ b/hw/usb/dev-storage.c
@@ -711,9 +711,6 @@ static USBDevice *usb_msd_init(USBBus *bus, const char *filename)
object_unparent(OBJECT(dev));
return NULL;
}
- if (qdev_init(&dev->qdev) < 0)
- return NULL;
-
return dev;
}
diff --git a/hw/usb/host-legacy.c b/hw/usb/host-legacy.c
index 3cc9c4282c..422ed9a65f 100644
--- a/hw/usb/host-legacy.c
+++ b/hw/usb/host-legacy.c
@@ -128,7 +128,6 @@ USBDevice *usb_host_device_open(USBBus *bus, const char *devname)
qdev_prop_set_uint32(&dev->qdev, "hostaddr", filter.addr);
qdev_prop_set_uint32(&dev->qdev, "vendorid", filter.vendor_id);
qdev_prop_set_uint32(&dev->qdev, "productid", filter.product_id);
- qdev_init_nofail(&dev->qdev);
return dev;
fail: