This is a convenience change that accepts a status when completing a
packet.
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
hw/usb/dev-storage.c | 17 ++++++++---------
1 file changed, 8 insertions(+), 9 deletions(-)
diff --git a/hw/usb/dev-storage.c b/hw/usb/dev-storage.c
index 341e505bd0..4f1e8b7f6c 100644
--- a/hw/usb/dev-storage.c
+++ b/hw/usb/dev-storage.c
@@ -177,7 +177,7 @@ static const USBDesc desc = {
.str = desc_strings,
};
-static void usb_msd_packet_complete(MSDState *s)
+static void usb_msd_packet_complete(MSDState *s, int status)
{
USBPacket *p = s->packet;
@@ -187,6 +187,7 @@ static void usb_msd_packet_complete(MSDState *s)
* usb_packet_complete returns.
*/
trace_usb_msd_packet_complete();
+ p->status = status;
s->packet = NULL;
usb_packet_complete(&s->dev, p);
}
@@ -196,8 +197,7 @@ static void usb_msd_fatal_error(MSDState *s)
trace_usb_msd_fatal_error();
if (s->packet) {
- s->packet->status = USB_RET_STALL;
- usb_msd_packet_complete(s);
+ usb_msd_packet_complete(s, USB_RET_STALL);
}
/*
@@ -255,8 +255,8 @@ void usb_msd_transfer_data(SCSIRequest *req, uint32_t len)
usb_msd_copy_data(s, p);
p = s->packet;
if (p && p->actual_length == p->iov.size) {
- p->status = USB_RET_SUCCESS; /* Clear previous ASYNC status */
- usb_msd_packet_complete(s);
+ /* USB_RET_SUCCESS status clears previous ASYNC status */
+ usb_msd_packet_complete(s, USB_RET_SUCCESS);
}
}
}
@@ -295,8 +295,8 @@ void usb_msd_command_complete(SCSIRequest *req, size_t resid)
s->mode = USB_MSDM_CSW;
}
}
- p->status = USB_RET_SUCCESS; /* Clear previous ASYNC status */
- usb_msd_packet_complete(s);
+ /* USB_RET_SUCCESS status clears previous ASYNC status */
+ usb_msd_packet_complete(s, USB_RET_SUCCESS);
} else if (s->data_len == 0) {
s->mode = USB_MSDM_CSW;
}
@@ -332,8 +332,7 @@ void usb_msd_handle_reset(USBDevice *dev)
assert(s->req == NULL);
if (s->packet) {
- s->packet->status = USB_RET_STALL;
- usb_msd_packet_complete(s);
+ usb_msd_packet_complete(s, USB_RET_STALL);
}
memset(&s->csw, 0, sizeof(s->csw));
--
2.45.2
On 10/11/24 03:39, Nicholas Piggin wrote: > This is a convenience change that accepts a status when completing a > packet. > > Signed-off-by: Nicholas Piggin <npiggin@gmail.com> > --- > hw/usb/dev-storage.c | 17 ++++++++--------- > 1 file changed, 8 insertions(+), 9 deletions(-) Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
© 2016 - 2024 Red Hat, Inc.