Skip to contentSkip to conversation

Fix nested switch statements in dummy_hcd.c

PATCH New Ingo van Lil 1 participant 1 message Mar 13, 2008 USB

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix nested switch statements in dummy_hcd.c

Hello everybody,

this patch fixes a messed up combination of two nested switch statements in drivers/usb/gadget/dummy_hcd.c. According to the USB spec (section 5.8.3) the maximum packet size for bulk endpoints can be 512 for high-speed devices and 8, 16, 32 or 64 for full-speed devices. Low-speed devices must not have bulk endpoints.

Cheers,
Ingo

---

drivers/usb/gadget/dummy_hcd.c renamed from drivers/usb/gadget/dummy_hcd.c.orig +6 -8
@@ -363,16 +363,14 @@
 		case USB_SPEED_HIGH:
 			if (max == 512)
 				break;
-			/* conserve return statements */
-		default:
-			switch (max) {
-			case 8: case 16: case 32: case 64:
+			goto done;
+		case USB_SPEED_FULL:
+			if (max == 8 || max == 16 || max == 32 || max == 64)
 				/* we'll fake any legal size */
 				break;
-			default:
-		case USB_SPEED_LOW:
-				goto done;
-			}
+			/* save a return statement */
+		default:
+			goto done;
 		}
 		break;
 	case USB_ENDPOINT_XFER_INT: