From 1a0bdbd415ddb4d15fd6d5787aba4d3276d19922 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Wed, 22 Feb 2012 14:11:43 +0100 Subject: [PATCH 027/109] usb-storage: drop tag from device state. RH-Author: Paolo Bonzini Message-id: <1329919979-20948-27-git-send-email-pbonzini@redhat.com> Patchwork-id: 37520 O-Subject: [RHEL 6.3 qemu-kvm PATCH v2 026/102] usb-storage: drop tag from device state. Bugzilla: 782029 RH-Acked-by: Gerd Hoffmann RH-Acked-by: Laszlo Ersek RH-Acked-by: Orit Wasserman From: Gerd Hoffmann scsi keeps track of the tag in SCSIRequest, no need to store a separate copy. Signed-off-by: Gerd Hoffmann (cherry picked from 7b863f41de0c0089c2735e3caa8952bb3b0a5a7c) --- hw/usb-msd.c | 13 ++++++------- 1 files changed, 6 insertions(+), 7 deletions(-) Signed-off-by: Michal Novotny --- hw/usb-msd.c | 13 ++++++------- 1 files changed, 6 insertions(+), 7 deletions(-) diff --git a/hw/usb-msd.c b/hw/usb-msd.c index f9470fe..dbea6c7 100644 --- a/hw/usb-msd.c +++ b/hw/usb-msd.c @@ -54,7 +54,6 @@ typedef struct { uint8_t *usb_buf; uint32_t data_len; uint32_t residue; - uint32_t tag; struct usb_msd_csw csw; SCSIRequest *req; SCSIBus bus; @@ -237,12 +236,12 @@ static void usb_msd_command_complete(SCSIRequest *req, uint32_t status) MSDState *s = DO_UPCAST(MSDState, dev.qdev, req->bus->qbus.parent); USBPacket *p = s->packet; - DPRINTF("Command complete %d\n", status); + DPRINTF("Command complete %d tag 0x%x\n", status, req->tag); s->residue = s->data_len; s->result = status != 0; s->csw.sig = cpu_to_le32(0x53425355); - s->csw.tag = cpu_to_le32(s->tag); + s->csw.tag = cpu_to_le32(req->tag); s->csw.residue = s->residue; s->csw.status = s->result; @@ -269,7 +268,6 @@ static void usb_msd_command_complete(SCSIRequest *req, uint32_t status) } else if (s->data_len == 0) { s->mode = USB_MSDM_CSW; } - scsi_req_unref(req); s->req = NULL; } @@ -361,6 +359,7 @@ static void usb_msd_cancel_io(USBDevice *dev, USBPacket *p) static int usb_msd_handle_data(USBDevice *dev, USBPacket *p) { MSDState *s = (MSDState *)dev; + uint32_t tag; int ret = 0; struct usb_msd_cbw cbw; uint8_t devep = p->devep; @@ -389,7 +388,7 @@ static int usb_msd_handle_data(USBDevice *dev, USBPacket *p) fprintf(stderr, "usb-msd: Bad LUN %d\n", cbw.lun); goto fail; } - s->tag = le32_to_cpu(cbw.tag); + tag = le32_to_cpu(cbw.tag); s->data_len = le32_to_cpu(cbw.data_len); if (s->data_len == 0) { s->mode = USB_MSDM_CSW; @@ -399,10 +398,10 @@ static int usb_msd_handle_data(USBDevice *dev, USBPacket *p) s->mode = USB_MSDM_DATAOUT; } DPRINTF("Command tag 0x%x flags %08x len %d data %d\n", - s->tag, cbw.flags, cbw.cmd_len, s->data_len); + tag, cbw.flags, cbw.cmd_len, s->data_len); s->residue = 0; s->scsi_len = 0; - s->req = scsi_req_new(s->scsi_dev, s->tag, 0, cbw.cmd, NULL); + s->req = scsi_req_new(s->scsi_dev, tag, 0, cbw.cmd, NULL); scsi_req_enqueue(s->req); /* ??? Should check that USB and SCSI data transfer directions match. */ -- 1.7.7.6