From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: Gerd Hoffmann <kraxel@redhat.com>
Subject: [Qemu-devel] [PATCH 08/10] usb-storage: add usb_msd_packet_complete()
Date: Fri, 25 May 2012 11:44:19 +0200 [thread overview]
Message-ID: <1337939061-13629-9-git-send-email-kraxel@redhat.com> (raw)
In-Reply-To: <1337939061-13629-1-git-send-email-kraxel@redhat.com>
Factor out packet completion to a separate function which
cares to get the MSDState->packet update right.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
hw/usb/dev-storage.c | 28 ++++++++++++++++------------
1 files changed, 16 insertions(+), 12 deletions(-)
diff --git a/hw/usb/dev-storage.c b/hw/usb/dev-storage.c
index 86f6851..1477599 100644
--- a/hw/usb/dev-storage.c
+++ b/hw/usb/dev-storage.c
@@ -200,6 +200,18 @@ static void usb_msd_send_status(MSDState *s, USBPacket *p)
memset(&s->csw, 0, sizeof(s->csw));
}
+static void usb_msd_packet_complete(MSDState *s)
+{
+ USBPacket *p = s->packet;
+
+ /* Set s->packet to NULL before calling usb_packet_complete
+ because another request may be issued before
+ usb_packet_complete returns. */
+ DPRINTF("Packet complete %p\n", p);
+ s->packet = NULL;
+ usb_packet_complete(&s->dev, p);
+}
+
static void usb_msd_transfer_data(SCSIRequest *req, uint32_t len)
{
MSDState *s = DO_UPCAST(MSDState, dev.qdev, req->bus->qbus.parent);
@@ -212,12 +224,7 @@ static void usb_msd_transfer_data(SCSIRequest *req, uint32_t len)
usb_msd_copy_data(s, p);
p = s->packet;
if (p && p->result == p->iov.size) {
- /* Set s->packet to NULL before calling usb_packet_complete
- because another request may be issued before
- usb_packet_complete returns. */
- DPRINTF("Packet complete %p\n", p);
- s->packet = NULL;
- usb_packet_complete(&s->dev, p);
+ usb_msd_packet_complete(s);
}
}
}
@@ -250,8 +257,7 @@ static void usb_msd_command_complete(SCSIRequest *req, uint32_t status, size_t r
s->mode = USB_MSDM_CSW;
}
}
- s->packet = NULL;
- usb_packet_complete(&s->dev, p);
+ usb_msd_packet_complete(s);
} else if (s->data_len == 0) {
s->mode = USB_MSDM_CSW;
}
@@ -281,10 +287,8 @@ static void usb_msd_handle_reset(USBDevice *dev)
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->packet->result = USB_RET_STALL;
+ usb_msd_packet_complete(s);
}
s->mode = USB_MSDM_CBW;
--
1.7.1
next prev parent reply other threads:[~2012-05-25 9:44 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-25 9:44 [Qemu-devel] [PATCH 00/10] usb: uhci & usb-storage updates Gerd Hoffmann
2012-05-25 9:44 ` [Qemu-devel] [PATCH 01/10] uhci: fix bandwidth management Gerd Hoffmann
2012-05-25 9:44 ` [Qemu-devel] [PATCH 02/10] uhci: use bottom half Gerd Hoffmann
2012-05-25 9:44 ` [Qemu-devel] [PATCH 03/10] uhci: make bandwidth tunable Gerd Hoffmann
2012-05-25 9:44 ` [Qemu-devel] [PATCH 04/10] uhci: fix trace format strings Gerd Hoffmann
2012-05-25 9:44 ` [Qemu-devel] [PATCH 05/10] uhci: zap uhci_pre_save Gerd Hoffmann
2012-05-25 9:44 ` [Qemu-devel] [PATCH 06/10] scsi: prepare migration code for usb-storage support Gerd Hoffmann
2012-05-25 9:51 ` Paolo Bonzini
2012-05-25 9:44 ` [Qemu-devel] [PATCH 07/10] usb-storage: remove MSDState->residue Gerd Hoffmann
2012-05-25 9:44 ` Gerd Hoffmann [this message]
2012-05-25 9:44 ` [Qemu-devel] [PATCH 09/10] usb-storage: add scsi_off, remove scsi_buf Gerd Hoffmann
2012-05-25 10:09 ` Paolo Bonzini
2012-05-25 9:44 ` [Qemu-devel] [PATCH 10/10] usb-storage: migration support Gerd Hoffmann
2012-05-25 10:11 ` Paolo Bonzini
2012-05-25 10:33 ` Gerd Hoffmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1337939061-13629-9-git-send-email-kraxel@redhat.com \
--to=kraxel@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).