aboutsummaryrefslogtreecommitdiff
path: root/hw/usb/dev-serial.c
diff options
context:
space:
mode:
authorGonglei <arei.gonglei@huawei.com>2014-09-19 15:25:21 +0800
committerGerd Hoffmann <kraxel@redhat.com>2014-09-23 12:51:08 +0200
commit7334d6507a7578152bb7addcef84e4cf634814a4 (patch)
tree4b5684fc19a7bff2d977c48cb0a2ecc751142780 /hw/usb/dev-serial.c
parent594a53607e5bd4a2b7555a7a2908d2c406fea9aa (diff)
usb-serial: only check speed once at realize time
Whatever the chardev is open or not, we should assure the speed is matched each other. So, call usb_check_attach() check speed. And then pass &error_abort at all calls to usb_device_attach(). 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/dev-serial.c')
-rw-r--r--hw/usb/dev-serial.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/hw/usb/dev-serial.c b/hw/usb/dev-serial.c
index 3784f4a174..1cee450259 100644
--- a/hw/usb/dev-serial.c
+++ b/hw/usb/dev-serial.c
@@ -451,7 +451,6 @@ static void usb_serial_read(void *opaque, const uint8_t *buf, int size)
static void usb_serial_event(void *opaque, int event)
{
USBSerialState *s = opaque;
- Error *local_err = NULL;
switch (event) {
case CHR_EVENT_BREAK:
@@ -461,11 +460,7 @@ static void usb_serial_event(void *opaque, int event)
break;
case CHR_EVENT_OPENED:
if (!s->dev.attached) {
- usb_device_attach(&s->dev, &local_err);
- if (local_err) {
- qerror_report_err(local_err);
- error_free(local_err);
- }
+ usb_device_attach(&s->dev, &error_abort);
}
break;
case CHR_EVENT_CLOSED:
@@ -479,6 +474,7 @@ static void usb_serial_event(void *opaque, int event)
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);
@@ -489,12 +485,18 @@ static void usb_serial_realize(USBDevice *dev, Error **errp)
return;
}
+ usb_check_attach(dev, &local_err);
+ if (local_err) {
+ error_propagate(errp, local_err);
+ return;
+ }
+
qemu_chr_add_handlers(s->cs, usb_serial_can_read, usb_serial_read,
usb_serial_event, s);
usb_serial_handle_reset(dev);
if (s->cs->be_open && !dev->attached) {
- usb_device_attach(dev, errp);
+ usb_device_attach(dev, &error_abort);
}
}