USB style patch, 80 chars strict

USB Code style patch

Signed-off-by: Michael Trimarchi <trimarchi@gandalf.sssup.it>
Signed-off-by: Remy Böhmer <linux@bohmer.net>
This commit is contained in:
Michael Trimarchi 2008-11-26 17:41:34 +01:00 committed by Remy Böhmer
parent d10c5a87cb
commit de39f8c19d
3 changed files with 462 additions and 389 deletions

View File

@ -40,29 +40,30 @@ char * usb_get_class_desc(unsigned char dclass)
{
switch (dclass) {
case USB_CLASS_PER_INTERFACE:
return("See Interface");
return "See Interface";
case USB_CLASS_AUDIO:
return("Audio");
return "Audio";
case USB_CLASS_COMM:
return("Communication");
return "Communication";
case USB_CLASS_HID:
return("Human Interface");
return "Human Interface";
case USB_CLASS_PRINTER:
return("Printer");
return "Printer";
case USB_CLASS_MASS_STORAGE:
return("Mass Storage");
return "Mass Storage";
case USB_CLASS_HUB:
return("Hub");
return "Hub";
case USB_CLASS_DATA:
return("CDC Data");
return "CDC Data";
case USB_CLASS_VENDOR_SPEC:
return("Vendor specific");
return "Vendor specific";
default:
return("");
return "";
}
}
void usb_display_class_sub(unsigned char dclass,unsigned char subclass,unsigned char proto)
void usb_display_class_sub(unsigned char dclass, unsigned char subclass,
unsigned char proto)
{
switch (dclass) {
case USB_CLASS_PER_INTERFACE:
@ -88,10 +89,12 @@ void usb_display_class_sub(unsigned char dclass,unsigned char subclass,unsigned
break;
default:
printf("reserved");
break;
}
break;
default:
printf("reserved");
break;
}
break;
case USB_CLASS_MASS_STORAGE:
@ -132,10 +135,12 @@ void usb_display_class_sub(unsigned char dclass,unsigned char subclass,unsigned
break;
default:
printf("reserved");
break;
}
break;
default:
printf("%s", usb_get_class_desc(dclass));
break;
}
}
@ -143,7 +148,7 @@ void usb_display_string(struct usb_device *dev,int index)
{
char buffer[256];
if (index != 0) {
if (usb_string(dev,index,&buffer[0],256)>0);
if (usb_string(dev, index, &buffer[0], 256) > 0)
printf("String: \"%s\"", buffer);
}
}
@ -151,29 +156,45 @@ void usb_display_string(struct usb_device *dev,int index)
void usb_display_desc(struct usb_device *dev)
{
if (dev->descriptor.bDescriptorType == USB_DT_DEVICE) {
printf("%d: %s, USB Revision %x.%x\n",dev->devnum,usb_get_class_desc(dev->config.if_desc[0].bInterfaceClass),
(dev->descriptor.bcdUSB>>8) & 0xff,dev->descriptor.bcdUSB & 0xff);
if (strlen(dev->mf) || strlen(dev->prod) || strlen(dev->serial))
printf(" - %s %s %s\n",dev->mf,dev->prod,dev->serial);
printf("%d: %s, USB Revision %x.%x\n", dev->devnum,
usb_get_class_desc(dev->config.if_desc[0].bInterfaceClass),
(dev->descriptor.bcdUSB>>8) & 0xff,
dev->descriptor.bcdUSB & 0xff);
if (strlen(dev->mf) || strlen(dev->prod) ||
strlen(dev->serial))
printf(" - %s %s %s\n", dev->mf, dev->prod,
dev->serial);
if (dev->descriptor.bDeviceClass) {
printf(" - Class: ");
usb_display_class_sub(dev->descriptor.bDeviceClass,dev->descriptor.bDeviceSubClass,dev->descriptor.bDeviceProtocol);
usb_display_class_sub(dev->descriptor.bDeviceClass,
dev->descriptor.bDeviceSubClass,
dev->descriptor.bDeviceProtocol);
printf("\n");
} else {
printf(" - Class: (from Interface) %s\n",
usb_get_class_desc(
dev->config.if_desc[0].bInterfaceClass));
}
else {
printf(" - Class: (from Interface) %s\n",usb_get_class_desc(dev->config.if_desc[0].bInterfaceClass));
}
printf(" - PacketSize: %d Configurations: %d\n",dev->descriptor.bMaxPacketSize0,dev->descriptor.bNumConfigurations);
printf(" - Vendor: 0x%04x Product 0x%04x Version %d.%d\n",dev->descriptor.idVendor,dev->descriptor.idProduct,(dev->descriptor.bcdDevice>>8) & 0xff,dev->descriptor.bcdDevice & 0xff);
printf(" - PacketSize: %d Configurations: %d\n",
dev->descriptor.bMaxPacketSize0,
dev->descriptor.bNumConfigurations);
printf(" - Vendor: 0x%04x Product 0x%04x Version %d.%d\n",
dev->descriptor.idVendor, dev->descriptor.idProduct,
(dev->descriptor.bcdDevice>>8) & 0xff,
dev->descriptor.bcdDevice & 0xff);
}
}
void usb_display_conf_desc(struct usb_config_descriptor *config,struct usb_device *dev)
void usb_display_conf_desc(struct usb_config_descriptor *config,
struct usb_device *dev)
{
printf(" Configuration: %d\n", config->bConfigurationValue);
printf(" - Interfaces: %d %s%s%dmA\n",config->bNumInterfaces,(config->bmAttributes & 0x40) ? "Self Powered " : "Bus Powered ",
(config->bmAttributes & 0x20) ? "Remote Wakeup " : "",config->MaxPower*2);
printf(" - Interfaces: %d %s%s%dmA\n", config->bNumInterfaces,
(config->bmAttributes & 0x40) ? "Self Powered " : "Bus Powered ",
(config->bmAttributes & 0x20) ? "Remote Wakeup " : "",
config->MaxPower*2);
if (config->iConfiguration) {
printf(" - ");
usb_display_string(dev, config->iConfiguration);
@ -181,12 +202,15 @@ void usb_display_conf_desc(struct usb_config_descriptor *config,struct usb_devic
}
}
void usb_display_if_desc(struct usb_interface_descriptor *ifdesc,struct usb_device *dev)
void usb_display_if_desc(struct usb_interface_descriptor *ifdesc,
struct usb_device *dev)
{
printf(" Interface: %d\n", ifdesc->bInterfaceNumber);
printf(" - Alternate Setting %d, Endpoints: %d\n",ifdesc->bAlternateSetting,ifdesc->bNumEndpoints);
printf(" - Alternate Setting %d, Endpoints: %d\n",
ifdesc->bAlternateSetting, ifdesc->bNumEndpoints);
printf(" - Class ");
usb_display_class_sub(ifdesc->bInterfaceClass,ifdesc->bInterfaceSubClass,ifdesc->bInterfaceProtocol);
usb_display_class_sub(ifdesc->bInterfaceClass,
ifdesc->bInterfaceSubClass, ifdesc->bInterfaceProtocol);
printf("\n");
if (ifdesc->iInterface) {
printf(" - ");
@ -197,13 +221,21 @@ void usb_display_if_desc(struct usb_interface_descriptor *ifdesc,struct usb_devi
void usb_display_ep_desc(struct usb_endpoint_descriptor *epdesc)
{
printf(" - Endpoint %d %s ",epdesc->bEndpointAddress & 0xf,(epdesc->bEndpointAddress & 0x80) ? "In" : "Out");
switch((epdesc->bmAttributes & 0x03))
{
case 0: printf("Control"); break;
case 1: printf("Isochronous"); break;
case 2: printf("Bulk"); break;
case 3: printf("Interrupt"); break;
printf(" - Endpoint %d %s ", epdesc->bEndpointAddress & 0xf,
(epdesc->bEndpointAddress & 0x80) ? "In" : "Out");
switch ((epdesc->bmAttributes & 0x03)) {
case 0:
printf("Control");
break;
case 1:
printf("Isochronous");
break;
case 2:
printf("Bulk");
break;
case 3:
printf("Interrupt");
break;
}
printf(" MaxPacket %d", epdesc->wMaxPacketSize);
if ((epdesc->bmAttributes & 0x03) == 0x3)
@ -252,7 +284,9 @@ void usb_show_tree_graph(struct usb_device *dev,char *pre)
for (i = 0; i < dev->parent->maxchild; i++) {
/* search for children */
if (dev->parent->children[i] == dev) {
/* found our pointer, see if we have a little sister */
/* found our pointer, see if we have a
* little sister
*/
port = i;
while (i++ < dev->parent->maxchild) {
if (dev->parent->children[i] != NULL) {
@ -265,9 +299,8 @@ void usb_show_tree_graph(struct usb_device *dev,char *pre)
} /* for all children of the parent */
printf("\b+-");
/* correct last child */
if (last_child) {
if (last_child)
pre[index-1] = ' ';
}
} /* if not root hub */
else
printf(" ");
@ -275,11 +308,11 @@ void usb_show_tree_graph(struct usb_device *dev,char *pre)
pre[index++] = ' ';
pre[index++] = has_child ? '|' : ' ';
pre[index] = 0;
printf(" %s (%s, %dmA)\n",usb_get_class_desc(dev->config.if_desc[0].bInterfaceClass),
dev->slow ? "1.5MBit/s" : "12MBit/s",dev->config.MaxPower * 2);
if (strlen(dev->mf) ||
strlen(dev->prod) ||
strlen(dev->serial))
printf(" %s (%s, %dmA)\n", usb_get_class_desc(
dev->config.if_desc[0].bInterfaceClass),
dev->slow ? "1.5MBit/s" : "12MBit/s",
dev->config.MaxPower * 2);
if (strlen(dev->mf) || strlen(dev->prod) || strlen(dev->serial))
printf(" %s %s %s %s\n", pre, dev->mf, dev->prod, dev->serial);
printf(" %s\n", pre);
if (dev->maxchild > 0) {
@ -362,15 +395,18 @@ int do_usbboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
if (get_partition_info(stor_dev, part, &info)) {
/* try to boot raw .... */
strncpy((char *)&info.type[0], BOOT_PART_TYPE, sizeof(BOOT_PART_TYPE));
strncpy((char *)&info.type[0], BOOT_PART_TYPE,
sizeof(BOOT_PART_TYPE));
strncpy((char *)&info.name[0], "Raw", 4);
info.start = 0;
info.blksz = 0x200;
info.size = 2880;
printf("error reading partinfo...try to boot raw\n");
}
if ((strncmp((char *)info.type, BOOT_PART_TYPE, sizeof(info.type)) != 0) &&
(strncmp((char *)info.type, BOOT_PART_COMP, sizeof(info.type)) != 0)) {
if ((strncmp((char *)info.type, BOOT_PART_TYPE,
sizeof(info.type)) != 0) &&
(strncmp((char *)info.type, BOOT_PART_COMP,
sizeof(info.type)) != 0)) {
printf("\n** Invalid partition type \"%.32s\""
" (expect \"" BOOT_PART_TYPE "\")\n",
info.type);
@ -425,7 +461,9 @@ int do_usbboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
}
#if defined(CONFIG_FIT)
/* This cannot be done earlier, we need complete FIT image in RAM first */
/* This cannot be done earlier, we need complete FIT image in RAM
* first
*/
if (genimg_get_format((void *)addr) == IMAGE_FORMAT_FIT) {
if (!fit_check_format(fit_hdr)) {
puts("** Bad FIT image format\n");
@ -455,7 +493,7 @@ int do_usbboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
#endif /* CONFIG_USB_STORAGE */
/*********************************************************************************
/******************************************************************************
* usb command intepreter
*/
int do_usb(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
@ -484,11 +522,12 @@ int do_usb (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
#ifdef CONFIG_USB_KEYBOARD
if (argc == 2) {
if (usb_kbd_deregister() != 0) {
printf("USB not stopped: usbkbd still using USB\n");
printf("USB not stopped: usbkbd still"
" using USB\n");
return 1;
}
}
else { /* forced stop, switch console in to serial */
} else {
/* forced stop, switch console in to serial */
console_assign(stdin, "serial");
usb_kbd_deregister();
}
@ -517,8 +556,7 @@ int do_usb (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
usb_display_config(dev);
}
return 0;
}
else {
} else {
int d;
i = simple_strtoul(argv[2], NULL, 16);
@ -533,8 +571,7 @@ int do_usb (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
if (dev == NULL) {
printf("*** NO Device avaiable ***\n");
return 0;
}
else {
} else {
usb_display_desc(dev);
usb_display_config(dev);
}
@ -543,15 +580,16 @@ int do_usb (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
}
#ifdef CONFIG_USB_STORAGE
if (strncmp(argv[1], "scan", 4) == 0) {
printf(" NOTE: this command is obsolete and will be phased out\n");
printf(" please use 'usb storage' for USB storage devices information\n\n");
printf(" NOTE: this command is obsolete and will be"
" phased out\n");
printf(" please use 'usb storage' for USB storage devices"
" information\n\n");
usb_stor_info();
return 0;
}
if (strncmp(argv[1], "stor", 4) == 0) {
if (strncmp(argv[1], "stor", 4) == 0)
return usb_stor_info();
}
if (strncmp(argv[1], "part", 4) == 0) {
int devno, ok = 0;
@ -566,8 +604,7 @@ int do_usb (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
print_part(stor_dev);
}
}
}
else {
} else {
devno = simple_strtoul(argv[2], NULL, 16);
stor_dev = usb_stor_get_dev(devno);
if (stor_dev->type != DEV_TYPE_UNKNOWN) {
@ -592,11 +629,13 @@ int do_usb (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
unsigned long blk = simple_strtoul(argv[3], NULL, 16);
unsigned long cnt = simple_strtoul(argv[4], NULL, 16);
unsigned long n;
printf ("\nUSB read: device %d block # %ld, count %ld ... ",
usb_stor_curr_dev, blk, cnt);
printf("\nUSB read: device %d block # %ld, count %ld"
" ... ", usb_stor_curr_dev, blk, cnt);
stor_dev = usb_stor_get_dev(usb_stor_curr_dev);
n = stor_dev->block_read(usb_stor_curr_dev, blk, cnt, (ulong *)addr);
printf ("%ld blocks read: %s\n",n,(n==cnt) ? "OK" : "ERROR");
n = stor_dev->block_read(usb_stor_curr_dev, blk, cnt,
(ulong *)addr);
printf("%ld blocks read: %s\n", n,
(n == cnt) ? "OK" : "ERROR");
if (n == cnt)
return 0;
return 1;
@ -613,20 +652,17 @@ int do_usb (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
printf("\n Device %d: ", dev);
stor_dev = usb_stor_get_dev(dev);
dev_print(stor_dev);
if (stor_dev->type == DEV_TYPE_UNKNOWN) {
if (stor_dev->type == DEV_TYPE_UNKNOWN)
return 1;
}
usb_stor_curr_dev = dev;
printf("... is now current device\n");
return 0;
}
else {
} else {
printf("\nUSB device %d: ", usb_stor_curr_dev);
stor_dev = usb_stor_get_dev(usb_stor_curr_dev);
dev_print(stor_dev);
if (stor_dev->type == DEV_TYPE_UNKNOWN) {
if (stor_dev->type == DEV_TYPE_UNKNOWN)
return 1;
}
return 0;
}
return 0;
@ -646,7 +682,8 @@ U_BOOT_CMD(
"usb info [dev] - show available USB devices\n"
"usb storage - show details of USB storage devices\n"
"usb dev [dev] - show or set current USB storage device\n"
"usb part [dev] - print partition table of one or all USB storage devices\n"
"usb part [dev] - print partition table of one or all USB storage"
" devices\n"
"usb read addr blk# cnt - read `cnt' blocks starting at block `blk#'\n"
" to memory address `addr'\n"
);

View File

@ -87,11 +87,12 @@ static int hub_port_reset(struct usb_device *dev, int port,
* wait_ms
*/
void __inline__ wait_ms(unsigned long ms)
inline void wait_ms(unsigned long ms)
{
while (ms-- > 0)
udelay(1000);
}
/***************************************************************************
* Init USB Device
*/
@ -245,9 +246,9 @@ int usb_maxpacket(struct usb_device *dev, unsigned long pipe)
{
/* direction is out -> use emaxpacket out */
if ((pipe & USB_DIR_IN) == 0)
return(dev->epmaxpacketout[((pipe>>15) & 0xf)]);
return dev->epmaxpacketout[((pipe>>15) & 0xf)];
else
return(dev->epmaxpacketin[((pipe>>15) & 0xf)]);
return dev->epmaxpacketin[((pipe>>15) & 0xf)];
}
/* The routine usb_set_maxpacket_ep() is extracted from the loop of routine
@ -793,7 +794,8 @@ int usb_new_device(struct usb_device *dev)
* reset of the device (Linux uses the same sequence)
* Some equipment is said to work only with such init sequence; this
* patch is based on the work by Alan Stern:
* http://sourceforge.net/mailarchive/forum.php?thread_id=5729457&forum_id=5398
* http://sourceforge.net/mailarchive/forum.php?
* thread_id=5729457&forum_id=5398
*/
struct usb_device_descriptor *desc;
int port = -1;
@ -847,10 +849,18 @@ int usb_new_device(struct usb_device *dev)
dev->epmaxpacketin[0] = dev->descriptor.bMaxPacketSize0;
dev->epmaxpacketout[0] = dev->descriptor.bMaxPacketSize0;
switch (dev->descriptor.bMaxPacketSize0) {
case 8: dev->maxpacketsize = PACKET_SIZE_8; break;
case 16: dev->maxpacketsize = PACKET_SIZE_16; break;
case 32: dev->maxpacketsize = PACKET_SIZE_32; break;
case 64: dev->maxpacketsize = PACKET_SIZE_64; break;
case 8:
dev->maxpacketsize = PACKET_SIZE_8;
break;
case 16:
dev->maxpacketsize = PACKET_SIZE_16;
break;
case 32:
dev->maxpacketsize = PACKET_SIZE_32;
break;
case 64:
dev->maxpacketsize = PACKET_SIZE_64;
break;
}
dev->devnum = addr;

View File

@ -57,7 +57,6 @@ struct devrequest {
unsigned short length;
} __attribute__ ((packed));
/* All standard descriptors have these 2 fields in common */
struct usb_descriptor_header {
unsigned char bLength;
@ -82,7 +81,6 @@ struct usb_device_descriptor {
unsigned char bNumConfigurations;
} __attribute__ ((packed));
/* Endpoint descriptor */
struct usb_endpoint_descriptor {
unsigned char bLength;
@ -93,8 +91,8 @@ struct usb_endpoint_descriptor {
unsigned char bInterval;
unsigned char bRefresh;
unsigned char bSynchAddress;
} __attribute__ ((packed));
/* Interface descriptor */
struct usb_interface_descriptor {
unsigned char bLength;
@ -110,6 +108,7 @@ struct usb_interface_descriptor {
unsigned char no_of_ep;
unsigned char num_altsetting;
unsigned char act_altsetting;
struct usb_endpoint_descriptor ep_desc[USB_MAXENDPOINTS];
} __attribute__ ((packed));
@ -148,9 +147,10 @@ struct usb_device {
int maxpacketsize;
/* one bit for each endpoint ([0] = IN, [1] = OUT) */
unsigned int toggle[2];
/* endpoint halts; one bit per endpoint # & direction; */
/* endpoint halts; one bit per endpoint # & direction;
* [0] = IN, [1] = OUT
*/
unsigned int halted[2];
/* [0] = IN, [1] = OUT */
int epmaxpacketin[16]; /* INput endpoint specific maximums */
int epmaxpacketout[16]; /* OUTput endpoint specific maximums */
@ -185,7 +185,8 @@ struct usb_device {
int usb_lowlevel_init(void);
int usb_lowlevel_stop(void);
int submit_bulk_msg(struct usb_device *dev, unsigned long pipe, void *buffer,int transfer_len);
int submit_bulk_msg(struct usb_device *dev, unsigned long pipe,
void *buffer, int transfer_len);
int submit_control_msg(struct usb_device *dev, unsigned long pipe, void *buffer,
int transfer_len, struct devrequest *setup);
int submit_int_msg(struct usb_device *dev, unsigned long pipe, void *buffer,
@ -221,7 +222,8 @@ int usb_stop(void); /* stop the USB Controller */
int usb_set_protocol(struct usb_device *dev, int ifnum, int protocol);
int usb_set_idle(struct usb_device *dev, int ifnum, int duration, int report_id);
int usb_set_idle(struct usb_device *dev, int ifnum, int duration,
int report_id);
struct usb_device *usb_get_dev_index(int index);
int usb_control_msg(struct usb_device *dev, unsigned int pipe,
unsigned char request, unsigned char requesttype,
@ -233,11 +235,14 @@ int usb_submit_int_msg(struct usb_device *dev, unsigned long pipe,
void *buffer, int transfer_len, int interval);
void usb_disable_asynch(int disable);
int usb_maxpacket(struct usb_device *dev, unsigned long pipe);
void __inline__ wait_ms(unsigned long ms);
int usb_get_configuration_no(struct usb_device *dev,unsigned char *buffer,int cfgno);
int usb_get_report(struct usb_device *dev, int ifnum, unsigned char type, unsigned char id, void *buf, int size);
inline void wait_ms(unsigned long ms);
int usb_get_configuration_no(struct usb_device *dev, unsigned char *buffer,
int cfgno);
int usb_get_report(struct usb_device *dev, int ifnum, unsigned char type,
unsigned char id, void *buf, int size);
int usb_get_class_descriptor(struct usb_device *dev, int ifnum,
unsigned char type, unsigned char id, void *buf, int size);
unsigned char type, unsigned char id, void *buf,
int size);
int usb_clear_halt(struct usb_device *dev, int pipe);
int usb_string(struct usb_device *dev, int index, char *buf, size_t size);
int usb_set_interface(struct usb_device *dev, int interface, int alternate);
@ -286,12 +291,14 @@ int usb_set_interface(struct usb_device *dev, int interface, int alternate);
* unsigned int. The encoding is:
*
* - max size: bits 0-1 (00 = 8, 01 = 16, 10 = 32, 11 = 64)
* - direction: bit 7 (0 = Host-to-Device [Out], 1 = Device-to-Host [In])
* - direction: bit 7 (0 = Host-to-Device [Out],
* (1 = Device-to-Host [In])
* - device: bits 8-14
* - endpoint: bits 15-18
* - Data0/1: bit 19
* - speed: bit 26 (0 = Full, 1 = Low Speed)
* - pipe type: bits 30-31 (00 = isochronous, 01 = interrupt, 10 = control, 11 = bulk)
* - pipe type: bits 30-31 (00 = isochronous, 01 = interrupt,
* 10 = control, 11 = bulk)
*
* Why? Because it's arbitrary, and whatever encoding we select is really
* up to us. This one happens to share a lot of bit positions with the UHCI
@ -300,24 +307,42 @@ int usb_set_interface(struct usb_device *dev, int interface, int alternate);
*/
/* Create various pipes... */
#define create_pipe(dev,endpoint) \
(((dev)->devnum << 8) | (endpoint << 15) | ((dev)->slow << 26) | (dev)->maxpacketsize)
(((dev)->devnum << 8) | (endpoint << 15) | \
((dev)->slow << 26) | (dev)->maxpacketsize)
#define default_pipe(dev) ((dev)->slow << 26)
#define usb_sndctrlpipe(dev,endpoint) ((PIPE_CONTROL << 30) | create_pipe(dev,endpoint))
#define usb_rcvctrlpipe(dev,endpoint) ((PIPE_CONTROL << 30) | create_pipe(dev,endpoint) | USB_DIR_IN)
#define usb_sndisocpipe(dev,endpoint) ((PIPE_ISOCHRONOUS << 30) | create_pipe(dev,endpoint))
#define usb_rcvisocpipe(dev,endpoint) ((PIPE_ISOCHRONOUS << 30) | create_pipe(dev,endpoint) | USB_DIR_IN)
#define usb_sndbulkpipe(dev,endpoint) ((PIPE_BULK << 30) | create_pipe(dev,endpoint))
#define usb_rcvbulkpipe(dev,endpoint) ((PIPE_BULK << 30) | create_pipe(dev,endpoint) | USB_DIR_IN)
#define usb_sndintpipe(dev,endpoint) ((PIPE_INTERRUPT << 30) | create_pipe(dev,endpoint))
#define usb_rcvintpipe(dev,endpoint) ((PIPE_INTERRUPT << 30) | create_pipe(dev,endpoint) | USB_DIR_IN)
#define usb_snddefctrl(dev) ((PIPE_CONTROL << 30) | default_pipe(dev))
#define usb_rcvdefctrl(dev) ((PIPE_CONTROL << 30) | default_pipe(dev) | USB_DIR_IN)
#define usb_sndctrlpipe(dev, endpoint) ((PIPE_CONTROL << 30) | \
create_pipe(dev, endpoint))
#define usb_rcvctrlpipe(dev, endpoint) ((PIPE_CONTROL << 30) | \
create_pipe(dev, endpoint) | \
USB_DIR_IN)
#define usb_sndisocpipe(dev, endpoint) ((PIPE_ISOCHRONOUS << 30) | \
create_pipe(dev, endpoint))
#define usb_rcvisocpipe(dev, endpoint) ((PIPE_ISOCHRONOUS << 30) | \
create_pipe(dev, endpoint) | \
USB_DIR_IN)
#define usb_sndbulkpipe(dev, endpoint) ((PIPE_BULK << 30) | \
create_pipe(dev, endpoint))
#define usb_rcvbulkpipe(dev, endpoint) ((PIPE_BULK << 30) | \
create_pipe(dev, endpoint) | \
USB_DIR_IN)
#define usb_sndintpipe(dev, endpoint) ((PIPE_INTERRUPT << 30) | \
create_pipe(dev, endpoint))
#define usb_rcvintpipe(dev, endpoint) ((PIPE_INTERRUPT << 30) | \
create_pipe(dev, endpoint) | \
USB_DIR_IN)
#define usb_snddefctrl(dev) ((PIPE_CONTROL << 30) | \
default_pipe(dev))
#define usb_rcvdefctrl(dev) ((PIPE_CONTROL << 30) | \
default_pipe(dev) | \
USB_DIR_IN)
/* The D0/D1 toggle bits */
#define usb_gettoggle(dev, ep, out) (((dev)->toggle[out] >> ep) & 1)
#define usb_dotoggle(dev, ep, out) ((dev)->toggle[out] ^= (1 << ep))
#define usb_settoggle(dev, ep, out, bit) ((dev)->toggle[out] = ((dev)->toggle[out] & ~(1 << ep)) | ((bit) << ep))
#define usb_settoggle(dev, ep, out, bit) ((dev)->toggle[out] = \
((dev)->toggle[out] & \
~(1 << ep)) | ((bit) << ep))
/* Endpoint halt control/status */
#define usb_endpoint_out(ep_dir) (((ep_dir >> 7) & 1) ^ 1)
@ -325,7 +350,8 @@ int usb_set_interface(struct usb_device *dev, int interface, int alternate);
#define usb_endpoint_running(dev, ep, out) ((dev)->halted[out] &= ~(1 << (ep)))
#define usb_endpoint_halted(dev, ep, out) ((dev)->halted[out] & (1 << (ep)))
#define usb_packetid(pipe) (((pipe) & USB_DIR_IN) ? USB_PID_IN : USB_PID_OUT)
#define usb_packetid(pipe) (((pipe) & USB_DIR_IN) ? USB_PID_IN : \
USB_PID_OUT)
#define usb_pipeout(pipe) ((((pipe) >> 7) & 1) ^ 1)
#define usb_pipein(pipe) (((pipe) >> 7) & 1)