Patchwork hw/usb-msd: fix some usb requests

login
register
mail settings
Submitter Arnaud Patard (Rtp)
Date March 10, 2010, 9:45 a.m.
Message ID <87pr3cmrx3.fsf@lechat.rtp-net.org>
Download mbox | patch
Permalink /patch/47214/
State New
Headers show

Comments

Arnaud Patard (Rtp) - March 10, 2010, 9:45 a.m.
The usb-msd device emulation needs some small tweaks in the requests
emulations. For instance, the reset/maxlun requests are class/interface
specific so requests for them with the type class and recipient interface
bits sets have to be handled.

Signed-off-by: Arnaud Patard <arnaud.patard@rtp-net.org>
---
David S. Ahern - March 10, 2010, 7:40 p.m.
On 03/10/2010 02:45 AM, Arnaud Patard (Rtp) wrote:
> 
> The usb-msd device emulation needs some small tweaks in the requests
> emulations. For instance, the reset/maxlun requests are class/interface
> specific so requests for them with the type class and recipient interface
> bits sets have to be handled.
> 
> Signed-off-by: Arnaud Patard <arnaud.patard@rtp-net.org>
> ---

I hit this yesterday with msd as well. I suggest moving the
ClassInterfaceRequest and ClassInterfaceOutRequest defines from
hw/usb-net.c to hw/usb.h and then use those in hw/usb-msd.c for the
Class specific requests.

David
Anthony Liguori - March 17, 2010, 4:58 p.m.
On 03/10/2010 03:45 AM, Arnaud Patard (Rtp) wrote:
> The usb-msd device emulation needs some small tweaks in the requests
> emulations. For instance, the reset/maxlun requests are class/interface
> specific so requests for them with the type class and recipient interface
> bits sets have to be handled.
>
> Signed-off-by: Arnaud Patard<arnaud.patard@rtp-net.org>
> ---
>    
Applied.  Thanks.

Regards,

Anthony Liguori

Patch

diff --git a/hw/usb-msd.c b/hw/usb-msd.c
index bb39b62..bec82f9 100644
--- a/hw/usb-msd.c
+++ b/hw/usb-msd.c
@@ -321,17 +321,19 @@  static int usb_msd_handle_control(USBDevice *dev, int request, int value,
         ret = 0;
         break;
     case EndpointOutRequest | USB_REQ_CLEAR_FEATURE:
-        if (value == 0 && index != 0x81) { /* clear ep halt */
-            goto fail;
-        }
+        ret = 0;
+        break;
+    case InterfaceOutRequest | USB_REQ_SET_INTERFACE:
         ret = 0;
         break;
         /* Class specific requests.  */
+    case (((USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE) << 8) | MassStorageReset):
     case MassStorageReset:
         /* Reset state ready for the next CBW.  */
         s->mode = USB_MSDM_CBW;
         ret = 0;
         break;
+    case (((USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE) << 8) | GetMaxLun):
     case GetMaxLun:
         data[0] = 0;
         ret = 1;