From: Gerd Hoffmann Date: Wed, 4 Jan 2012 17:13:54 +0000 (+0100) Subject: usb-storage: cancel I/O on reset X-Git-Tag: TizenStudio_2.0_p2.3~1876 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=31058c319b0558f617a29c556264970d6017c0fd;p=sdk%2Femulator%2Fqemu.git usb-storage: cancel I/O on reset When resetting the usb-storage device we'll have to carefully cancel and clear any requests which might be in flight, otherwise we'll confuse the state machine. Signed-off-by: Gerd Hoffmann --- diff --git a/hw/usb-msd.c b/hw/usb-msd.c index 4c06950..3147131 100644 --- a/hw/usb-msd.c +++ b/hw/usb-msd.c @@ -278,6 +278,18 @@ static void usb_msd_handle_reset(USBDevice *dev) MSDState *s = (MSDState *)dev; DPRINTF("Reset\n"); + if (s->req) { + scsi_req_cancel(s->req); + } + assert(s->req == NULL); + + if (s->packet) { + USBPacket *p = s->packet; + s->packet = NULL; + p->result = USB_RET_STALL; + usb_packet_complete(dev, p); + } + s->mode = USB_MSDM_CBW; }