aboutsummaryrefslogtreecommitdiff
path: root/hw/usb
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2020-06-10 07:32:16 +0200
committerMarkus Armbruster <armbru@redhat.com>2020-06-15 22:05:28 +0200
commit590ce74a08d5b4fb39ac165a4fb68bd07e6d2b6c (patch)
tree22d63bcd8ac233c82139e9dd4f5ddee83f962ac3 /hw/usb
parent32aaaebe5665a75f8be8d76ba3ecfcf87627858b (diff)
downloadqemu-590ce74a08d5b4fb39ac165a4fb68bd07e6d2b6c.zip
qemu-590ce74a08d5b4fb39ac165a4fb68bd07e6d2b6c.tar.gz
qemu-590ce74a08d5b4fb39ac165a4fb68bd07e6d2b6c.tar.bz2
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>
Diffstat (limited to 'hw/usb')
-rw-r--r--hw/usb/bus.c11
-rw-r--r--hw/usb/dev-serial.c4
2 files changed, 7 insertions, 8 deletions
diff --git a/hw/usb/bus.c b/hw/usb/bus.c
index 6b0d9f9..da85b8b 100644
--- a/hw/usb/bus.c
+++ b/hw/usb/bus.c
@@ -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);
diff --git a/hw/usb/dev-serial.c b/hw/usb/dev-serial.c
index d2c0368..7e50e3b 100644
--- a/hw/usb/dev-serial.c
+++ b/hw/usb/dev-serial.c
@@ -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;
}