aboutsummaryrefslogtreecommitdiff
path: root/hw/usb
diff options
context:
space:
mode:
authorGonglei <arei.gonglei@huawei.com>2014-09-19 14:48:34 +0800
committerGerd Hoffmann <kraxel@redhat.com>2014-09-23 12:51:07 +0200
commit38fff2c9f4f9173e8b985fcdf6c2bb8a56712993 (patch)
treede7bc05547fae3844f2da0453aaa376ed3077e30 /hw/usb
parent63cdca364c84f174271c7d6756091895dadd71f4 (diff)
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>
Diffstat (limited to 'hw/usb')
-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 eb1b115919..3784f4a174 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;