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 /include | |
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 'include')
-rw-r--r-- | include/hw/usb.h | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/include/hw/usb.h b/include/hw/usb.h index 6b32a3bb70..612f09f8c1 100644 --- a/include/hw/usb.h +++ b/include/hw/usb.h @@ -267,11 +267,17 @@ struct USBDevice { #define USB_DEVICE_GET_CLASS(obj) \ OBJECT_GET_CLASS(USBDeviceClass, (obj), TYPE_USB_DEVICE) +typedef void (*USBDeviceRealize)(USBDevice *dev, Error **errp); +typedef void (*USBDeviceUnrealize)(USBDevice *dev, Error **errp); + typedef struct USBDeviceClass { DeviceClass parent_class; int (*init)(USBDevice *dev); + USBDeviceRealize realize; + USBDeviceUnrealize unrealize; + /* * Walk (enabled) downstream ports, check for a matching device. * Only hubs implement this. @@ -544,9 +550,9 @@ int usb_register_companion(const char *masterbus, USBPort *ports[], void *opaque, USBPortOps *ops, int speedmask); void usb_port_location(USBPort *downstream, USBPort *upstream, int portnr); void usb_unregister_port(USBBus *bus, USBPort *port); -int usb_claim_port(USBDevice *dev); +void usb_claim_port(USBDevice *dev, Error **errp); void usb_release_port(USBDevice *dev); -int usb_device_attach(USBDevice *dev); +void usb_device_attach(USBDevice *dev, Error **errp); int usb_device_detach(USBDevice *dev); int usb_device_delete_addr(int busnr, int addr); |