diff options
author | Gonglei <arei.gonglei@huawei.com> | 2014-09-19 14:48:24 +0800 |
---|---|---|
committer | Gerd Hoffmann <kraxel@redhat.com> | 2014-09-23 12:51:06 +0200 |
commit | 7d553f27fce284805d7f94603932045ee3bbb979 (patch) | |
tree | b1b83b4c53a460660bcaedb45647c28e05397dca /hw/usb/dev-serial.c | |
parent | dc1f5988454d9dac8b9ba0c35266c8b4bc33ffa1 (diff) |
usb-bus: convert USBDeviceClass init to realize
Add "realize/unrealize" in USBDeviceClass, which has errp
as a parameter. So all the implementations now use
error_setg instead of error_report for reporting error.
Note: this patch still keep "init" in USBDeviceClass, and
call kclass->init in usb_device_realize(), avoid breaking
git bisect. After realize all usb devices, will be removed.
Signed-off-by: Gonglei <arei.gonglei@huawei.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Diffstat (limited to 'hw/usb/dev-serial.c')
-rw-r--r-- | hw/usb/dev-serial.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/hw/usb/dev-serial.c b/hw/usb/dev-serial.c index d3606142c9..eb1b115919 100644 --- a/hw/usb/dev-serial.c +++ b/hw/usb/dev-serial.c @@ -9,7 +9,7 @@ */ #include "qemu-common.h" -#include "qemu/error-report.h" +#include "monitor/monitor.h" #include "hw/usb.h" #include "hw/usb/desc.h" #include "sysemu/char.h" @@ -451,6 +451,7 @@ 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: @@ -460,7 +461,11 @@ static void usb_serial_event(void *opaque, int event) break; case CHR_EVENT_OPENED: if (!s->dev.attached) { - usb_device_attach(&s->dev); + usb_device_attach(&s->dev, &local_err); + if (local_err) { + qerror_report_err(local_err); + error_free(local_err); + } } break; case CHR_EVENT_CLOSED: @@ -474,6 +479,7 @@ static void usb_serial_event(void *opaque, int event) static int usb_serial_initfn(USBDevice *dev) { USBSerialState *s = DO_UPCAST(USBSerialState, dev, dev); + Error *local_err = NULL; usb_desc_create_serial(dev); usb_desc_init(dev); @@ -489,7 +495,11 @@ static int usb_serial_initfn(USBDevice *dev) usb_serial_handle_reset(dev); if (s->cs->be_open && !dev->attached) { - usb_device_attach(dev); + usb_device_attach(dev, &local_err); + if (local_err) { + qerror_report_err(local_err); + error_free(local_err); + } } return 0; } |