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: Gonglei <arei.gonglei@huawei.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
This commit is contained in:
parent
63cdca364c
commit
38fff2c9f4
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user