1
0
Fork 0
forked from len0rd/rockbox

Cosmetic changes only - tab, whitespace and brace policing

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14484 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Dave Chapman 2007-08-27 22:07:36 +00:00
parent a6d52a8305
commit 03745f4ed3
13 changed files with 558 additions and 555 deletions

View file

@ -25,27 +25,27 @@
*
* Naming Convention for Endpoint Names
*
* - ep1, ep2, ... address is fixed, not direction or type
* - ep1in, ep2out, ... address and direction are fixed, not type
* - ep1-bulk, ep2-bulk, ... address and type are fixed, not direction
* - ep1in-bulk, ep2out-iso, ... all three are fixed
* - ep-* ... no functionality restrictions
* - ep1, ep2, ... address is fixed, not direction or type
* - ep1in, ep2out, ... address and direction are fixed, not type
* - ep1-bulk, ep2-bulk, ... address and type are fixed, not direction
* - ep1in-bulk, ep2out-iso, ... all three are fixed
* - ep-* ... no functionality restrictions
*
* Type suffixes are "-bulk", "-iso", or "-int". Numbers are decimal.
*
*/
static int ep_matches(struct usb_ep* ep, struct usb_endpoint_descriptor* desc);
void usb_ep_autoconfig_reset(void) {
void usb_ep_autoconfig_reset(void)
{
struct usb_ep* ep = NULL;
if (usbcore.active_controller == NULL) {
return;
}
logf("resetting endpoints");
list_for_each_entry(ep, &usbcore.active_controller->endpoints.list, list) {
logf("reset %s", ep->name);
logf("reset %s", ep->name);
ep->claimed = false;
}
}
@ -55,48 +55,48 @@ void usb_ep_autoconfig_reset(void) {
* @param desc usb descritpro to use for seraching.
* @return NULL or a valid endpoint.
*/
struct usb_ep* usb_ep_autoconfig(struct usb_endpoint_descriptor* desc) {
struct usb_ep* ep = NULL;
struct usb_ep* usb_ep_autoconfig(struct usb_endpoint_descriptor* desc)
{
struct usb_ep* ep = NULL;
if (usbcore.active_controller == NULL) {
logf("active controller NULL");
logf("active controller NULL");
return NULL;
}
list_for_each_entry(ep, &usbcore.active_controller->endpoints.list, list) {
if (ep_matches (ep, desc)) {
return ep;
}
}
return NULL;
}
static int ep_matches(struct usb_ep* ep, struct usb_endpoint_descriptor* desc) {
static int ep_matches(struct usb_ep* ep, struct usb_endpoint_descriptor* desc)
{
uint8_t type;
const char* tmp;
uint16_t max;
const char* tmp;
uint16_t max;
/* endpoint already claimed? */
if (ep->claimed) {
logf("!! claimed !!");
/* endpoint already claimed? */
if (ep->claimed) {
logf("!! claimed !!");
return 0;
}
/* only support ep0 for portable CONTROL traffic */
type = desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK;
if (type == USB_ENDPOINT_XFER_CONTROL) {
logf("type == control");
logf("type == control");
return 0;
}
/* some other naming convention */
if (ep->name[0] != 'e') {
logf("wrong name");
logf("wrong name");
return 0;
}
/* type-restriction: "-iso", "-bulk", or "-int".
* direction-restriction: "in", "out".
*/
@ -111,20 +111,20 @@ static int ep_matches(struct usb_ep* ep, struct usb_endpoint_descriptor* desc) {
if (tmp[2] == 's') { // == "-iso"
return 0;
}
break;
case USB_ENDPOINT_XFER_BULK:
if (tmp[1] != 'b') { // != "-bulk"
return 0;
}
break;
case USB_ENDPOINT_XFER_ISOC:
if (tmp[2] != 's') { // != "-iso"
return 0;
}
}
break;
case USB_ENDPOINT_XFER_BULK:
if (tmp[1] != 'b') { // != "-bulk"
return 0;
}
break;
case USB_ENDPOINT_XFER_ISOC:
if (tmp[2] != 's') { // != "-iso"
return 0;
}
}
} else {
tmp = ep->name + strlen (ep->name);
}
}
/* direction-restriction: "..in-..", "out-.." */
tmp--;
@ -132,7 +132,7 @@ static int ep_matches(struct usb_ep* ep, struct usb_endpoint_descriptor* desc) {
if (desc->bEndpointAddress & USB_DIR_IN) {
if ('n' != *tmp) {
return 0;
}
}
} else {
if ('t' != *tmp) {
return 0;
@ -147,40 +147,40 @@ static int ep_matches(struct usb_ep* ep, struct usb_endpoint_descriptor* desc) {
* the usb spec fixes high speed bulk maxpacket at 512 bytes.
*/
max = 0x7ff & desc->wMaxPacketSize;
switch (type) {
case USB_ENDPOINT_XFER_INT:
/* INT: limit 64 bytes full speed, 1024 high speed */
if ((usbcore.active_controller->speed != USB_SPEED_HIGH) && (max > 64)) {
if ((usbcore.active_controller->speed != USB_SPEED_HIGH) && (max > 64)) {
return 0;
}
/* FALLTHROUGH */
/* FALLTHROUGH */
case USB_ENDPOINT_XFER_ISOC:
case USB_ENDPOINT_XFER_ISOC:
if ((usbcore.active_controller->speed != USB_SPEED_HIGH) && (max > 1023)) {
return 0;
}
break;
}
break;
}
/* MATCH!! */
/* MATCH!! */
/* report address */
/* report address */
desc->bEndpointAddress |= ep->ep_num;
/* report (variable) full speed bulk maxpacket */
if (type == USB_ENDPOINT_XFER_BULK) {
int size = max;
int size = max;
/* min() doesn't work on bitfields with gcc-3.5 */
if (size > 64) {
size = 64;
}
}
desc->wMaxPacketSize = size;
}
/* save desc in endpoint */
ep->desc = desc;
return 1;
}