From 594a53607e5bd4a2b7555a7a2908d2c406fea9aa Mon Sep 17 00:00:00 2001 From: Gonglei Date: Fri, 19 Sep 2014 15:25:20 +0800 Subject: usb-bus: introduce a wrapper function to check speed In this way, we can check speed directly, don't need call usb_device_attach(), which has other conditions, such as checking the chardev is open. Signed-off-by: Gonglei Reviewed-by: Paolo Bonzini Signed-off-by: Gerd Hoffmann --- hw/usb/bus.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'hw/usb/bus.c') diff --git a/hw/usb/bus.c b/hw/usb/bus.c index b375293529..da1eba9fbd 100644 --- a/hw/usb/bus.c +++ b/hw/usb/bus.c @@ -478,7 +478,7 @@ static void usb_mask_to_str(char *dest, size_t size, } } -void usb_device_attach(USBDevice *dev, Error **errp) +void usb_check_attach(USBDevice *dev, Error **errp) { USBBus *bus = usb_bus_from_device(dev); USBPort *port = dev->port; @@ -499,6 +499,18 @@ void usb_device_attach(USBDevice *dev, Error **errp) bus->qbus.name, port->path, portspeed); return; } +} + +void usb_device_attach(USBDevice *dev, Error **errp) +{ + USBPort *port = dev->port; + Error *local_err = NULL; + + usb_check_attach(dev, &local_err); + if (local_err) { + error_propagate(errp, local_err); + return; + } dev->attached++; usb_attach(port); -- cgit v1.2.3