From d28f4e2d86317f7ef7398651e8a1d493e4bf8c88 Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Fri, 6 Jan 2012 15:23:10 +0100 Subject: usb: kill USB_MSG_RESET The USB subsystem pipes internal reset notifications through usb_handle_packet() with a special magic PID. This indirection is a pretty pointless excercise as it ends up being handled by usb_generic_handle_packet anyway. Replace the USB_MSG_RESET with a usb_device_reset() function which can be called directly. Also rename the existing usb_reset() function to usb_port_reset() to avoid confusion. Signed-off-by: Gerd Hoffmann --- hw/usb.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'hw/usb.c') diff --git a/hw/usb.c b/hw/usb.c index 800dd835de..c8e6be4bc5 100644 --- a/hw/usb.c +++ b/hw/usb.c @@ -49,14 +49,25 @@ void usb_detach(USBPort *port) dev->state = USB_STATE_NOTATTACHED; } -void usb_reset(USBPort *port) +void usb_port_reset(USBPort *port) { USBDevice *dev = port->dev; assert(dev != NULL); usb_detach(port); usb_attach(port); - usb_send_msg(dev, USB_MSG_RESET); + usb_device_reset(dev); +} + +void usb_device_reset(USBDevice *dev) +{ + if (dev == NULL || !dev->attached) { + return; + } + dev->remote_wakeup = 0; + dev->addr = 0; + dev->state = USB_STATE_DEFAULT; + usb_device_handle_reset(dev); } void usb_wakeup(USBDevice *dev) @@ -218,15 +229,6 @@ static int do_token_out(USBDevice *s, USBPacket *p) */ int usb_generic_handle_packet(USBDevice *s, USBPacket *p) { - switch(p->pid) { - case USB_MSG_RESET: - s->remote_wakeup = 0; - s->addr = 0; - s->state = USB_STATE_DEFAULT; - usb_device_handle_reset(s); - return 0; - } - /* Rest of the PIDs must match our address */ if (s->state < USB_STATE_DEFAULT || p->devaddr != s->addr) return USB_RET_NODEV; -- cgit v1.2.3-55-g7522