Skip to contentSkip to conversation

usb: class specific interface requests

PATCH Applied Max Reitz 2 participants 2 messages Mar 14, 2010 – Mar 31, 2010

lore
Share & tools
lore

Max Reitz

author
#0 lore raw

PATCH 1/1 usb: class specific interface requests

Mass Storage Reset and Get Max LUN are class specific requests, but they were not marked as such in hw/usb-msd.c, moved therefore ClassInterfaceRequest and ClassInterfaceOutRequest from hw/usb-net.c to hw/usb.h.
Furthermore there was a problem in hw/usb-ohci.c when using DEBUG concerning systems where size_t is a 32 bit integer (printf resulted in a segmentation fault).

---
 hw/usb-msd.c  |    4 ++--
 hw/usb-net.c  |    5 -----
 hw/usb-ohci.c |    2 +-
 hw/usb.h      |    4 ++++
 4 files changed, 7 insertions(+), 8 deletions(-)
hw/usb-msd.c +2 -2
index 1a11bc5..87b744f 100644
@@ -327,12 +327,12 @@ static int usb_msd_handle_control(USBDevice *dev, int request, int value,
         ret = 0;
         break;
         /* Class specific requests.  */
-    case MassStorageReset:
+    case ClassInterfaceOutRequest | MassStorageReset:
         /* Reset state ready for the next CBW.  */
         s->mode = USB_MSDM_CBW;
         ret = 0;
         break;
-    case GetMaxLun:
+    case ClassInterfaceRequest | GetMaxLun:
         data[0] = 0;
         ret = 1;
         break;
hw/usb-net.c +0 -5
index 6875f11..45aa427 100644
@@ -71,11 +71,6 @@ enum usbstring_idx {
 #define USB_DT_CS_INTERFACE		0x24
 #define USB_DT_CS_ENDPOINT		0x25
 
-#define ClassInterfaceRequest		\
-    ((USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE) << 8)
-#define ClassInterfaceOutRequest	\
-    ((USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE) << 8)
-
 #define USB_CDC_SEND_ENCAPSULATED_COMMAND	0x00
 #define USB_CDC_GET_ENCAPSULATED_RESPONSE	0x01
 #define USB_CDC_REQ_SET_LINE_CODING		0x20
hw/usb-ohci.c +1 -1
index 5c5dc4a..ac23c44 100644
@@ -908,7 +908,7 @@ static int ohci_service_td(OHCIState *ohci, struct ohci_ed *ed)
     flag_r = (td.flags & OHCI_TD_R) != 0;
 #ifdef DEBUG_PACKET
     DPRINTF(" TD @ 0x%.8x %" PRId64 " bytes %s r=%d cbp=0x%.8x be=0x%.8x\n",
-            addr, len, str, flag_r, td.cbp, td.be);
+            addr, (int64_t)len, str, flag_r, td.cbp, td.be);
 
     if (len > 0 && dir != OHCI_TD_DIR_IN) {
         DPRINTF("  data:");
hw/usb.h +4 -0
index 106d174..00d2802 100644
@@ -91,6 +91,10 @@
 #define EndpointRequest ((USB_DIR_IN|USB_TYPE_STANDARD|USB_RECIP_ENDPOINT)<<8)
 #define EndpointOutRequest \
         ((USB_DIR_OUT|USB_TYPE_STANDARD|USB_RECIP_ENDPOINT)<<8)
+#define ClassInterfaceRequest \
+        ((USB_DIR_IN|USB_TYPE_CLASS|USB_RECIP_INTERFACE)<<8)
+#define ClassInterfaceOutRequest \
+        ((USB_DIR_OUT|USB_TYPE_CLASS|USB_RECIP_INTERFACE)<<8)
 
 #define USB_REQ_GET_STATUS		0x00
 #define USB_REQ_CLEAR_FEATURE		0x01
Signature · 1 line
1.6.4.2
#1 lore raw
Quoted 10 lines · Max Reitz

Mass Storage Reset and Get Max LUN are class specific requests, but they were not marked as such in hw/usb-msd.c, moved therefore ClassInterfaceRequest and ClassInterfaceOutRequest from hw/usb-net.c to hw/usb.h.
Furthermore there was a problem in hw/usb-ohci.c when using DEBUG concerning systems where size_t is a 32 bit integer (printf resulted in a segmentation fault).

Applied. Thanks.

Regards,

Anthony Liguori

Quoted 71 lines
---
  hw/usb-msd.c  |    4 ++--
  hw/usb-net.c  |    5 -----
  hw/usb-ohci.c |    2 +-
  hw/usb.h      |    4 ++++
  4 files changed, 7 insertions(+), 8 deletions(-)
hw/usb-msd.c +2 -2
index 1a11bc5..87b744f 100644
@@ -327,12 +327,12 @@ static int usb_msd_handle_control(USBDevice *dev, int request, int value,
          ret = 0;
          break;
          /* Class specific requests.  */
-    case MassStorageReset:
+    case ClassInterfaceOutRequest | MassStorageReset:
          /* Reset state ready for the next CBW.  */
          s->mode = USB_MSDM_CBW;
          ret = 0;
          break;
-    case GetMaxLun:
+    case ClassInterfaceRequest | GetMaxLun:
          data[0] = 0;
          ret = 1;
          break;
hw/usb-net.c +0 -5
index 6875f11..45aa427 100644
@@ -71,11 +71,6 @@ enum usbstring_idx {
  #define USB_DT_CS_INTERFACE		0x24
  #define USB_DT_CS_ENDPOINT		0x25
 
-#define ClassInterfaceRequest		\
-    ((USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE)<<  8)
-#define ClassInterfaceOutRequest	\
-    ((USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE)<<  8)
-
  #define USB_CDC_SEND_ENCAPSULATED_COMMAND	0x00
  #define USB_CDC_GET_ENCAPSULATED_RESPONSE	0x01
  #define USB_CDC_REQ_SET_LINE_CODING		0x20
hw/usb-ohci.c +1 -1
index 5c5dc4a..ac23c44 100644
@@ -908,7 +908,7 @@ static int ohci_service_td(OHCIState *ohci, struct ohci_ed *ed)
      flag_r = (td.flags&  OHCI_TD_R) != 0;
  #ifdef DEBUG_PACKET
      DPRINTF(" TD @ 0x%.8x %" PRId64 " bytes %s r=%d cbp=0x%.8x be=0x%.8x\n",
-            addr, len, str, flag_r, td.cbp, td.be);
+            addr, (int64_t)len, str, flag_r, td.cbp, td.be);
 
      if (len>  0&&  dir != OHCI_TD_DIR_IN) {
          DPRINTF("  data:");
hw/usb.h +4 -0
index 106d174..00d2802 100644
@@ -91,6 +91,10 @@
  #define EndpointRequest ((USB_DIR_IN|USB_TYPE_STANDARD|USB_RECIP_ENDPOINT)<<8)
  #define EndpointOutRequest \
          ((USB_DIR_OUT|USB_TYPE_STANDARD|USB_RECIP_ENDPOINT)<<8)
+#define ClassInterfaceRequest \
+        ((USB_DIR_IN|USB_TYPE_CLASS|USB_RECIP_INTERFACE)<<8)
+#define ClassInterfaceOutRequest \
+        ((USB_DIR_OUT|USB_TYPE_CLASS|USB_RECIP_INTERFACE)<<8)
 
  #define USB_REQ_GET_STATUS		0x00
  #define USB_REQ_CLEAR_FEATURE		0x01