All new accounts created on Gitlab now require administrator approval. If you invite any collaborators, please let Flux staff know so they can approve the accounts.

Commit 38fff2c9 authored by Gonglei's avatar Gonglei Committed by Gerd Hoffmann

dev-serial: convert init to realize

In this way, all the implementations now use
error_setg instead of error_report for reporting error.
Signed-off-by: default avatarGonglei <arei.gonglei@huawei.com>
Reviewed-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
Signed-off-by: default avatarGerd Hoffmann <kraxel@redhat.com>
parent 63cdca36
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment