From patchwork Fri May 25 09:44:18 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 161291 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 5A150B6EF3 for ; Fri, 25 May 2012 21:13:49 +1000 (EST) Received: from localhost ([::1]:52623 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SXr5M-0002x0-Oe for incoming@patchwork.ozlabs.org; Fri, 25 May 2012 05:45:28 -0400 Received: from eggs.gnu.org ([208.118.235.92]:47598) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SXr4V-000141-6h for qemu-devel@nongnu.org; Fri, 25 May 2012 05:44:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SXr4O-0000cL-2P for qemu-devel@nongnu.org; Fri, 25 May 2012 05:44:34 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54575) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SXr4N-0000bS-Qi for qemu-devel@nongnu.org; Fri, 25 May 2012 05:44:27 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q4P9iQWN015075 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 25 May 2012 05:44:26 -0400 Received: from rincewind.home.kraxel.org (ovpn-116-44.ams2.redhat.com [10.36.116.44]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q4P9iPS8020891; Fri, 25 May 2012 05:44:26 -0400 Received: by rincewind.home.kraxel.org (Postfix, from userid 500) id 9B0C041312; Fri, 25 May 2012 11:44:22 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Fri, 25 May 2012 11:44:18 +0200 Message-Id: <1337939061-13629-8-git-send-email-kraxel@redhat.com> In-Reply-To: <1337939061-13629-1-git-send-email-kraxel@redhat.com> References: <1337939061-13629-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: Gerd Hoffmann Subject: [Qemu-devel] [PATCH 07/10] usb-storage: remove MSDState->residue X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org We have the field twice, once in MSDState directly and one in the status word struct. Drop one. Signed-off-by: Gerd Hoffmann --- hw/usb/dev-storage.c | 10 ++++------ 1 files changed, 4 insertions(+), 6 deletions(-) diff --git a/hw/usb/dev-storage.c b/hw/usb/dev-storage.c index ae22fb1..86f6851 100644 --- a/hw/usb/dev-storage.c +++ b/hw/usb/dev-storage.c @@ -51,7 +51,6 @@ typedef struct { uint32_t scsi_len; uint8_t *scsi_buf; uint32_t data_len; - uint32_t residue; struct usb_msd_csw csw; SCSIRequest *req; SCSIBus bus; @@ -229,11 +228,10 @@ static void usb_msd_command_complete(SCSIRequest *req, uint32_t status, size_t r USBPacket *p = s->packet; DPRINTF("Command complete %d tag 0x%x\n", status, req->tag); - s->residue = s->data_len; s->csw.sig = cpu_to_le32(0x53425355); s->csw.tag = cpu_to_le32(req->tag); - s->csw.residue = cpu_to_le32(s->residue); + s->csw.residue = cpu_to_le32(s->data_len); s->csw.status = status != 0; if (s->packet) { @@ -378,7 +376,7 @@ static int usb_msd_handle_data(USBDevice *dev, USBPacket *p) } DPRINTF("Command tag 0x%x flags %08x len %d data %d\n", tag, cbw.flags, cbw.cmd_len, s->data_len); - s->residue = 0; + assert(le32_to_cpu(s->csw.residue) == 0); s->scsi_len = 0; s->req = scsi_req_new(s->scsi_dev, tag, 0, cbw.cmd, NULL); scsi_req_enqueue(s->req); @@ -397,7 +395,7 @@ static int usb_msd_handle_data(USBDevice *dev, USBPacket *p) if (s->scsi_len) { usb_msd_copy_data(s, p); } - if (s->residue) { + if (le32_to_cpu(s->csw.residue)) { int len = p->iov.size - p->result; if (len) { usb_packet_skip(p, len); @@ -458,7 +456,7 @@ static int usb_msd_handle_data(USBDevice *dev, USBPacket *p) if (s->scsi_len) { usb_msd_copy_data(s, p); } - if (s->residue) { + if (le32_to_cpu(s->csw.residue)) { int len = p->iov.size - p->result; if (len) { usb_packet_skip(p, len);