aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--hw/usb/dev-serial.c18
1 files changed, 6 insertions, 12 deletions
diff --git a/hw/usb/dev-serial.c b/hw/usb/dev-serial.c
index eb1b115..3784f4a 100644
--- a/hw/usb/dev-serial.c
+++ b/hw/usb/dev-serial.c
@@ -476,18 +476,17 @@ static void usb_serial_event(void *opaque, int event)
}
}
-static int usb_serial_initfn(USBDevice *dev)
+static void usb_serial_realize(USBDevice *dev, Error **errp)
{
USBSerialState *s = DO_UPCAST(USBSerialState, dev, dev);
- Error *local_err = NULL;
usb_desc_create_serial(dev);
usb_desc_init(dev);
dev->auto_attach = 0;
if (!s->cs) {
- error_report("Property chardev is required");
- return -1;
+ error_setg(errp, "Property chardev is required");
+ return;
}
qemu_chr_add_handlers(s->cs, usb_serial_can_read, usb_serial_read,
@@ -495,13 +494,8 @@ static int usb_serial_initfn(USBDevice *dev)
usb_serial_handle_reset(dev);
if (s->cs->be_open && !dev->attached) {
- usb_device_attach(dev, &local_err);
- if (local_err) {
- qerror_report_err(local_err);
- error_free(local_err);
- }
+ usb_device_attach(dev, errp);
}
- return 0;
}
static USBDevice *usb_serial_init(USBBus *bus, const char *filename)
@@ -592,7 +586,7 @@ static void usb_serial_class_initfn(ObjectClass *klass, void *data)
DeviceClass *dc = DEVICE_CLASS(klass);
USBDeviceClass *uc = USB_DEVICE_CLASS(klass);
- uc->init = usb_serial_initfn;
+ uc->realize = usb_serial_realize;
uc->product_desc = "QEMU USB Serial";
uc->usb_desc = &desc_serial;
uc->handle_reset = usb_serial_handle_reset;
@@ -620,7 +614,7 @@ static void usb_braille_class_initfn(ObjectClass *klass, void *data)
DeviceClass *dc = DEVICE_CLASS(klass);
USBDeviceClass *uc = USB_DEVICE_CLASS(klass);
- uc->init = usb_serial_initfn;
+ uc->realize = usb_serial_realize;
uc->product_desc = "QEMU USB Braille";
uc->usb_desc = &desc_braille;
uc->handle_reset = usb_serial_handle_reset;