PERFORCE change 163780 for review
Hans Petter Selasky
hselasky at FreeBSD.org
Mon Jun 8 13:10:14 UTC 2009
http://perforce.freebsd.org/chv.cgi?CH=163780
Change 163780 by hselasky at hselasky_laptop001 on 2009/06/08 13:09:58
USB CORE:
- minor device side improvement. Make sure a not complete state
gets paired with a complete state in device side mode for the
default control endpoint.
Affected files ...
.. //depot/projects/usb/src/sys/dev/usb/usb_core.h#24 edit
.. //depot/projects/usb/src/sys/dev/usb/usb_handle_request.c#11 edit
.. //depot/projects/usb/src/sys/dev/usb/usb_if.m#8 edit
Differences ...
==== //depot/projects/usb/src/sys/dev/usb/usb_core.h#24 (text+ko) ====
@@ -215,6 +215,11 @@
#define USB_ST_TRANSFERRED 1
#define USB_ST_ERROR 2
+/* USB handle request states */
+#define USB_HR_NOT_COMPLETE 0
+#define USB_HR_COMPLETE_OK 1
+#define USB_HR_COMPLETE_ERR 2
+
/*
* The following macro will return the current state of an USB
* transfer like defined by the "USB_ST_XXX" enums.
==== //depot/projects/usb/src/sys/dev/usb/usb_handle_request.c#11 (text+ko) ====
@@ -42,13 +42,6 @@
#include <dev/usb/usb_controller.h>
#include <dev/usb/usb_bus.h>
-/* enum */
-
-enum {
- ST_DATA,
- ST_POST_STATUS,
-};
-
/* function prototypes */
static uint8_t usb2_handle_get_stall(struct usb_device *, uint8_t);
@@ -88,16 +81,17 @@
usb2_needs_explore(xfer->xroot->bus, 0);
break;
}
- /*
- * If no control transfer is active,
- * receive the next SETUP message:
- */
goto tr_restart;
}
usb2_start_hardware(xfer);
break;
default:
+ /* check if a control transfer is active */
+ if (xfer->flags_int.control_rem != 0xFFFF) {
+ /* handle the request */
+ err = usb2_handle_request(xfer);
+ }
if (xfer->error != USB_ERR_CANCELLED) {
/* should not happen - try stalling */
goto tr_restart;
@@ -107,6 +101,10 @@
return;
tr_restart:
+ /*
+ * If a control transfer is active, stall it, and wait for the
+ * next control transfer.
+ */
xfer->frlengths[0] = sizeof(struct usb_device_request);
xfer->nframes = 1;
xfer->flags.manual_status = 1;
@@ -215,7 +213,7 @@
#endif
error = USB_HANDLE_REQUEST(iface->subdev,
&req, ppdata, plen,
- off, (state == ST_POST_STATUS));
+ off, state);
}
iface_parent = usb2_get_iface(udev, iface->parent_iface_index);
@@ -235,7 +233,7 @@
device_is_attached(iface_parent->subdev)) {
error = USB_HANDLE_REQUEST(iface_parent->subdev,
&req, ppdata, plen, off,
- (state == ST_POST_STATUS));
+ state);
}
if (error == 0) {
/* negativly adjust pointer and length */
@@ -249,7 +247,7 @@
iface_index++; /* iterate */
goto tr_repeat;
}
- if (state == ST_POST_STATUS) {
+ if (state != USB_HR_NOT_COMPLETE) {
/* we are complete */
goto tr_valid;
}
@@ -409,7 +407,7 @@
*
* Internal state sequence:
*
- * ST_DATA -> ST_POST_STATUS
+ * USB_HR_NOT_COMPLETE -> USB_HR_COMPLETE_OK v USB_HR_COMPLETE_ERR
*
* Returns:
* 0: Ready to start hardware
@@ -441,21 +439,23 @@
switch (USB_GET_STATE(xfer)) {
case USB_ST_SETUP:
- state = ST_DATA;
+ state = USB_HR_NOT_COMPLETE;
if (!xfer->flags_int.control_act) {
/* nothing to do */
goto tr_stalled;
}
break;
-
- default: /* USB_ST_TRANSFERRED */
+ case USB_ST_TRANSFERRED:
if (!xfer->flags_int.control_act) {
- state = ST_POST_STATUS;
+ state = USB_HR_COMPLETE_OK;
} else {
- state = ST_DATA;
+ state = USB_HR_NOT_COMPLETE;
}
break;
+ default:
+ state = USB_HR_COMPLETE_ERR;
+ break;
}
/* reset frame stuff */
@@ -499,7 +499,7 @@
switch (req.bmRequestType) {
case UT_READ_DEVICE:
- if (state != ST_DATA) {
+ if (state != USB_HR_NOT_COMPLETE) {
break;
}
switch (req.bRequest) {
@@ -629,7 +629,7 @@
goto tr_valid;
tr_handle_set_address:
- if (state == ST_DATA) {
+ if (state == USB_HR_NOT_COMPLETE) {
if (wValue >= 0x80) {
/* invalid value */
goto tr_stalled;
@@ -637,14 +637,14 @@
/* we are configured ! */
goto tr_stalled;
}
- } else if (state == ST_POST_STATUS) {
+ } else if (state != USB_HR_NOT_COMPLETE) {
udev->address = (wValue & 0x7F);
goto tr_bad_context;
}
goto tr_valid;
tr_handle_set_config:
- if (state == ST_DATA) {
+ if (state == USB_HR_NOT_COMPLETE) {
if (usb2_handle_set_config(xfer, req.wValue[0])) {
goto tr_stalled;
}
@@ -652,7 +652,7 @@
goto tr_valid;
tr_handle_clear_halt:
- if (state == ST_DATA) {
+ if (state == USB_HR_NOT_COMPLETE) {
if (usb2_handle_set_stall(xfer, req.wIndex[0], 0)) {
goto tr_stalled;
}
@@ -660,7 +660,7 @@
goto tr_valid;
tr_handle_clear_wakeup:
- if (state == ST_DATA) {
+ if (state == USB_HR_NOT_COMPLETE) {
if (usb2_handle_remote_wakeup(xfer, 0)) {
goto tr_stalled;
}
@@ -668,7 +668,7 @@
goto tr_valid;
tr_handle_set_halt:
- if (state == ST_DATA) {
+ if (state == USB_HR_NOT_COMPLETE) {
if (usb2_handle_set_stall(xfer, req.wIndex[0], 1)) {
goto tr_stalled;
}
@@ -676,7 +676,7 @@
goto tr_valid;
tr_handle_set_wakeup:
- if (state == ST_DATA) {
+ if (state == USB_HR_NOT_COMPLETE) {
if (usb2_handle_remote_wakeup(xfer, 1)) {
goto tr_stalled;
}
@@ -684,7 +684,7 @@
goto tr_valid;
tr_handle_get_ep_status:
- if (state == ST_DATA) {
+ if (state == USB_HR_NOT_COMPLETE) {
temp.wStatus[0] =
usb2_handle_get_stall(udev, req.wIndex[0]);
temp.wStatus[1] = 0;
@@ -694,7 +694,7 @@
goto tr_valid;
tr_valid:
- if (state == ST_POST_STATUS) {
+ if (state != USB_HR_NOT_COMPLETE) {
goto tr_stalled;
}
/* subtract offset from length */
@@ -750,7 +750,7 @@
return (0); /* success */
tr_stalled:
- DPRINTF("%s\n", (state == ST_POST_STATUS) ?
+ DPRINTF("%s\n", (state != USB_HR_NOT_COMPLETE) ?
"complete" : "stalled");
return (USB_ERR_STALLED);
==== //depot/projects/usb/src/sys/dev/usb/usb_if.m#8 (text+ko) ====
@@ -47,6 +47,5 @@
void **pptr; /* data pointer */
uint16_t *plen; /* maximum transfer length */
uint16_t offset; /* data offset */
- uint8_t is_complete; /* set if transfer is complete */
+ uint8_t is_complete; /* set if transfer is complete, see USB_HR_XXX */
};
-
More information about the p4-projects
mailing list