ChangeSet 1.850.1.4, 2002/10/29 23:43:32-08:00, david-b@pacbell.net [PATCH] USB: clean up usb structures some more This patch splits up the usb structures to have two structs, "usb_XXX_descriptor" with just the descriptor, and "usb_host_XXX" (or something similar) to wrap it and add the "extra" pointers plus the array of related descriptors that the host parsed during enumeration. (2 or 3 words extra in each"usb_host_XXX".) This further matches the "on the wire" data and enables the gadget drivers to share the same header file. Covers all the linux/drivers/usb/* and linux/sound/usb/* stuff, but not a handful of other drivers (bluetooth, iforce, hisax, irda) that are out of the usb tree and will likely be affected. diff -Nru a/drivers/usb/class/audio.c b/drivers/usb/class/audio.c --- a/drivers/usb/class/audio.c Wed Oct 30 09:44:00 2002 +++ b/drivers/usb/class/audio.c Wed Oct 30 09:44:00 2002 @@ -1512,8 +1512,8 @@ static int set_format_in(struct usb_audiodev *as) { struct usb_device *dev = as->state->usbdev; - struct usb_config_descriptor *config = dev->actconfig; - struct usb_interface_descriptor *alts; + struct usb_host_config *config = dev->actconfig; + struct usb_host_interface *alts; struct usb_interface *iface; struct usbin *u = &as->usbin; struct dmabuf *d = &u->dma; @@ -1522,7 +1522,7 @@ unsigned char data[3]; int fmtnr, ret; - if (u->interface < 0 || u->interface >= config->bNumInterfaces) + if (u->interface < 0 || u->interface >= config->desc.bNumInterfaces) return 0; iface = &config->interface[u->interface]; @@ -1535,26 +1535,26 @@ fmt = as->fmtin + fmtnr; alts = &iface->altsetting[fmt->altsetting]; u->format = fmt->format; - u->datapipe = usb_rcvisocpipe(dev, alts->endpoint[0].bEndpointAddress & 0xf); + u->datapipe = usb_rcvisocpipe(dev, alts->endpoint[0].desc.bEndpointAddress & 0xf); u->syncpipe = u->syncinterval = 0; - if ((alts->endpoint[0].bmAttributes & 0x0c) == 0x08) { - if (alts->bNumEndpoints < 2 || - alts->endpoint[1].bmAttributes != 0x01 || - alts->endpoint[1].bSynchAddress != 0 || - alts->endpoint[1].bEndpointAddress != (alts->endpoint[0].bSynchAddress & 0x7f)) { + if ((alts->endpoint[0].desc.bmAttributes & 0x0c) == 0x08) { + if (alts->desc.bNumEndpoints < 2 || + alts->endpoint[1].desc.bmAttributes != 0x01 || + alts->endpoint[1].desc.bSynchAddress != 0 || + alts->endpoint[1].desc.bEndpointAddress != (alts->endpoint[0].desc.bSynchAddress & 0x7f)) { printk(KERN_ERR "usbaudio: device %d interface %d altsetting %d invalid synch pipe\n", dev->devnum, u->interface, fmt->altsetting); return -1; } - u->syncpipe = usb_sndisocpipe(dev, alts->endpoint[1].bEndpointAddress & 0xf); - u->syncinterval = alts->endpoint[1].bRefresh; + u->syncpipe = usb_sndisocpipe(dev, alts->endpoint[1].desc.bEndpointAddress & 0xf); + u->syncinterval = alts->endpoint[1].desc.bRefresh; } if (d->srate < fmt->sratelo) d->srate = fmt->sratelo; if (d->srate > fmt->sratehi) d->srate = fmt->sratehi; - dprintk((KERN_DEBUG "usbaudio: set_format_in: usb_set_interface %u %u\n", alts->bInterfaceNumber, fmt->altsetting)); - if (usb_set_interface(dev, alts->bInterfaceNumber, fmt->altsetting) < 0) { + dprintk((KERN_DEBUG "usbaudio: set_format_in: usb_set_interface %u %u\n", alts->desc.bInterfaceNumber, fmt->altsetting)); + if (usb_set_interface(dev, alts->desc.bInterfaceNumber, fmt->altsetting) < 0) { printk(KERN_WARNING "usbaudio: usb_set_interface failed, device %d interface %d altsetting %d\n", dev->devnum, u->interface, fmt->altsetting); return -1; @@ -1600,8 +1600,8 @@ static int set_format_out(struct usb_audiodev *as) { struct usb_device *dev = as->state->usbdev; - struct usb_config_descriptor *config = dev->actconfig; - struct usb_interface_descriptor *alts; + struct usb_host_config *config = dev->actconfig; + struct usb_host_interface *alts; struct usb_interface *iface; struct usbout *u = &as->usbout; struct dmabuf *d = &u->dma; @@ -1610,7 +1610,7 @@ unsigned char data[3]; int fmtnr, ret; - if (u->interface < 0 || u->interface >= config->bNumInterfaces) + if (u->interface < 0 || u->interface >= config->desc.bNumInterfaces) return 0; iface = &config->interface[u->interface]; @@ -1623,9 +1623,9 @@ fmt = as->fmtout + fmtnr; u->format = fmt->format; alts = &iface->altsetting[fmt->altsetting]; - u->datapipe = usb_sndisocpipe(dev, alts->endpoint[0].bEndpointAddress & 0xf); + u->datapipe = usb_sndisocpipe(dev, alts->endpoint[0].desc.bEndpointAddress & 0xf); u->syncpipe = u->syncinterval = 0; - if ((alts->endpoint[0].bmAttributes & 0x0c) == 0x04) { + if ((alts->endpoint[0].desc.bmAttributes & 0x0c) == 0x04) { #if 0 printk(KERN_DEBUG "bNumEndpoints 0x%02x endpoint[1].bmAttributes 0x%02x\n" KERN_DEBUG "endpoint[1].bSynchAddress 0x%02x endpoint[1].bEndpointAddress 0x%02x\n" @@ -1633,22 +1633,22 @@ alts->endpoint[1].bmAttributes, alts->endpoint[1].bSynchAddress, alts->endpoint[1].bEndpointAddress, alts->endpoint[0].bSynchAddress); #endif - if (alts->bNumEndpoints < 2 || - alts->endpoint[1].bmAttributes != 0x01 || - alts->endpoint[1].bSynchAddress != 0 || - alts->endpoint[1].bEndpointAddress != (alts->endpoint[0].bSynchAddress | 0x80)) { + if (alts->desc.bNumEndpoints < 2 || + alts->endpoint[1].desc.bmAttributes != 0x01 || + alts->endpoint[1].desc.bSynchAddress != 0 || + alts->endpoint[1].desc.bEndpointAddress != (alts->endpoint[0].desc.bSynchAddress | 0x80)) { printk(KERN_ERR "usbaudio: device %d interface %d altsetting %d invalid synch pipe\n", dev->devnum, u->interface, fmt->altsetting); return -1; } - u->syncpipe = usb_rcvisocpipe(dev, alts->endpoint[1].bEndpointAddress & 0xf); - u->syncinterval = alts->endpoint[1].bRefresh; + u->syncpipe = usb_rcvisocpipe(dev, alts->endpoint[1].desc.bEndpointAddress & 0xf); + u->syncinterval = alts->endpoint[1].desc.bRefresh; } if (d->srate < fmt->sratelo) d->srate = fmt->sratelo; if (d->srate > fmt->sratehi) d->srate = fmt->sratehi; - dprintk((KERN_DEBUG "usbaudio: set_format_out: usb_set_interface %u %u\n", alts->bInterfaceNumber, fmt->altsetting)); + dprintk((KERN_DEBUG "usbaudio: set_format_out: usb_set_interface %u %u\n", alts->desc.bInterfaceNumber, fmt->altsetting)); if (usb_set_interface(dev, u->interface, fmt->altsetting) < 0) { printk(KERN_WARNING "usbaudio: usb_set_interface failed, device %d interface %d altsetting %d\n", dev->devnum, u->interface, fmt->altsetting); @@ -2705,7 +2705,7 @@ usbout_stop(as); if (dev && as->usbout.interface >= 0) { iface = &dev->actconfig->interface[as->usbout.interface]; - usb_set_interface(dev, iface->altsetting->bInterfaceNumber, 0); + usb_set_interface(dev, iface->altsetting->desc.bInterfaceNumber, 0); } dmabuf_release(&as->usbout.dma); usbout_release(as); @@ -2714,7 +2714,7 @@ usbin_stop(as); if (dev && as->usbin.interface >= 0) { iface = &dev->actconfig->interface[as->usbin.interface]; - usb_set_interface(dev, iface->altsetting->bInterfaceNumber, 0); + usb_set_interface(dev, iface->altsetting->desc.bInterfaceNumber, 0); } dmabuf_release(&as->usbin.dma); usbin_release(as); @@ -2819,8 +2819,8 @@ { struct usb_device *dev = s->usbdev; struct usb_audiodev *as; - struct usb_config_descriptor *config = dev->actconfig; - struct usb_interface_descriptor *alts; + struct usb_host_config *config = dev->actconfig; + struct usb_host_interface *alts; struct usb_interface *iface; struct audioformat *fp; unsigned char *fmt, *csep; @@ -2868,17 +2868,17 @@ iface = &config->interface[asifin]; for (i = 0; i < iface->num_altsetting; i++) { alts = &iface->altsetting[i]; - if (alts->bInterfaceClass != USB_CLASS_AUDIO || alts->bInterfaceSubClass != 2) + if (alts->desc.bInterfaceClass != USB_CLASS_AUDIO || alts->desc.bInterfaceSubClass != 2) continue; - if (alts->bNumEndpoints < 1) { + if (alts->desc.bNumEndpoints < 1) { if (i != 0) { /* altsetting 0 has no endpoints (Section B.3.4.1) */ printk(KERN_ERR "usbaudio: device %u interface %u altsetting %u does not have an endpoint\n", dev->devnum, asifin, i); } continue; } - if ((alts->endpoint[0].bmAttributes & 0x03) != 0x01 || - !(alts->endpoint[0].bEndpointAddress & 0x80)) { + if ((alts->endpoint[0].desc.bmAttributes & 0x03) != 0x01 || + !(alts->endpoint[0].desc.bEndpointAddress & 0x80)) { printk(KERN_ERR "usbaudio: device %u interface %u altsetting %u first endpoint not isochronous in\n", dev->devnum, asifin, i); continue; @@ -2949,15 +2949,15 @@ iface = &config->interface[asifout]; for (i = 0; i < iface->num_altsetting; i++) { alts = &iface->altsetting[i]; - if (alts->bInterfaceClass != USB_CLASS_AUDIO || alts->bInterfaceSubClass != 2) + if (alts->desc.bInterfaceClass != USB_CLASS_AUDIO || alts->desc.bInterfaceSubClass != 2) continue; - if (alts->bNumEndpoints < 1) { + if (alts->desc.bNumEndpoints < 1) { printk(KERN_ERR "usbaudio: device %u interface %u altsetting %u does not have an endpoint\n", dev->devnum, asifout, i); continue; } - if ((alts->endpoint[0].bmAttributes & 0x03) != 0x01 || - (alts->endpoint[0].bEndpointAddress & 0x80)) { + if ((alts->endpoint[0].desc.bmAttributes & 0x03) != 0x01 || + (alts->endpoint[0].desc.bEndpointAddress & 0x80)) { printk(KERN_ERR "usbaudio: device %u interface %u altsetting %u first endpoint not isochronous out\n", dev->devnum, asifout, i); continue; @@ -3642,10 +3642,13 @@ list_add_tail(&ms->list, &s->mixerlist); } +/* arbitrary limit, we won't check more interfaces than this */ +#define USB_MAXINTERFACES 32 + static struct usb_audio_state *usb_audio_parsecontrol(struct usb_device *dev, unsigned char *buffer, unsigned int buflen, unsigned int ctrlif) { struct usb_audio_state *s; - struct usb_config_descriptor *config = dev->actconfig; + struct usb_host_config *config = dev->actconfig; struct usb_interface *iface; unsigned char ifin[USB_MAXINTERFACES], ifout[USB_MAXINTERFACES]; unsigned char *p1; @@ -3675,23 +3678,23 @@ dev->devnum, ctrlif); for (i = 0; i < p1[7]; i++) { j = p1[8+i]; - if (j >= config->bNumInterfaces) { + if (j >= config->desc.bNumInterfaces) { printk(KERN_ERR "usbaudio: device %d audiocontrol interface %u interface %u does not exist\n", dev->devnum, ctrlif, j); continue; } iface = &config->interface[j]; - if (iface->altsetting[0].bInterfaceClass != USB_CLASS_AUDIO) { + if (iface->altsetting[0].desc.bInterfaceClass != USB_CLASS_AUDIO) { printk(KERN_ERR "usbaudio: device %d audiocontrol interface %u interface %u is not an AudioClass interface\n", dev->devnum, ctrlif, j); continue; } - if (iface->altsetting[0].bInterfaceSubClass == 3) { + if (iface->altsetting[0].desc.bInterfaceSubClass == 3) { printk(KERN_INFO "usbaudio: device %d audiocontrol interface %u interface %u MIDIStreaming not supported\n", dev->devnum, ctrlif, j); continue; } - if (iface->altsetting[0].bInterfaceSubClass != 2) { + if (iface->altsetting[0].desc.bInterfaceSubClass != 2) { printk(KERN_ERR "usbaudio: device %d audiocontrol interface %u interface %u invalid AudioClass subtype\n", dev->devnum, ctrlif, j); continue; @@ -3704,25 +3707,25 @@ printk(KERN_ERR "usbaudio: device %d audiocontrol interface %u has only 1 altsetting.\n", dev->devnum, ctrlif); continue; } - if (iface->altsetting[0].bNumEndpoints > 0) { + if (iface->altsetting[0].desc.bNumEndpoints > 0) { /* Check all endpoints; should they all have a bandwidth of 0 ? */ - for (k = 0; k < iface->altsetting[0].bNumEndpoints; k++) { - if (iface->altsetting[0].endpoint[k].wMaxPacketSize > 0) { + for (k = 0; k < iface->altsetting[0].desc.bNumEndpoints; k++) { + if (iface->altsetting[0].endpoint[k].desc.wMaxPacketSize > 0) { printk(KERN_ERR "usbaudio: device %d audiocontrol interface %u endpoint %d does not have 0 bandwidth at alt[0]\n", dev->devnum, ctrlif, k); break; } } - if (k < iface->altsetting[0].bNumEndpoints) + if (k < iface->altsetting[0].desc.bNumEndpoints) continue; } - if (iface->altsetting[1].bNumEndpoints < 1) { + if (iface->altsetting[1].desc.bNumEndpoints < 1) { printk(KERN_ERR "usbaudio: device %d audiocontrol interface %u interface %u has no endpoint\n", dev->devnum, ctrlif, j); continue; } /* note: this requires the data endpoint to be ep0 and the optional sync ep to be ep1, which seems to be the case */ - if (iface->altsetting[1].endpoint[0].bEndpointAddress & USB_DIR_IN) { + if (iface->altsetting[1].endpoint[0].desc.bEndpointAddress & USB_DIR_IN) { if (numifin < USB_MAXINTERFACES) { ifin[numifin++] = j; usb_driver_claim_interface(&usb_audio_driver, iface, (void *)-1); @@ -3769,7 +3772,7 @@ const struct usb_device_id *id) { struct usb_device *dev = interface_to_usbdev (intf); - struct usb_config_descriptor *config = dev->actconfig; + struct usb_host_config *config = dev->actconfig; struct usb_audio_state *s; unsigned char *buffer; unsigned char buf[8]; @@ -3778,8 +3781,8 @@ #if 0 printk(KERN_DEBUG "usbaudio: Probing if %i: IC %x, ISC %x\n", ifnum, - config->interface[ifnum].altsetting[0].bInterfaceClass, - config->interface[ifnum].altsetting[0].bInterfaceSubClass); + config->interface[ifnum].altsetting[0].desc.bInterfaceClass, + config->interface[ifnum].altsetting[0].desc.bInterfaceSubClass); #endif /* @@ -3788,8 +3791,8 @@ */ i = dev->actconfig - config; - if (usb_set_configuration(dev, config->bConfigurationValue) < 0) { - printk(KERN_ERR "usbaudio: set_configuration failed (ConfigValue 0x%x)\n", config->bConfigurationValue); + if (usb_set_configuration(dev, config->desc.bConfigurationValue) < 0) { + printk(KERN_ERR "usbaudio: set_configuration failed (ConfigValue 0x%x)\n", config->desc.bConfigurationValue); return -EIO; } ret = usb_get_descriptor(dev, USB_DT_CONFIG, i, buf, 8); @@ -3810,7 +3813,7 @@ printk(KERN_ERR "usbaudio: cannot get config descriptor %d of device %d (error %d)\n", i, dev->devnum, ret); return -EIO; } - s = usb_audio_parsecontrol(dev, buffer, buflen, intf->altsetting->bInterfaceNumber); + s = usb_audio_parsecontrol(dev, buffer, buflen, intf->altsetting->desc.bInterfaceNumber); if (s) { dev_set_drvdata (&intf->dev, s); return 0; diff -Nru a/drivers/usb/class/bluetty.c b/drivers/usb/class/bluetty.c --- a/drivers/usb/class/bluetty.c Wed Oct 30 09:43:59 2002 +++ b/drivers/usb/class/bluetty.c Wed Oct 30 09:43:59 2002 @@ -1053,7 +1053,7 @@ { struct usb_device *dev = interface_to_usbdev (intf); struct usb_bluetooth *bluetooth = NULL; - struct usb_interface_descriptor *interface; + struct usb_host_interface *interface; struct usb_endpoint_descriptor *endpoint; struct usb_endpoint_descriptor *interrupt_in_endpoint[8]; struct usb_endpoint_descriptor *bulk_in_endpoint[8]; @@ -1068,11 +1068,11 @@ int num_bulk_out = 0; interface = &intf->altsetting[0]; - control_out_endpoint = interface->bInterfaceNumber; + control_out_endpoint = interface->desc.bInterfaceNumber; /* find the endpoints that we need */ - for (i = 0; i < interface->bNumEndpoints; ++i) { - endpoint = &interface->endpoint[i]; + for (i = 0; i < interface->desc.bNumEndpoints; ++i) { + endpoint = &interface->endpoint[i].desc; if ((endpoint->bEndpointAddress & 0x80) && ((endpoint->bmAttributes & 3) == 0x02)) { diff -Nru a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c --- a/drivers/usb/class/cdc-acm.c Wed Oct 30 09:44:00 2002 +++ b/drivers/usb/class/cdc-acm.c Wed Oct 30 09:44:00 2002 @@ -166,7 +166,9 @@ static int acm_ctrl_msg(struct acm *acm, int request, int value, void *buf, int len) { int retval = usb_control_msg(acm->dev, usb_sndctrlpipe(acm->dev, 0), - request, USB_RT_ACM, value, acm->iface[0].altsetting[0].bInterfaceNumber, buf, len, HZ * 5); + request, USB_RT_ACM, value, + acm->iface[0].altsetting[0].desc.bInterfaceNumber, + buf, len, HZ * 5); dbg("acm_control_msg: rq: 0x%02x val: %#x len: %#x result: %d", request, value, len, retval); return retval < 0 ? retval : 0; } @@ -528,8 +530,8 @@ { struct usb_device *dev; struct acm *acm; - struct usb_config_descriptor *cfacm; - struct usb_interface_descriptor *ifcom, *ifdata; + struct usb_host_config *cfacm; + struct usb_host_interface *ifcom, *ifdata; struct usb_endpoint_descriptor *epctrl, *epread, *epwrite; int readsize, ctrlsize, minor, i; unsigned char *buf; @@ -541,7 +543,7 @@ dbg("probing config %d", cfacm->bConfigurationValue); - if (cfacm->bNumInterfaces != 2 || + if (cfacm->desc.bNumInterfaces != 2 || usb_interface_claimed(cfacm->interface + 0) || usb_interface_claimed(cfacm->interface + 1)) continue; @@ -549,20 +551,20 @@ ifcom = cfacm->interface[0].altsetting + 0; ifdata = cfacm->interface[1].altsetting + 0; - if (ifdata->bInterfaceClass != 10 || ifdata->bNumEndpoints < 2) { + if (ifdata->desc.bInterfaceClass != 10 || ifdata->desc.bNumEndpoints < 2) { ifcom = cfacm->interface[1].altsetting + 0; ifdata = cfacm->interface[0].altsetting + 0; - if (ifdata->bInterfaceClass != 10 || ifdata->bNumEndpoints < 2) + if (ifdata->desc.bInterfaceClass != 10 || ifdata->desc.bNumEndpoints < 2) continue; } - if (ifcom->bInterfaceClass != 2 || ifcom->bInterfaceSubClass != 2 || - ifcom->bInterfaceProtocol != 1 || ifcom->bNumEndpoints < 1) + if (ifcom->desc.bInterfaceClass != 2 || ifcom->desc.bInterfaceSubClass != 2 || + ifcom->desc.bInterfaceProtocol != 1 || ifcom->desc.bNumEndpoints < 1) continue; - epctrl = ifcom->endpoint + 0; - epread = ifdata->endpoint + 0; - epwrite = ifdata->endpoint + 1; + epctrl = &ifcom->endpoint[0].desc; + epread = &ifdata->endpoint[0].desc; + epwrite = &ifdata->endpoint[1].desc; if ((epctrl->bEndpointAddress & 0x80) != 0x80 || (epctrl->bmAttributes & 3) != 3 || (epread->bmAttributes & 3) != 2 || (epwrite->bmAttributes & 3) != 2 || @@ -570,11 +572,11 @@ continue; if ((epread->bEndpointAddress & 0x80) != 0x80) { - epread = ifdata->endpoint + 1; - epwrite = ifdata->endpoint + 0; + epread = &ifdata->endpoint[1].desc; + epwrite = &ifdata->endpoint[0].desc; } - usb_set_configuration(dev, cfacm->bConfigurationValue); + usb_set_configuration(dev, cfacm->desc.bConfigurationValue); for (minor = 0; minor < ACM_TTY_MINORS && acm_table[minor]; minor++); if (acm_table[minor]) { diff -Nru a/drivers/usb/class/usb-midi.c b/drivers/usb/class/usb-midi.c --- a/drivers/usb/class/usb-midi.c Wed Oct 30 09:43:59 2002 +++ b/drivers/usb/class/usb-midi.c Wed Oct 30 09:43:59 2002 @@ -1519,7 +1519,7 @@ static int get_alt_setting( struct usb_device *d, int ifnum ) { int alts, alt=0; - struct usb_interface_descriptor *interface; + struct usb_host_interface *interface; struct usb_endpoint_descriptor *ep; int epin, epout; int i; @@ -1531,8 +1531,8 @@ epin = -1; epout = -1; - for ( i=0 ; ibNumEndpoints ; i++ ) { - ep = &interface->endpoint[i]; + for ( i=0 ; idesc.bNumEndpoints ; i++ ) { + ep = &interface->endpoint[i].desc; if ( (ep->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) != USB_ENDPOINT_XFER_BULK ) { continue; } @@ -1778,8 +1778,8 @@ static int detect_yamaha_device( struct usb_device *d, unsigned int ifnum, struct usb_midi_state *s) { - struct usb_config_descriptor *c = d->actconfig; - struct usb_interface_descriptor *interface; + struct usb_host_config *c = d->actconfig; + struct usb_host_interface *interface; struct usb_midi_device *u; unsigned char buf[USB_DT_CONFIG_SIZE], *buffer; int bufSize; @@ -1794,8 +1794,8 @@ for ( i=0 ; i < c->interface[ifnum].num_altsetting; i++ ) { interface = c->interface[ifnum].altsetting + i; - if ( interface->bInterfaceClass != 255 || - interface->bInterfaceSubClass != 0 ) + if ( interface->desc.bInterfaceClass != 255 || + interface->desc.bInterfaceSubClass != 0 ) continue; alts = i; } @@ -1817,7 +1817,7 @@ configfound: /* this may not be necessary. */ - if ( usb_set_configuration( d, c->bConfigurationValue ) < 0 ) { + if ( usb_set_configuration( d, c->desc.bConfigurationValue ) < 0 ) { printk(KERN_INFO "usb-midi: Could not set config.\n"); return -EINVAL; } @@ -1892,8 +1892,8 @@ **/ static int detect_midi_subclass(struct usb_device *d, unsigned int ifnum, struct usb_midi_state *s) { - struct usb_config_descriptor *c = d->actconfig; - struct usb_interface_descriptor *interface; + struct usb_host_config *c = d->actconfig; + struct usb_host_interface *interface; struct usb_midi_device *u; unsigned char buf[USB_DT_CONFIG_SIZE], *buffer; int bufSize; @@ -1904,8 +1904,8 @@ for ( i=0 ; i < c->interface[ifnum].num_altsetting; i++ ) { interface = c->interface[ifnum].altsetting + i; - if ( interface->bInterfaceClass != USB_CLASS_AUDIO || - interface->bInterfaceSubClass != USB_SUBCLASS_MIDISTREAMING ) + if ( interface->desc.bInterfaceClass != USB_CLASS_AUDIO || + interface->desc.bInterfaceSubClass != USB_SUBCLASS_MIDISTREAMING ) continue; alts = i; } @@ -1927,7 +1927,7 @@ configfound: /* this may not be necessary. */ - if ( usb_set_configuration( d, c->bConfigurationValue ) < 0 ) { + if ( usb_set_configuration( d, c->desc.bConfigurationValue ) < 0 ) { printk(KERN_INFO "usb-midi: Could not set config.\n"); return -EINVAL; } @@ -2025,7 +2025,7 @@ { struct usb_midi_state *s; struct usb_device *dev = interface_to_usbdev(intf); - int ifnum = intf->altsetting->bInterfaceNumber; + int ifnum = intf->altsetting->desc.bInterfaceNumber; s = (struct usb_midi_state *)kmalloc(sizeof(struct usb_midi_state), GFP_KERNEL); if ( !s ) diff -Nru a/drivers/usb/class/usblp.c b/drivers/usb/class/usblp.c --- a/drivers/usb/class/usblp.c Wed Oct 30 09:43:59 2002 +++ b/drivers/usb/class/usblp.c Wed Oct 30 09:43:59 2002 @@ -814,7 +814,7 @@ usblp->dev = dev; init_MUTEX (&usblp->sem); init_waitqueue_head(&usblp->wait); - usblp->ifnum = intf->altsetting->bInterfaceNumber; + usblp->ifnum = intf->altsetting->desc.bInterfaceNumber; retval = usb_register_dev(&usblp_fops, USBLP_MINOR_BASE, 1, &usblp->minor); if (retval) { @@ -931,7 +931,7 @@ static int usblp_select_alts(struct usblp *usblp) { struct usb_interface *if_alt; - struct usb_interface_descriptor *ifd; + struct usb_host_interface *ifd; struct usb_endpoint_descriptor *epd, *epwrite, *epread; int p, i, e; @@ -944,17 +944,17 @@ for (i = 0; i < if_alt->num_altsetting; i++) { ifd = &if_alt->altsetting[i]; - if (ifd->bInterfaceClass != 7 || ifd->bInterfaceSubClass != 1) + if (ifd->desc.bInterfaceClass != 7 || ifd->desc.bInterfaceSubClass != 1) continue; - if (ifd->bInterfaceProtocol < USBLP_FIRST_PROTOCOL || - ifd->bInterfaceProtocol > USBLP_LAST_PROTOCOL) + if (ifd->desc.bInterfaceProtocol < USBLP_FIRST_PROTOCOL || + ifd->desc.bInterfaceProtocol > USBLP_LAST_PROTOCOL) continue; /* Look for bulk OUT and IN endpoints. */ epwrite = epread = 0; - for (e = 0; e < ifd->bNumEndpoints; e++) { - epd = &ifd->endpoint[e]; + for (e = 0; e < ifd->desc.bNumEndpoints; e++) { + epd = &ifd->endpoint[e].desc; if ((epd->bmAttributes&USB_ENDPOINT_XFERTYPE_MASK)!= USB_ENDPOINT_XFER_BULK) @@ -969,12 +969,12 @@ } /* Ignore buggy hardware without the right endpoints. */ - if (!epwrite || (ifd->bInterfaceProtocol > 1 && !epread)) + if (!epwrite || (ifd->desc.bInterfaceProtocol > 1 && !epread)) continue; /* Turn off reads for 7/1/1 (unidirectional) interfaces * and buggy bidirectional printers. */ - if (ifd->bInterfaceProtocol == 1) { + if (ifd->desc.bInterfaceProtocol == 1) { epread = NULL; } else if (usblp->quirks & USBLP_QUIRK_BIDIR) { info("Disabling reads from problem bidirectional " @@ -982,9 +982,9 @@ epread = NULL; } - usblp->protocol[ifd->bInterfaceProtocol].alt_setting = i; - usblp->protocol[ifd->bInterfaceProtocol].epwrite = epwrite; - usblp->protocol[ifd->bInterfaceProtocol].epread = epread; + usblp->protocol[ifd->desc.bInterfaceProtocol].alt_setting = i; + usblp->protocol[ifd->desc.bInterfaceProtocol].epwrite = epwrite; + usblp->protocol[ifd->desc.bInterfaceProtocol].epread = epread; } /* If our requested protocol is supported, then use it. */ diff -Nru a/drivers/usb/core/config.c b/drivers/usb/core/config.c --- a/drivers/usb/core/config.c Wed Oct 30 09:43:59 2002 +++ b/drivers/usb/core/config.c Wed Oct 30 09:43:59 2002 @@ -4,7 +4,16 @@ #include #include -static int usb_parse_endpoint(struct usb_endpoint_descriptor *endpoint, unsigned char *buffer, int size) + +#define USB_MAXALTSETTING 128 /* Hard limit */ +#define USB_MAXENDPOINTS 30 /* Hard limit */ + +/* these maximums are arbitrary */ +#define USB_MAXCONFIG 8 +#define USB_ALTSETTINGALLOC 4 +#define USB_MAXINTERFACES 32 + +static int usb_parse_endpoint(struct usb_host_endpoint *endpoint, unsigned char *buffer, int size) { struct usb_descriptor_header *header; unsigned char *begin; @@ -20,17 +29,17 @@ } if (header->bDescriptorType != USB_DT_ENDPOINT) { - warn("unexpected descriptor 0x%X, expecting endpoint descriptor, type 0x%X", - endpoint->bDescriptorType, USB_DT_ENDPOINT); + warn("unexpected descriptor 0x%X, expecting endpoint, 0x%X", + header->bDescriptorType, USB_DT_ENDPOINT); return parsed; } if (header->bLength == USB_DT_ENDPOINT_AUDIO_SIZE) - memcpy(endpoint, buffer, USB_DT_ENDPOINT_AUDIO_SIZE); + memcpy(&endpoint->desc, buffer, USB_DT_ENDPOINT_AUDIO_SIZE); else - memcpy(endpoint, buffer, USB_DT_ENDPOINT_SIZE); + memcpy(&endpoint->desc, buffer, USB_DT_ENDPOINT_SIZE); - le16_to_cpus(&endpoint->wMaxPacketSize); + le16_to_cpus(&endpoint->desc.wMaxPacketSize); buffer += header->bLength; size -= header->bLength; @@ -93,7 +102,7 @@ { int i, len, numskipped, retval, parsed = 0; struct usb_descriptor_header *header; - struct usb_interface_descriptor *ifp; + struct usb_host_interface *ifp; unsigned char *begin; interface->act_altsetting = 0; @@ -108,6 +117,8 @@ } while (size > 0) { + struct usb_interface_descriptor *d; + if (interface->num_altsetting >= interface->max_altsetting) { void *ptr; int oldmas; @@ -141,9 +152,9 @@ memcpy(ifp, buffer, USB_DT_INTERFACE_SIZE); /* Skip over the interface */ - buffer += ifp->bLength; - parsed += ifp->bLength; - size -= ifp->bLength; + buffer += ifp->desc.bLength; + parsed += ifp->desc.bLength; + size -= ifp->desc.bLength; begin = buffer; numskipped = 0; @@ -196,23 +207,23 @@ (header->bDescriptorType == USB_DT_DEVICE))) return parsed; - if (ifp->bNumEndpoints > USB_MAXENDPOINTS) { + if (ifp->desc.bNumEndpoints > USB_MAXENDPOINTS) { warn("too many endpoints"); return -1; } - ifp->endpoint = (struct usb_endpoint_descriptor *) - kmalloc(ifp->bNumEndpoints * - sizeof(struct usb_endpoint_descriptor), GFP_KERNEL); + ifp->endpoint = (struct usb_host_endpoint *) + kmalloc(ifp->desc.bNumEndpoints * + sizeof(struct usb_host_endpoint), GFP_KERNEL); if (!ifp->endpoint) { err("out of memory"); return -1; } - memset(ifp->endpoint, 0, ifp->bNumEndpoints * - sizeof(struct usb_endpoint_descriptor)); + memset(ifp->endpoint, 0, ifp->desc.bNumEndpoints * + sizeof(struct usb_host_endpoint)); - for (i = 0; i < ifp->bNumEndpoints; i++) { + for (i = 0; i < ifp->desc.bNumEndpoints; i++) { header = (struct usb_descriptor_header *)buffer; if (header->bLength > size) { @@ -230,49 +241,49 @@ } /* We check to see if it's an alternate to this one */ - ifp = (struct usb_interface_descriptor *)buffer; - if (size < USB_DT_INTERFACE_SIZE || - ifp->bDescriptorType != USB_DT_INTERFACE || - !ifp->bAlternateSetting) + d = (struct usb_interface_descriptor *)buffer; + if (size < USB_DT_INTERFACE_SIZE + || d->bDescriptorType != USB_DT_INTERFACE + || !d->bAlternateSetting) return parsed; } return parsed; } -int usb_parse_configuration(struct usb_config_descriptor *config, char *buffer) +int usb_parse_configuration(struct usb_host_config *config, char *buffer) { int i, retval, size; struct usb_descriptor_header *header; - memcpy(config, buffer, USB_DT_CONFIG_SIZE); - le16_to_cpus(&config->wTotalLength); - size = config->wTotalLength; + memcpy(&config->desc, buffer, USB_DT_CONFIG_SIZE); + le16_to_cpus(&config->desc.wTotalLength); + size = config->desc.wTotalLength; - if (config->bNumInterfaces > USB_MAXINTERFACES) { + if (config->desc.bNumInterfaces > USB_MAXINTERFACES) { warn("too many interfaces"); return -1; } config->interface = (struct usb_interface *) - kmalloc(config->bNumInterfaces * + kmalloc(config->desc.bNumInterfaces * sizeof(struct usb_interface), GFP_KERNEL); - dbg("kmalloc IF %p, numif %i", config->interface, config->bNumInterfaces); + dbg("kmalloc IF %p, numif %i", config->interface, config->desc.bNumInterfaces); if (!config->interface) { err("out of memory"); return -1; } memset(config->interface, 0, - config->bNumInterfaces * sizeof(struct usb_interface)); + config->desc.bNumInterfaces * sizeof(struct usb_interface)); - buffer += config->bLength; - size -= config->bLength; + buffer += config->desc.bLength; + size -= config->desc.bLength; config->extra = NULL; config->extralen = 0; - for (i = 0; i < config->bNumInterfaces; i++) { + for (i = 0; i < config->desc.bNumInterfaces; i++) { int numskipped, len; char *begin; @@ -351,12 +362,12 @@ } for (c = 0; c < dev->descriptor.bNumConfigurations; c++) { - struct usb_config_descriptor *cf = &dev->config[c]; + struct usb_host_config *cf = &dev->config[c]; if (!cf->interface) break; - for (i = 0; i < cf->bNumInterfaces; i++) { + for (i = 0; i < cf->desc.bNumInterfaces; i++) { struct usb_interface *ifp = &cf->interface[i]; @@ -364,7 +375,7 @@ break; for (j = 0; j < ifp->num_altsetting; j++) { - struct usb_interface_descriptor *as = + struct usb_host_interface *as = &ifp->altsetting[j]; if(as->extra) { @@ -374,7 +385,7 @@ if (!as->endpoint) break; - for(k = 0; k < as->bNumEndpoints; k++) { + for(k = 0; k < as->desc.bNumEndpoints; k++) { if(as->endpoint[k].extra) { kfree(as->endpoint[k].extra); } @@ -410,15 +421,15 @@ return -EINVAL; } - dev->config = (struct usb_config_descriptor *) + dev->config = (struct usb_host_config *) kmalloc(dev->descriptor.bNumConfigurations * - sizeof(struct usb_config_descriptor), GFP_KERNEL); + sizeof(struct usb_host_config), GFP_KERNEL); if (!dev->config) { err("out of memory"); return -ENOMEM; } memset(dev->config, 0, dev->descriptor.bNumConfigurations * - sizeof(struct usb_config_descriptor)); + sizeof(struct usb_host_config)); dev->rawdescriptors = (char **)kmalloc(sizeof(char *) * dev->descriptor.bNumConfigurations, GFP_KERNEL); diff -Nru a/drivers/usb/core/devices.c b/drivers/usb/core/devices.c --- a/drivers/usb/core/devices.c Wed Oct 30 09:43:59 2002 +++ b/drivers/usb/core/devices.c Wed Oct 30 09:43:59 2002 @@ -234,7 +234,7 @@ static char *usb_dump_interface_descriptor(char *start, char *end, const struct usb_interface *iface, int setno) { - struct usb_interface_descriptor *desc = &iface->altsetting[setno]; + struct usb_interface_descriptor *desc = &iface->altsetting[setno].desc; if (start > end) return start; @@ -259,15 +259,15 @@ const struct usb_interface *iface, int setno ) { - struct usb_interface_descriptor *desc = &iface->altsetting[setno]; + struct usb_host_interface *desc = &iface->altsetting[setno]; int i; start = usb_dump_interface_descriptor(start, end, iface, setno); - for (i = 0; i < desc->bNumEndpoints; i++) { + for (i = 0; i < desc->desc.bNumEndpoints; i++) { if (start > end) return start; start = usb_dump_endpoint_descriptor(speed, - start, end, desc->endpoint + i); + start, end, &desc->endpoint[i].desc); } return start; } @@ -288,7 +288,7 @@ desc->bNumInterfaces, desc->bConfigurationValue, desc->bmAttributes, - desc->MaxPower * 2); + desc->bMaxPower * 2); return start; } @@ -296,7 +296,7 @@ int speed, char *start, char *end, - const struct usb_config_descriptor *config, + const struct usb_host_config *config, int active ) { @@ -307,8 +307,8 @@ return start; if (!config) /* getting these some in 2.3.7; none in 2.3.6 */ return start + sprintf(start, "(null Cfg. desc.)\n"); - start = usb_dump_config_descriptor(start, end, config, active); - for (i = 0; i < config->bNumInterfaces; i++) { + start = usb_dump_config_descriptor(start, end, &config->desc, active); + for (i = 0; i < config->desc.bNumInterfaces; i++) { interface = config->interface + i; if (!interface) break; diff -Nru a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c --- a/drivers/usb/core/devio.c Wed Oct 30 09:44:00 2002 +++ b/drivers/usb/core/devio.c Wed Oct 30 09:44:00 2002 @@ -337,7 +337,8 @@ struct usb_interface *iface; int err; - if (intf >= 8*sizeof(ps->ifclaimed) || !dev || intf >= dev->actconfig->bNumInterfaces) + if (intf >= 8*sizeof(ps->ifclaimed) || !dev + || intf >= dev->actconfig->desc.bNumInterfaces) return -EINVAL; /* already claimed */ if (test_bit(intf, &ps->ifclaimed)) @@ -390,17 +391,17 @@ { unsigned int i, j, e; struct usb_interface *iface; - struct usb_interface_descriptor *alts; + struct usb_host_interface *alts; struct usb_endpoint_descriptor *endpt; if (ep & ~(USB_DIR_IN|0xf)) return -EINVAL; - for (i = 0; i < dev->actconfig->bNumInterfaces; i++) { + for (i = 0; i < dev->actconfig->desc.bNumInterfaces; i++) { iface = &dev->actconfig->interface[i]; for (j = 0; j < iface->num_altsetting; j++) { alts = &iface->altsetting[j]; - for (e = 0; e < alts->bNumEndpoints; e++) { - endpt = &alts->endpoint[e]; + for (e = 0; e < alts->desc.bNumEndpoints; e++) { + endpt = &alts->endpoint[e].desc; if (endpt->bEndpointAddress == ep) return i; } @@ -413,15 +414,15 @@ { unsigned int i, j; struct usb_interface *iface; - struct usb_interface_descriptor *alts; + struct usb_host_interface *alts; if (ifn & ~0xff) return -EINVAL; - for (i = 0; i < dev->actconfig->bNumInterfaces; i++) { + for (i = 0; i < dev->actconfig->desc.bNumInterfaces; i++) { iface = &dev->actconfig->interface[i]; for (j = 0; j < iface->num_altsetting; j++) { alts = &iface->altsetting[j]; - if (alts->bInterfaceNumber == ifn) + if (alts->desc.bInterfaceNumber == ifn) return i; } } @@ -693,7 +694,7 @@ if (ret < 0) return ret; - for (i = 0; i < ps->dev->actconfig->bNumInterfaces; i++) { + for (i = 0; i < ps->dev->actconfig->desc.bNumInterfaces; i++) { struct usb_interface *intf = &ps->dev->actconfig->interface[i]; /* Don't simulate interfaces we've claimed */ diff -Nru a/drivers/usb/core/driverfs.c b/drivers/usb/core/driverfs.c --- a/drivers/usb/core/driverfs.c Wed Oct 30 09:43:59 2002 +++ b/drivers/usb/core/driverfs.c Wed Oct 30 09:43:59 2002 @@ -33,14 +33,14 @@ return 0; \ \ udev = to_usb_device (dev); \ - return sprintf (buf, format_string, udev->actconfig->field); \ + return sprintf (buf, format_string, udev->actconfig->desc.field); \ } \ static DEVICE_ATTR(field, S_IRUGO, show_##field, NULL); usb_actconfig_attr (bNumInterfaces, "%2d\n") usb_actconfig_attr (bConfigurationValue, "%2d\n") usb_actconfig_attr (bmAttributes, "%2x\n") -usb_actconfig_attr (MaxPower, "%3dmA\n") +usb_actconfig_attr (bMaxPower, "%3dmA\n") /* String fields */ static ssize_t show_product (struct device *dev, char *buf, size_t count, loff_t off) @@ -157,7 +157,7 @@ device_create_file (dev, &dev_attr_bNumInterfaces); device_create_file (dev, &dev_attr_bConfigurationValue); device_create_file (dev, &dev_attr_bmAttributes); - device_create_file (dev, &dev_attr_MaxPower); + device_create_file (dev, &dev_attr_bMaxPower); device_create_file (dev, &dev_attr_idVendor); device_create_file (dev, &dev_attr_idProduct); device_create_file (dev, &dev_attr_bcdDevice); @@ -188,7 +188,7 @@ intf = to_usb_interface (dev); \ alt = intf->act_altsetting; \ \ - return sprintf (buf, format_string, intf->altsetting[alt].field); \ + return sprintf (buf, format_string, intf->altsetting[alt].desc.field); \ } \ static DEVICE_ATTR(field, S_IRUGO, show_##field, NULL); diff -Nru a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c --- a/drivers/usb/core/hub.c Wed Oct 30 09:44:00 2002 +++ b/drivers/usb/core/hub.c Wed Oct 30 09:44:00 2002 @@ -478,7 +478,7 @@ static int hub_probe(struct usb_interface *intf, const struct usb_device_id *id) { - struct usb_interface_descriptor *desc; + struct usb_host_interface *desc; struct usb_endpoint_descriptor *endpoint; struct usb_device *dev; struct usb_hub *hub; @@ -489,21 +489,21 @@ /* Some hubs have a subclass of 1, which AFAICT according to the */ /* specs is not defined, but it works */ - if ((desc->bInterfaceSubClass != 0) && - (desc->bInterfaceSubClass != 1)) { + if ((desc->desc.bInterfaceSubClass != 0) && + (desc->desc.bInterfaceSubClass != 1)) { err("invalid subclass (%d) for USB hub device #%d", - desc->bInterfaceSubClass, dev->devnum); + desc->desc.bInterfaceSubClass, dev->devnum); return -EIO; } /* Multiple endpoints? What kind of mutant ninja-hub is this? */ - if (desc->bNumEndpoints != 1) { + if (desc->desc.bNumEndpoints != 1) { err("invalid bNumEndpoints (%d) for USB hub device #%d", - desc->bNumEndpoints, dev->devnum); + desc->desc.bNumEndpoints, dev->devnum); return -EIO; } - endpoint = &desc->endpoint[0]; + endpoint = &desc->endpoint[0].desc; /* Output endpoint? Curiousier and curiousier.. */ if (!(endpoint->bEndpointAddress & USB_DIR_IN)) { @@ -1244,18 +1244,18 @@ return 1; } - ret = usb_set_configuration(dev, dev->actconfig->bConfigurationValue); + ret = usb_set_configuration(dev, dev->actconfig->desc.bConfigurationValue); if (ret < 0) { err("failed to set dev %s active configuration (error=%d)", dev->devpath, ret); return ret; } - for (i = 0; i < dev->actconfig->bNumInterfaces; i++) { + for (i = 0; i < dev->actconfig->desc.bNumInterfaces; i++) { struct usb_interface *intf = &dev->actconfig->interface[i]; struct usb_interface_descriptor *as; - as = &intf->altsetting[intf->act_altsetting]; + as = &intf->altsetting[intf->act_altsetting].desc; ret = usb_set_interface(dev, as->bInterfaceNumber, as->bAlternateSetting); if (ret < 0) { diff -Nru a/drivers/usb/core/message.c b/drivers/usb/core/message.c --- a/drivers/usb/core/message.c Wed Oct 30 09:43:59 2002 +++ b/drivers/usb/core/message.c Wed Oct 30 09:43:59 2002 @@ -640,31 +640,33 @@ // hub-only!! ... and only exported for reset/reinit path. -// otherwise used internally, for config/altsetting reconfig. +// otherwise used internally, when setting up a config void usb_set_maxpacket(struct usb_device *dev) { int i, b; - for (i=0; iactconfig->bNumInterfaces; i++) { + for (i=0; iactconfig->desc.bNumInterfaces; i++) { struct usb_interface *ifp = dev->actconfig->interface + i; - struct usb_interface_descriptor *as = ifp->altsetting + ifp->act_altsetting; - struct usb_endpoint_descriptor *ep = as->endpoint; + struct usb_host_interface *as = ifp->altsetting + ifp->act_altsetting; + struct usb_host_endpoint *ep = as->endpoint; int e; - for (e=0; ebNumEndpoints; e++) { - b = ep[e].bEndpointAddress & USB_ENDPOINT_NUMBER_MASK; - if ((ep[e].bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == + for (e=0; edesc.bNumEndpoints; e++) { + struct usb_endpoint_descriptor *d; + d = &ep [e].desc; + b = d->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK; + if ((d->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_CONTROL) { /* Control => bidirectional */ - dev->epmaxpacketout[b] = ep[e].wMaxPacketSize; - dev->epmaxpacketin [b] = ep[e].wMaxPacketSize; + dev->epmaxpacketout[b] = d->wMaxPacketSize; + dev->epmaxpacketin [b] = d->wMaxPacketSize; } - else if (usb_endpoint_out(ep[e].bEndpointAddress)) { - if (ep[e].wMaxPacketSize > dev->epmaxpacketout[b]) - dev->epmaxpacketout[b] = ep[e].wMaxPacketSize; + else if (usb_endpoint_out(d->bEndpointAddress)) { + if (d->wMaxPacketSize > dev->epmaxpacketout[b]) + dev->epmaxpacketout[b] = d->wMaxPacketSize; } else { - if (ep[e].wMaxPacketSize > dev->epmaxpacketin [b]) - dev->epmaxpacketin [b] = ep[e].wMaxPacketSize; + if (d->wMaxPacketSize > dev->epmaxpacketin [b]) + dev->epmaxpacketin [b] = d->wMaxPacketSize; } } } @@ -764,7 +766,7 @@ int usb_set_interface(struct usb_device *dev, int interface, int alternate) { struct usb_interface *iface; - struct usb_interface_descriptor *iface_as; + struct usb_host_interface *iface_as; int i, ret; iface = usb_ifnum_to_if(dev, interface); @@ -786,7 +788,8 @@ if ((ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), USB_REQ_SET_INTERFACE, USB_RECIP_INTERFACE, - iface->altsetting[alternate].bAlternateSetting, + iface->altsetting[alternate] + .desc.bAlternateSetting, interface, NULL, 0, HZ * 5)) < 0) return ret; @@ -798,8 +801,8 @@ /* prevent submissions using previous endpoint settings */ iface_as = iface->altsetting + iface->act_altsetting; - for (i = 0; i < iface_as->bNumEndpoints; i++) { - u8 ep = iface_as->endpoint [i].bEndpointAddress; + for (i = 0; i < iface_as->desc.bNumEndpoints; i++) { + u8 ep = iface_as->endpoint [i].desc.bEndpointAddress; int out = !(ep & USB_DIR_IN); ep &= USB_ENDPOINT_NUMBER_MASK; @@ -821,14 +824,14 @@ */ iface_as = &iface->altsetting[alternate]; - for (i = 0; i < iface_as->bNumEndpoints; i++) { - u8 ep = iface_as->endpoint[i].bEndpointAddress; + for (i = 0; i < iface_as->desc.bNumEndpoints; i++) { + u8 ep = iface_as->endpoint[i].desc.bEndpointAddress; int out = !(ep & USB_DIR_IN); ep &= USB_ENDPOINT_NUMBER_MASK; usb_settoggle (dev, ep, out, 0); (out ? dev->epmaxpacketout : dev->epmaxpacketin) [ep] - = iface_as->endpoint [i].wMaxPacketSize; + = iface_as->endpoint [i].desc.wMaxPacketSize; } return 0; @@ -867,10 +870,10 @@ int usb_set_configuration(struct usb_device *dev, int configuration) { int i, ret; - struct usb_config_descriptor *cp = NULL; + struct usb_host_config *cp = NULL; for (i=0; idescriptor.bNumConfigurations; i++) { - if (dev->config[i].bConfigurationValue == configuration) { + if (dev->config[i].desc.bConfigurationValue == configuration) { cp = &dev->config[i]; break; } diff -Nru a/drivers/usb/core/usb-debug.c b/drivers/usb/core/usb-debug.c --- a/drivers/usb/core/usb-debug.c Wed Oct 30 09:43:59 2002 +++ b/drivers/usb/core/usb-debug.c Wed Oct 30 09:43:59 2002 @@ -16,28 +16,28 @@ #endif #include -static void usb_show_endpoint(struct usb_endpoint_descriptor *endpoint) +static void usb_show_endpoint(struct usb_host_endpoint *endpoint) { - usb_show_endpoint_descriptor(endpoint); + usb_show_endpoint_descriptor(&endpoint->desc); } -static void usb_show_interface(struct usb_interface_descriptor *altsetting) +static void usb_show_interface(struct usb_host_interface *altsetting) { int i; - usb_show_interface_descriptor(altsetting); + usb_show_interface_descriptor(&altsetting->desc); - for (i = 0; i < altsetting->bNumEndpoints; i++) + for (i = 0; i < altsetting->desc.bNumEndpoints; i++) usb_show_endpoint(altsetting->endpoint + i); } -static void usb_show_config(struct usb_config_descriptor *config) +static void usb_show_config(struct usb_host_config *config) { int i, j; struct usb_interface *ifp; - usb_show_config_descriptor(config); - for (i = 0; i < config->bNumInterfaces; i++) { + usb_show_config_descriptor(&config->desc); + for (i = 0; i < config->desc.bNumInterfaces; i++) { ifp = config->interface + i; if (!ifp) @@ -124,7 +124,7 @@ printk(" bConfigurationValue = %02x\n", desc->bConfigurationValue); printk(" iConfiguration = %02x\n", desc->iConfiguration); printk(" bmAttributes = %02x\n", desc->bmAttributes); - printk(" MaxPower = %4dmA\n", desc->MaxPower * 2); + printk(" bMaxPower = %4dmA\n", desc->bMaxPower * 2); } void usb_show_interface_descriptor(struct usb_interface_descriptor *desc) diff -Nru a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c --- a/drivers/usb/core/usb.c Wed Oct 30 09:44:00 2002 +++ b/drivers/usb/core/usb.c Wed Oct 30 09:44:00 2002 @@ -233,8 +233,9 @@ { int i; - for (i = 0; i < dev->actconfig->bNumInterfaces; i++) - if (dev->actconfig->interface[i].altsetting[0].bInterfaceNumber == ifnum) + for (i = 0; i < dev->actconfig->desc.bNumInterfaces; i++) + if (dev->actconfig->interface[i].altsetting[0] + .desc.bInterfaceNumber == ifnum) return &dev->actconfig->interface[i]; return NULL; @@ -254,15 +255,21 @@ * the first endpoint in that descriptor corresponds to interface zero. * This routine helps device drivers avoid such mistakes. */ -struct usb_endpoint_descriptor *usb_epnum_to_ep_desc(struct usb_device *dev, unsigned epnum) +struct usb_endpoint_descriptor * +usb_epnum_to_ep_desc(struct usb_device *dev, unsigned epnum) { int i, j, k; - for (i = 0; i < dev->actconfig->bNumInterfaces; i++) + for (i = 0; i < dev->actconfig->desc.bNumInterfaces; i++) for (j = 0; j < dev->actconfig->interface[i].num_altsetting; j++) - for (k = 0; k < dev->actconfig->interface[i].altsetting[j].bNumEndpoints; k++) - if (epnum == dev->actconfig->interface[i].altsetting[j].endpoint[k].bEndpointAddress) - return &dev->actconfig->interface[i].altsetting[j].endpoint[k]; + for (k = 0; k < dev->actconfig->interface[i] + .altsetting[j].desc.bNumEndpoints; k++) + if (epnum == dev->actconfig->interface[i] + .altsetting[j].endpoint[k] + .desc.bEndpointAddress) + return &dev->actconfig->interface[i] + .altsetting[j].endpoint[k] + .desc; return NULL; } @@ -408,7 +415,7 @@ const struct usb_device_id * usb_match_id(struct usb_interface *interface, const struct usb_device_id *id) { - struct usb_interface_descriptor *intf; + struct usb_host_interface *intf; struct usb_device *dev; /* proc_connectinfo in devio.c may call us with id == NULL. */ @@ -457,15 +464,15 @@ continue; if ((id->match_flags & USB_DEVICE_ID_MATCH_INT_CLASS) && - (id->bInterfaceClass != intf->bInterfaceClass)) + (id->bInterfaceClass != intf->desc.bInterfaceClass)) continue; if ((id->match_flags & USB_DEVICE_ID_MATCH_INT_SUBCLASS) && - (id->bInterfaceSubClass != intf->bInterfaceSubClass)) + (id->bInterfaceSubClass != intf->desc.bInterfaceSubClass)) continue; if ((id->match_flags & USB_DEVICE_ID_MATCH_INT_PROTOCOL) && - (id->bInterfaceProtocol != intf->bInterfaceProtocol)) + (id->bInterfaceProtocol != intf->desc.bInterfaceProtocol)) continue; return id; @@ -604,10 +611,10 @@ */ envp [i++] = scratch; length += snprintf (scratch, buffer_size - length, - "INTERFACE=%d/%d/%d", - intf->altsetting[alt].bInterfaceClass, - intf->altsetting[alt].bInterfaceSubClass, - intf->altsetting[alt].bInterfaceProtocol); + "INTERFACE=%d/%d/%d", + intf->altsetting[alt].desc.bInterfaceClass, + intf->altsetting[alt].desc.bInterfaceSubClass, + intf->altsetting[alt].desc.bInterfaceProtocol); if ((buffer_size - length <= 0) || (i >= num_envp)) return -ENOMEM; ++length; @@ -792,7 +799,7 @@ dbg ("unregistering interfaces on device %d", dev->devnum); if (dev->actconfig) { - for (i = 0; i < dev->actconfig->bNumInterfaces; i++) { + for (i = 0; i < dev->actconfig->desc.bNumInterfaces; i++) { struct usb_interface *interface = &dev->actconfig->interface[i]; /* remove this interface */ @@ -1026,7 +1033,7 @@ } /* we set the default configuration here */ - err = usb_set_configuration(dev, dev->config[0].bConfigurationValue); + err = usb_set_configuration(dev, dev->config[0].desc.bConfigurationValue); if (err) { err("failed to set device %d default configuration (error=%d)", dev->devnum, err); @@ -1065,16 +1072,17 @@ /* Register all of the interfaces for this device with the driver core. * Remember, interfaces get bound to drivers, not devices. */ - for (i = 0; i < dev->actconfig->bNumInterfaces; i++) { + for (i = 0; i < dev->actconfig->desc.bNumInterfaces; i++) { struct usb_interface *interface = &dev->actconfig->interface[i]; - struct usb_interface_descriptor *desc = interface->altsetting; + struct usb_interface_descriptor *desc; + desc = &interface->altsetting [interface->act_altsetting].desc; interface->dev.parent = &dev->dev; interface->dev.driver = NULL; interface->dev.bus = &usb_bus_type; sprintf (&interface->dev.bus_id[0], "%d-%s:%d", dev->bus->busnum, dev->devpath, - interface->altsetting->bInterfaceNumber); + desc->bInterfaceNumber); if (!desc->iInterface || usb_string (dev, desc->iInterface, interface->dev.name, @@ -1087,7 +1095,7 @@ sprintf (&interface->dev.name[0], "usb-%s-%s interface %d", dev->bus->bus_name, dev->devpath, - interface->altsetting->bInterfaceNumber); + desc->bInterfaceNumber); } dbg ("%s - registering %s", __FUNCTION__, interface->dev.bus_id); device_register (&interface->dev); diff -Nru a/drivers/usb/image/hpusbscsi.c b/drivers/usb/image/hpusbscsi.c --- a/drivers/usb/image/hpusbscsi.c Wed Oct 30 09:44:00 2002 +++ b/drivers/usb/image/hpusbscsi.c Wed Oct 30 09:44:00 2002 @@ -35,14 +35,14 @@ { struct hpusbscsi *new; struct usb_device *dev = interface_to_usbdev (intf); - struct usb_interface_descriptor *altsetting = + struct usb_host_interface *altsetting = &(intf->altsetting[0]); int i, result; /* basic check */ - if (altsetting->bNumEndpoints != 3) { + if (altsetting->desc.bNumEndpoints != 3) { printk (KERN_ERR "Wrong number of endpoints\n"); return -ENODEV; } @@ -76,34 +76,34 @@ /* finding endpoints */ - for (i = 0; i < altsetting->bNumEndpoints; i++) { + for (i = 0; i < altsetting->desc.bNumEndpoints; i++) { if ( - (altsetting->endpoint[i]. + (altsetting->endpoint[i].desc. bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_BULK) { - if (altsetting->endpoint[i]. + if (altsetting->endpoint[i].desc. bEndpointAddress & USB_DIR_IN) { new->ep_in = - altsetting->endpoint[i]. + altsetting->endpoint[i].desc. bEndpointAddress & USB_ENDPOINT_NUMBER_MASK; } else { new->ep_out = - altsetting->endpoint[i]. + altsetting->endpoint[i].desc. bEndpointAddress & USB_ENDPOINT_NUMBER_MASK; } } else { new->ep_int = - altsetting->endpoint[i]. + altsetting->endpoint[i].desc. bEndpointAddress & USB_ENDPOINT_NUMBER_MASK; - new->interrupt_interval= altsetting->endpoint[i].bInterval; + new->interrupt_interval= altsetting->endpoint[i].desc.bInterval; } } /* USB initialisation magic for the simple case */ - result = usb_set_interface (dev, altsetting->bInterfaceNumber, 0); + result = usb_set_interface (dev, altsetting->desc.bInterfaceNumber, 0); switch (result) { case 0: /* no error */ diff -Nru a/drivers/usb/image/mdc800.c b/drivers/usb/image/mdc800.c --- a/drivers/usb/image/mdc800.c Wed Oct 30 09:44:00 2002 +++ b/drivers/usb/image/mdc800.c Wed Oct 30 09:44:00 2002 @@ -410,7 +410,7 @@ const struct usb_device_id *id) { int i,j; - struct usb_interface_descriptor *intf_desc; + struct usb_host_interface *intf_desc; struct usb_device *dev = interface_to_usbdev (intf); int irq_interval=0; int retval; @@ -432,10 +432,10 @@ intf_desc = &intf->altsetting[0]; if ( - ( intf_desc->bInterfaceClass != 0xff ) - || ( intf_desc->bInterfaceSubClass != 0 ) - || ( intf_desc->bInterfaceProtocol != 0 ) - || ( intf_desc->bNumEndpoints != 4) + ( intf_desc->desc.bInterfaceClass != 0xff ) + || ( intf_desc->desc.bInterfaceSubClass != 0 ) + || ( intf_desc->desc.bInterfaceProtocol != 0 ) + || ( intf_desc->desc.bNumEndpoints != 4) ) { err ("probe fails -> wrong Interface"); @@ -448,12 +448,12 @@ mdc800->endpoint[i]=-1; for (j=0; j<4; j++) { - if (mdc800_endpoint_equals (&intf_desc->endpoint [j],&mdc800_ed [i])) + if (mdc800_endpoint_equals (&intf_desc->endpoint [j].desc,&mdc800_ed [i])) { - mdc800->endpoint[i]=intf_desc->endpoint [j].bEndpointAddress ; + mdc800->endpoint[i]=intf_desc->endpoint [j].desc.bEndpointAddress ; if (i==1) { - irq_interval=intf_desc->endpoint [j].bInterval; + irq_interval=intf_desc->endpoint [j].desc.bInterval; } continue; @@ -468,7 +468,7 @@ usb_driver_claim_interface (&mdc800_usb_driver, intf, mdc800); - if (usb_set_interface (dev, intf_desc->bInterfaceNumber, 0) < 0) + if (usb_set_interface (dev, intf_desc->desc.bInterfaceNumber, 0) < 0) { err ("MDC800 Configuration fails."); return -ENODEV; diff -Nru a/drivers/usb/image/microtek.c b/drivers/usb/image/microtek.c --- a/drivers/usb/image/microtek.c Wed Oct 30 09:44:00 2002 +++ b/drivers/usb/image/microtek.c Wed Oct 30 09:44:00 2002 @@ -851,7 +851,7 @@ struct usb_device *dev = interface_to_usbdev (intf); /* the altsettting 0 on the interface we're probing */ - struct usb_interface_descriptor *altsetting; + struct usb_host_interface *altsetting; MTS_DEBUG_GOT_HERE(); MTS_DEBUG( "usb-device descriptor at %x\n", (int)dev ); @@ -877,23 +877,23 @@ /* Check if the config is sane */ - if ( altsetting->bNumEndpoints != MTS_EP_TOTAL ) { + if ( altsetting->desc.bNumEndpoints != MTS_EP_TOTAL ) { MTS_WARNING( "expecting %d got %d endpoints! Bailing out.\n", - (int)MTS_EP_TOTAL, (int)altsetting->bNumEndpoints ); + (int)MTS_EP_TOTAL, (int)altsetting->desc.bNumEndpoints ); return -ENODEV; } - for( i = 0; i < altsetting->bNumEndpoints; i++ ) { - if ((altsetting->endpoint[i].bmAttributes & + for( i = 0; i < altsetting->desc.bNumEndpoints; i++ ) { + if ((altsetting->endpoint[i].desc.bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) != USB_ENDPOINT_XFER_BULK) { MTS_WARNING( "can only deal with bulk endpoints; endpoint %d is not bulk.\n", - (int)altsetting->endpoint[i].bEndpointAddress ); + (int)altsetting->endpoint[i].desc.bEndpointAddress ); } else { - if (altsetting->endpoint[i].bEndpointAddress & + if (altsetting->endpoint[i].desc.bEndpointAddress & USB_DIR_IN) *ep_in_current++ - = altsetting->endpoint[i].bEndpointAddress & + = altsetting->endpoint[i].desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK; else { if ( ep_out != -1 ) { @@ -901,7 +901,7 @@ return -ENODEV; } - ep_out = altsetting->endpoint[i].bEndpointAddress & + ep_out = altsetting->endpoint[i].desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK; } } diff -Nru a/drivers/usb/image/scanner.c b/drivers/usb/image/scanner.c --- a/drivers/usb/image/scanner.c Wed Oct 30 09:43:59 2002 +++ b/drivers/usb/image/scanner.c Wed Oct 30 09:43:59 2002 @@ -839,7 +839,7 @@ { struct usb_device *dev = interface_to_usbdev (intf); struct scn_usb_data *scn; - struct usb_interface_descriptor *interface; + struct usb_host_interface *interface; struct usb_endpoint_descriptor *endpoint; int ep_cnt; @@ -905,13 +905,13 @@ return -ENODEV; } - if (dev->config[0].bNumInterfaces != 1) { + if (dev->config[0].desc.bNumInterfaces != 1) { info("probe_scanner: Only one device interface is supported."); return -ENODEV; } interface = intf->altsetting; - endpoint = interface->endpoint; + endpoint = &interface->endpoint[0].desc; /* * Start checking for two bulk endpoints OR two bulk endpoints *and* one @@ -919,16 +919,16 @@ * setup the handler. FIXME: This is a future enhancement... */ - dbg("probe_scanner: Number of Endpoints:%d", (int) interface->bNumEndpoints); + dbg("probe_scanner: Number of Endpoints:%d", (int) interface->desc.bNumEndpoints); - if ((interface->bNumEndpoints != 2) && (interface->bNumEndpoints != 3)) { + if ((interface->desc.bNumEndpoints != 2) && (interface->desc.bNumEndpoints != 3)) { info("probe_scanner: Only two or three endpoints supported."); return -ENODEV; } ep_cnt = have_bulk_in = have_bulk_out = have_intr = 0; - while (ep_cnt < interface->bNumEndpoints) { + while (ep_cnt < interface->desc.bNumEndpoints) { if (!have_bulk_in && IS_EP_BULK_IN(endpoint[ep_cnt])) { ep_cnt++; @@ -960,7 +960,7 @@ * should have. */ - switch(interface->bNumEndpoints) { + switch(interface->desc.bNumEndpoints) { case 2: if (!have_bulk_in || !have_bulk_out) { info("probe_scanner: Two bulk endpoints required."); diff -Nru a/drivers/usb/input/aiptek.c b/drivers/usb/input/aiptek.c --- a/drivers/usb/input/aiptek.c Wed Oct 30 09:44:00 2002 +++ b/drivers/usb/input/aiptek.c Wed Oct 30 09:44:00 2002 @@ -313,7 +313,7 @@ aiptek->dev.id.version = dev->descriptor.bcdDevice; aiptek->usbdev = dev; - endpoint = intf->altsetting[0].endpoint + 0; + endpoint = &intf->altsetting[0].endpoint[0].desc; if (aiptek->features->pktlen > 10) BUG(); diff -Nru a/drivers/usb/input/hid-core.c b/drivers/usb/input/hid-core.c --- a/drivers/usb/input/hid-core.c Wed Oct 30 09:44:00 2002 +++ b/drivers/usb/input/hid-core.c Wed Oct 30 09:44:00 2002 @@ -1386,7 +1386,7 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf) { - struct usb_interface_descriptor *interface = intf->altsetting + intf->act_altsetting; + struct usb_host_interface *interface = intf->altsetting + intf->act_altsetting; struct usb_device *dev = interface_to_usbdev (intf); struct hid_descriptor *hdesc; struct hid_device *hid; @@ -1402,7 +1402,7 @@ if (quirks & HID_QUIRK_IGNORE) return NULL; - if (usb_get_extra_descriptor(interface, HID_DT_HID, &hdesc) && ((!interface->bNumEndpoints) || + if (usb_get_extra_descriptor(interface, HID_DT_HID, &hdesc) && ((!interface->desc.bNumEndpoints) || usb_get_extra_descriptor(&interface->endpoint[0], HID_DT_HID, &hdesc))) { dbg("class descriptor not present\n"); return NULL; @@ -1422,7 +1422,7 @@ return NULL; } - if ((n = hid_get_class_descriptor(dev, interface->bInterfaceNumber, HID_DT_REPORT, rdesc, rsize)) < 0) { + if ((n = hid_get_class_descriptor(dev, interface->desc.bInterfaceNumber, HID_DT_REPORT, rdesc, rsize)) < 0) { dbg("reading report descriptor failed"); kfree(rdesc); return NULL; @@ -1449,11 +1449,12 @@ goto fail; } - for (n = 0; n < interface->bNumEndpoints; n++) { + for (n = 0; n < interface->desc.bNumEndpoints; n++) { - struct usb_endpoint_descriptor *endpoint = &interface->endpoint[n]; + struct usb_endpoint_descriptor *endpoint; int pipe; + endpoint = &interface->endpoint[n].desc; if ((endpoint->bmAttributes & 3) != 3) /* Not an interrupt endpoint */ continue; @@ -1493,7 +1494,7 @@ hid->version = le16_to_cpu(hdesc->bcdHID); hid->country = hdesc->bCountryCode; hid->dev = dev; - hid->ifnum = interface->bInterfaceNumber; + hid->ifnum = interface->desc.bInterfaceNumber; hid->name[0] = 0; @@ -1510,7 +1511,8 @@ snprintf(hid->name, 128, "%04x:%04x", dev->descriptor.idVendor, dev->descriptor.idProduct); usb_make_path(dev, buf, 64); - snprintf(hid->phys, 64, "%s/input%d", buf, intf->altsetting[0].bInterfaceNumber); + snprintf(hid->phys, 64, "%s/input%d", buf, + intf->altsetting[0].desc.bInterfaceNumber); if (usb_string(dev, dev->descriptor.iSerialNumber, hid->uniq, 64) <= 0) hid->uniq[0] = 0; diff -Nru a/drivers/usb/input/powermate.c b/drivers/usb/input/powermate.c --- a/drivers/usb/input/powermate.c Wed Oct 30 09:44:00 2002 +++ b/drivers/usb/input/powermate.c Wed Oct 30 09:44:00 2002 @@ -290,14 +290,14 @@ static int powermate_probe(struct usb_interface *intf, const struct usb_device_id *id) { struct usb_device *udev = interface_to_usbdev (intf); - struct usb_interface_descriptor *interface; + struct usb_host_interface *interface; struct usb_endpoint_descriptor *endpoint; struct powermate_device *pm; int pipe, maxp; char path[64]; interface = intf->altsetting + 0; - endpoint = interface->endpoint + 0; + endpoint = &interface->endpoint[0].desc; if (!(endpoint->bEndpointAddress & 0x80)) return -EIO; if ((endpoint->bmAttributes & 3) != 3) @@ -305,7 +305,7 @@ usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x0a, USB_TYPE_CLASS | USB_RECIP_INTERFACE, - 0, interface->bInterfaceNumber, NULL, 0, + 0, interface->desc.bInterfaceNumber, NULL, 0, HZ * USB_CTRL_SET_TIMEOUT); if (!(pm = kmalloc(sizeof(struct powermate_device), GFP_KERNEL))) diff -Nru a/drivers/usb/input/usbkbd.c b/drivers/usb/input/usbkbd.c --- a/drivers/usb/input/usbkbd.c Wed Oct 30 09:43:59 2002 +++ b/drivers/usb/input/usbkbd.c Wed Oct 30 09:43:59 2002 @@ -228,7 +228,7 @@ const struct usb_device_id *id) { struct usb_device * dev = interface_to_usbdev(iface); - struct usb_interface_descriptor *interface; + struct usb_host_interface *interface; struct usb_endpoint_descriptor *endpoint; struct usb_kbd *kbd; int i, pipe, maxp; @@ -237,10 +237,10 @@ interface = &iface->altsetting[iface->act_altsetting]; - if (interface->bNumEndpoints != 1) + if (interface->desc.bNumEndpoints != 1) return -ENODEV; - endpoint = interface->endpoint + 0; + endpoint = &interface->endpoint[0].desc; if (!(endpoint->bEndpointAddress & 0x80)) return -ENODEV; if ((endpoint->bmAttributes & 3) != 3) @@ -282,7 +282,7 @@ kbd->cr->bRequestType = USB_TYPE_CLASS | USB_RECIP_INTERFACE; kbd->cr->bRequest = 0x09; kbd->cr->wValue = cpu_to_le16(0x200); - kbd->cr->wIndex = cpu_to_le16(interface->bInterfaceNumber); + kbd->cr->wIndex = cpu_to_le16(interface->desc.bInterfaceNumber); kbd->cr->wLength = cpu_to_le16(1); usb_make_path(dev, path, 64); diff -Nru a/drivers/usb/input/usbmouse.c b/drivers/usb/input/usbmouse.c --- a/drivers/usb/input/usbmouse.c Wed Oct 30 09:44:00 2002 +++ b/drivers/usb/input/usbmouse.c Wed Oct 30 09:44:00 2002 @@ -121,7 +121,7 @@ static int usb_mouse_probe(struct usb_interface * intf, const struct usb_device_id * id) { struct usb_device * dev = interface_to_usbdev(intf); - struct usb_interface_descriptor *interface; + struct usb_host_interface *interface; struct usb_endpoint_descriptor *endpoint; struct usb_mouse *mouse; int pipe, maxp; @@ -130,10 +130,10 @@ interface = &intf->altsetting[intf->act_altsetting]; - if (interface->bNumEndpoints != 1) + if (interface->desc.bNumEndpoints != 1) return -ENODEV; - endpoint = interface->endpoint + 0; + endpoint = &interface->endpoint[0].desc; if (!(endpoint->bEndpointAddress & 0x80)) return -ENODEV; if ((endpoint->bmAttributes & 3) != 3) diff -Nru a/drivers/usb/input/wacom.c b/drivers/usb/input/wacom.c --- a/drivers/usb/input/wacom.c Wed Oct 30 09:43:59 2002 +++ b/drivers/usb/input/wacom.c Wed Oct 30 09:43:59 2002 @@ -561,7 +561,7 @@ wacom->dev.id.version = dev->descriptor.bcdDevice; wacom->usbdev = dev; - endpoint = intf->altsetting[0].endpoint + 0; + endpoint = &intf->altsetting[0].endpoint[0].desc; if (wacom->features->pktlen > 10) BUG(); diff -Nru a/drivers/usb/input/xpad.c b/drivers/usb/input/xpad.c --- a/drivers/usb/input/xpad.c Wed Oct 30 09:44:00 2002 +++ b/drivers/usb/input/xpad.c Wed Oct 30 09:44:00 2002 @@ -249,7 +249,7 @@ return -ENOMEM; } - ep_irq_in = intf->altsetting[0].endpoint + 0; + ep_irq_in = &intf->altsetting[0].endpoint[0].desc; usb_fill_int_urb(xpad->irq_in, udev, usb_rcvintpipe(udev, ep_irq_in->bEndpointAddress), diff -Nru a/drivers/usb/media/dabusb.c b/drivers/usb/media/dabusb.c --- a/drivers/usb/media/dabusb.c Wed Oct 30 09:44:00 2002 +++ b/drivers/usb/media/dabusb.c Wed Oct 30 09:44:00 2002 @@ -728,7 +728,7 @@ if (usbdev->descriptor.bNumConfigurations != 1) return -ENODEV; - if (intf->altsetting->bInterfaceNumber != _DABUSB_IF && usbdev->descriptor.idProduct == 0x9999) + if (intf->altsetting->desc.bInterfaceNumber != _DABUSB_IF && usbdev->descriptor.idProduct == 0x9999) return -ENODEV; retval = usb_register_dev (&dabusb_fops, DABUSB_MINOR, 1, &devnum); @@ -742,7 +742,7 @@ s->usbdev = usbdev; s->devnum = devnum; - if (usb_set_configuration (usbdev, usbdev->config[0].bConfigurationValue) < 0) { + if (usb_set_configuration (usbdev, usbdev->config[0].desc.bConfigurationValue) < 0) { err("set_configuration failed"); goto reject; } diff -Nru a/drivers/usb/media/ibmcam.c b/drivers/usb/media/ibmcam.c --- a/drivers/usb/media/ibmcam.c Wed Oct 30 09:43:59 2002 +++ b/drivers/usb/media/ibmcam.c Wed Oct 30 09:43:59 2002 @@ -3662,7 +3662,7 @@ struct uvd *uvd = NULL; int i, nas, model=0, canvasX=0, canvasY=0; int actInterface=-1, inactInterface=-1, maxPS=0; - __u8 ifnum = intf->altsetting->bInterfaceNumber; + __u8 ifnum = intf->altsetting->desc.bInterfaceNumber; unsigned char video_ep = 0; if (debug >= 1) @@ -3740,16 +3740,16 @@ } /* Validate all alternate settings */ for (i=0; i < nas; i++) { - const struct usb_interface_descriptor *interface; + const struct usb_host_interface *interface; const struct usb_endpoint_descriptor *endpoint; interface = &dev->actconfig->interface[ifnum].altsetting[i]; - if (interface->bNumEndpoints != 1) { + if (interface->desc.bNumEndpoints != 1) { err("Interface %d. has %u. endpoints!", - ifnum, (unsigned)(interface->bNumEndpoints)); + ifnum, (unsigned)(interface->desc.bNumEndpoints)); return -ENODEV; } - endpoint = &interface->endpoint[0]; + endpoint = &interface->endpoint[0].desc; if (video_ep == 0) video_ep = endpoint->bEndpointAddress; else if (video_ep != endpoint->bEndpointAddress) { diff -Nru a/drivers/usb/media/konicawc.c b/drivers/usb/media/konicawc.c --- a/drivers/usb/media/konicawc.c Wed Oct 30 09:43:59 2002 +++ b/drivers/usb/media/konicawc.c Wed Oct 30 09:43:59 2002 @@ -381,10 +381,10 @@ int i, errFlag; struct konicawc *cam = (struct konicawc *)uvd->user_data; int pktsz; - struct usb_interface_descriptor *interface; + struct usb_host_interface *interface; interface = &dev->actconfig->interface[uvd->iface].altsetting[spd_to_iface[cam->speed]]; - pktsz = interface->endpoint[1].wMaxPacketSize; + pktsz = interface->endpoint[1].desc.wMaxPacketSize; DEBUG(1, "pktsz = %d", pktsz); if (!CAMERA_IS_OPERATIONAL(uvd)) { err("Camera is not operational"); @@ -742,17 +742,17 @@ } /* Validate all alternate settings */ for (i=0; i < nas; i++) { - const struct usb_interface_descriptor *interface; + const struct usb_host_interface *interface; const struct usb_endpoint_descriptor *endpoint; interface = &intf->altsetting[i]; - if (interface->bNumEndpoints != 2) { + if (interface->desc.bNumEndpoints != 2) { err("Interface %d. has %u. endpoints!", - interface->bInterfaceNumber, - (unsigned)(interface->bNumEndpoints)); + interface->desc.bInterfaceNumber, + (unsigned)(interface->desc.bNumEndpoints)); return -ENODEV; } - endpoint = &interface->endpoint[1]; + endpoint = &interface->endpoint[1].desc; DEBUG(1, "found endpoint: addr: 0x%2.2x maxps = 0x%4.4x", endpoint->bEndpointAddress, endpoint->wMaxPacketSize); if (video_ep == 0) @@ -763,12 +763,12 @@ } if ((endpoint->bmAttributes & 0x03) != 0x01) { err("Interface %d. has non-ISO endpoint!", - interface->bInterfaceNumber); + interface->desc.bInterfaceNumber); return -ENODEV; } if ((endpoint->bEndpointAddress & 0x80) == 0) { err("Interface %d. has ISO OUT endpoint!", - interface->bInterfaceNumber); + interface->desc.bInterfaceNumber); return -ENODEV; } if (endpoint->wMaxPacketSize == 0) { @@ -819,7 +819,7 @@ uvd->flags = 0; uvd->debug = debug; uvd->dev = dev; - uvd->iface = intf->altsetting->bInterfaceNumber; + uvd->iface = intf->altsetting->desc.bInterfaceNumber; uvd->ifaceAltInactive = inactInterface; uvd->ifaceAltActive = actInterface; uvd->video_endp = video_ep; diff -Nru a/drivers/usb/media/ov511.c b/drivers/usb/media/ov511.c --- a/drivers/usb/media/ov511.c Wed Oct 30 09:43:59 2002 +++ b/drivers/usb/media/ov511.c Wed Oct 30 09:43:59 2002 @@ -5988,7 +5988,7 @@ if (ov->bridge == BRG_OV518) { struct usb_interface *ifp = &ov->dev->config[0].interface[0]; - __u16 mxps = ifp->altsetting[7].endpoint[0].wMaxPacketSize; + __u16 mxps = ifp->altsetting[7].endpoint[0].desc.wMaxPacketSize; /* Some OV518s have packet numbering by default, some don't */ if (mxps == 897) @@ -6083,7 +6083,7 @@ if (dev->descriptor.bNumConfigurations != 1) return -ENODEV; - interface = &intf->altsetting[0]; + interface = &intf->altsetting[0].desc; /* Checking vendor/product should be enough, but what the hell */ if (interface->bInterfaceClass != 0xFF) diff -Nru a/drivers/usb/media/pwc-if.c b/drivers/usb/media/pwc-if.c --- a/drivers/usb/media/pwc-if.c Wed Oct 30 09:44:00 2002 +++ b/drivers/usb/media/pwc-if.c Wed Oct 30 09:44:00 2002 @@ -761,7 +761,7 @@ struct urb *urb; int i, j, ret; - struct usb_interface_descriptor *idesc; + struct usb_host_interface *idesc; int cur_alt; if (pdev == NULL) @@ -781,9 +781,9 @@ /* Search video endpoint */ pdev->vmax_packet_size = -1; - for (i = 0; i < idesc->bNumEndpoints; i++) - if ((idesc->endpoint[i].bEndpointAddress & 0xF) == pdev->vendpoint) { - pdev->vmax_packet_size = idesc->endpoint[i].wMaxPacketSize; + for (i = 0; i < idesc->desc.bNumEndpoints; i++) + if ((idesc->endpoint[i].desc.bEndpointAddress & 0xF) == pdev->vendpoint) { + pdev->vmax_packet_size = idesc->endpoint[i].desc.wMaxPacketSize; break; } @@ -1552,13 +1552,15 @@ free_mem_leak(); /* Check if we can handle this device */ - Trace(TRACE_PROBE, "probe() called [%04X %04X], if %d\n", udev->descriptor.idVendor, udev->descriptor.idProduct, intf->altsetting->bInterfaceNumber); + Trace(TRACE_PROBE, "probe() called [%04X %04X], if %d\n", + udev->descriptor.idVendor, udev->descriptor.idProduct, + intf->altsetting->desc.bInterfaceNumber); /* the interfaces are probed one by one. We are only interested in the video interface (0) now. Interface 1 is the Audio Control, and interface 2 Audio itself. */ - if (intf->altsetting->bInterfaceNumber > 0) + if (intf->altsetting->desc.bInterfaceNumber > 0) return -ENODEV; vendor_id = udev->descriptor.idVendor; diff -Nru a/drivers/usb/media/se401.c b/drivers/usb/media/se401.c --- a/drivers/usb/media/se401.c Wed Oct 30 09:43:59 2002 +++ b/drivers/usb/media/se401.c Wed Oct 30 09:43:59 2002 @@ -1456,7 +1456,7 @@ if (dev->descriptor.bNumConfigurations != 1) return -ENODEV; - interface = &intf->altsetting[0]; + interface = &intf->altsetting[0].desc; /* Is it an se401? */ if (dev->descriptor.idVendor == 0x03e8 && diff -Nru a/drivers/usb/media/ultracam.c b/drivers/usb/media/ultracam.c --- a/drivers/usb/media/ultracam.c Wed Oct 30 09:43:59 2002 +++ b/drivers/usb/media/ultracam.c Wed Oct 30 09:43:59 2002 @@ -569,17 +569,17 @@ } /* Validate all alternate settings */ for (i=0; i < nas; i++) { - const struct usb_interface_descriptor *interface; + const struct usb_host_interface *interface; const struct usb_endpoint_descriptor *endpoint; interface = &intf->altsetting[i]; - if (interface->bNumEndpoints != 1) { + if (interface->desc.bNumEndpoints != 1) { err("Interface %d. has %u. endpoints!", - interface->bInterfaceNumber, - (unsigned)(interface->bNumEndpoints)); + interface->desc.bInterfaceNumber, + (unsigned)(interface->desc.bNumEndpoints)); return -ENODEV; } - endpoint = &interface->endpoint[0]; + endpoint = &interface->endpoint[0].desc; if (video_ep == 0) video_ep = endpoint->bEndpointAddress; else if (video_ep != endpoint->bEndpointAddress) { @@ -588,12 +588,12 @@ } if ((endpoint->bmAttributes & 0x03) != 0x01) { err("Interface %d. has non-ISO endpoint!", - interface->bInterfaceNumber); + interface->desc.bInterfaceNumber); return -ENODEV; } if ((endpoint->bEndpointAddress & 0x80) == 0) { err("Interface %d. has ISO OUT endpoint!", - interface->bInterfaceNumber); + interface->desc.bInterfaceNumber); return -ENODEV; } if (endpoint->wMaxPacketSize == 0) { @@ -636,7 +636,7 @@ uvd->flags = flags; uvd->debug = debug; uvd->dev = dev; - uvd->iface = intf->altsetting->bInterfaceNumber; + uvd->iface = intf->altsetting->desc.bInterfaceNumber; uvd->ifaceAltInactive = inactInterface; uvd->ifaceAltActive = actInterface; uvd->video_endp = video_ep; diff -Nru a/drivers/usb/media/vicam.c b/drivers/usb/media/vicam.c --- a/drivers/usb/media/vicam.c Wed Oct 30 09:43:59 2002 +++ b/drivers/usb/media/vicam.c Wed Oct 30 09:43:59 2002 @@ -1253,7 +1253,7 @@ { struct usb_device *dev = interface_to_usbdev(intf); int bulkEndpoint = 0; - const struct usb_interface_descriptor *interface; + const struct usb_host_interface *interface; const struct usb_endpoint_descriptor *endpoint; struct vicam_camera *cam; @@ -1268,8 +1268,8 @@ interface = &intf->altsetting[0]; DBG(KERN_DEBUG "Interface %d. has %u. endpoints!\n", - ifnum, (unsigned) (interface->bNumEndpoints)); - endpoint = &interface->endpoint[0]; + ifnum, (unsigned) (interface->desc.bNumEndpoints)); + endpoint = &interface->endpoint[0].desc; if ((endpoint->bEndpointAddress & 0x80) && ((endpoint->bmAttributes & 3) == 0x02)) { diff -Nru a/drivers/usb/misc/auerswald.c b/drivers/usb/misc/auerswald.c --- a/drivers/usb/misc/auerswald.c Wed Oct 30 09:43:59 2002 +++ b/drivers/usb/misc/auerswald.c Wed Oct 30 09:43:59 2002 @@ -1943,7 +1943,7 @@ return -ENODEV; /* we use only the first -and only- interface */ - if (intf->altsetting->bInterfaceNumber != 0) + if (intf->altsetting->desc.bInterfaceNumber != 0) return -ENODEV; /* prevent module unloading while sleeping */ diff -Nru a/drivers/usb/misc/brlvger.c b/drivers/usb/misc/brlvger.c --- a/drivers/usb/misc/brlvger.c Wed Oct 30 09:44:00 2002 +++ b/drivers/usb/misc/brlvger.c Wed Oct 30 09:44:00 2002 @@ -290,7 +290,7 @@ int i; int retval; struct usb_endpoint_descriptor *endpoint; - struct usb_interface_descriptor *actifsettings; + struct usb_host_interface *actifsettings; /* protects against reentrance: once we've found a free slot we reserve it.*/ static DECLARE_MUTEX(reserve_sem); @@ -299,13 +299,13 @@ actifsettings = dev->actconfig->interface->altsetting; if( dev->descriptor.bNumConfigurations != 1 - || dev->config->bNumInterfaces != 1 - || actifsettings->bNumEndpoints != 1 ) { + || dev->config->desc.bNumInterfaces != 1 + || actifsettings->desc.bNumEndpoints != 1 ) { err ("Bogus braille display config info"); return -ENODEV; } - endpoint = actifsettings->endpoint; + endpoint = &actifsettings->endpoint [0].desc; if (!(endpoint->bEndpointAddress & 0x80) || ((endpoint->bmAttributes & 3) != 0x03)) { err ("Bogus braille display config info, wrong endpoints"); diff -Nru a/drivers/usb/misc/tiglusb.c b/drivers/usb/misc/tiglusb.c --- a/drivers/usb/misc/tiglusb.c Wed Oct 30 09:43:59 2002 +++ b/drivers/usb/misc/tiglusb.c Wed Oct 30 09:43:59 2002 @@ -64,7 +64,7 @@ static inline int clear_device (struct usb_device *dev) { - if (usb_set_configuration (dev, dev->config[0].bConfigurationValue) < 0) { + if (usb_set_configuration (dev, dev->config[0].desc.bConfigurationValue) < 0) { err ("clear_device failed"); return -1; } @@ -351,7 +351,7 @@ && (dev->descriptor.idVendor != 0x451)) return -ENODEV; - if (usb_set_configuration (dev, dev->config[0].bConfigurationValue) < 0) { + if (usb_set_configuration (dev, dev->config[0].desc.bConfigurationValue) < 0) { err ("tiglusb_probe: set_configuration failed"); return -ENODEV; } diff -Nru a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c --- a/drivers/usb/misc/usbtest.c Wed Oct 30 09:44:00 2002 +++ b/drivers/usb/misc/usbtest.c Wed Oct 30 09:44:00 2002 @@ -290,7 +290,7 @@ retval = usb_control_msg (udev, usb_rcvctrlpipe (udev, 0), USB_REQ_GET_INTERFACE, USB_DIR_IN|USB_RECIP_INTERFACE, - 0, iface->altsetting [0].bInterfaceNumber, + 0, iface->altsetting [0].desc.bInterfaceNumber, dev->buf, 1, HZ * USB_CTRL_GET_TIMEOUT); switch (retval) { case 1: @@ -308,7 +308,7 @@ { struct usb_interface *iface = dev->intf; struct usb_device *udev; - struct usb_interface_descriptor *iface_as; + struct usb_host_interface *iface_as; int i, ret; if (alternate < 0 || alternate >= iface->num_altsetting) @@ -317,8 +317,8 @@ udev = interface_to_usbdev (iface); if ((ret = usb_control_msg (udev, usb_sndctrlpipe (udev, 0), USB_REQ_SET_INTERFACE, USB_RECIP_INTERFACE, - iface->altsetting [alternate].bAlternateSetting, - iface->altsetting [alternate].bInterfaceNumber, + alternate, + iface->altsetting->desc.bInterfaceNumber, NULL, 0, HZ * USB_CTRL_SET_TIMEOUT)) < 0) return ret; @@ -328,8 +328,8 @@ /* prevent requests using previous endpoint settings */ iface_as = iface->altsetting + iface->act_altsetting; - for (i = 0; i < iface_as->bNumEndpoints; i++) { - u8 ep = iface_as->endpoint [i].bEndpointAddress; + for (i = 0; i < iface_as->desc.bNumEndpoints; i++) { + u8 ep = iface_as->endpoint [i].desc.bEndpointAddress; int out = !(ep & USB_DIR_IN); ep &= USB_ENDPOINT_NUMBER_MASK; @@ -340,14 +340,14 @@ /* reset toggles and maxpacket for all endpoints affected */ iface_as = iface->altsetting + iface->act_altsetting; - for (i = 0; i < iface_as->bNumEndpoints; i++) { - u8 ep = iface_as->endpoint [i].bEndpointAddress; + for (i = 0; i < iface_as->desc.bNumEndpoints; i++) { + u8 ep = iface_as->endpoint [i].desc.bEndpointAddress; int out = !(ep & USB_DIR_IN); ep &= USB_ENDPOINT_NUMBER_MASK; usb_settoggle (udev, ep, out, 0); (out ? udev->epmaxpacketout : udev->epmaxpacketin ) [ep] - = iface_as->endpoint [i].wMaxPacketSize; + = iface_as->endpoint [i].desc.wMaxPacketSize; } return 0; @@ -415,10 +415,10 @@ /* 9.2.3 constrains the range here, and Linux ensures * they're ordered meaningfully in this array */ - if (iface->altsetting [i].bAlternateSetting != i) { + if (iface->altsetting [i].desc.bAlternateSetting != i) { dbg ("%s, illegal alt [%d].bAltSetting = %d", dev->id, i, - iface->altsetting [i] + iface->altsetting [i].desc .bAlternateSetting); return -EDOM; } @@ -447,7 +447,7 @@ /* [real world] get_config unimplemented if there's only one */ if (udev->descriptor.bNumConfigurations != 1) { - int expected = udev->actconfig->bConfigurationValue; + int expected = udev->actconfig->desc.bConfigurationValue; /* [9.4.2] get_configuration always works * ... although some cheap devices (like one TI Hub I've got) @@ -534,7 +534,7 @@ // the device's remote wakeup feature ... if we can, test that here retval = usb_get_status (udev, USB_RECIP_INTERFACE, - iface->altsetting [0].bInterfaceNumber, dev->buf); + iface->altsetting [0].desc.bInterfaceNumber, dev->buf); if (retval != 2) { dbg ("%s get interface status --> %d", dev->id, retval); return (retval < 0) ? retval : -EDOM; @@ -591,7 +591,7 @@ if (dev->info->alt >= 0) { int res; - if (intf->altsetting->bInterfaceNumber) + if (intf->altsetting->desc.bInterfaceNumber) return -ENODEV; res = set_altsetting (dev, dev->info->alt); if (res) { @@ -823,7 +823,7 @@ /* use the same kind of id the hid driver shows */ snprintf (dev->id, sizeof dev->id, "%s-%s:%d", udev->bus->bus_name, udev->devpath, - intf->altsetting [0].bInterfaceNumber); + intf->altsetting [0].desc.bInterfaceNumber); dev->intf = intf; /* cacheline-aligned scratch for i/o */ diff -Nru a/drivers/usb/net/catc.c b/drivers/usb/net/catc.c --- a/drivers/usb/net/catc.c Wed Oct 30 09:43:59 2002 +++ b/drivers/usb/net/catc.c Wed Oct 30 09:43:59 2002 @@ -783,7 +783,8 @@ u8 broadcast[6]; int i, pktsz; - if (usb_set_interface(usbdev, intf->altsetting->bInterfaceNumber, 1)) { + if (usb_set_interface(usbdev, + intf->altsetting->desc.bInterfaceNumber, 1)) { err("Can't set altsetting 1."); return -EIO; } diff -Nru a/drivers/usb/net/cdc-ether.c b/drivers/usb/net/cdc-ether.c --- a/drivers/usb/net/cdc-ether.c Wed Oct 30 09:43:59 2002 +++ b/drivers/usb/net/cdc-ether.c Wed Oct 30 09:43:59 2002 @@ -723,9 +723,9 @@ static int find_and_parse_ethernet_class_information( struct usb_device *device, ether_dev_t *ether_dev ) { - struct usb_config_descriptor *conf = NULL; + struct usb_host_config *conf = NULL; struct usb_interface *comm_intf_group = NULL; - struct usb_interface_descriptor *comm_intf = NULL; + struct usb_host_interface *comm_intf = NULL; int rc = -1; // The assumption here is that find_ethernet_comm_interface // and find_valid_configuration @@ -760,9 +760,9 @@ static int get_data_interface_endpoints( struct usb_device *device, ether_dev_t *ether_dev ) { - struct usb_config_descriptor *conf = NULL; + struct usb_host_config *conf = NULL; struct usb_interface *data_intf_group = NULL; - struct usb_interface_descriptor *data_intf = NULL; + struct usb_host_interface *data_intf = NULL; // Walk through and get to the data interface we are checking. conf = &( device->config[ether_dev->configuration_num] ); @@ -774,30 +774,30 @@ ether_dev->data_ep_out = 0; // If these are not BULK endpoints, we don't want them - if ( data_intf->endpoint[0].bmAttributes != 0x02 ) { + if ( data_intf->endpoint[0].desc.bmAttributes != 0x02 ) { return -1; - } if ( data_intf->endpoint[1].bmAttributes != 0x02 ) { + } if ( data_intf->endpoint[1].desc.bmAttributes != 0x02 ) { return -1; } // Check the first endpoint to see if it is IN or OUT - if ( data_intf->endpoint[0].bEndpointAddress & 0x80 ) { + if ( data_intf->endpoint[0].desc.bEndpointAddress & 0x80 ) { // This endpoint is IN - ether_dev->data_ep_in = data_intf->endpoint[0].bEndpointAddress & 0x7F; + ether_dev->data_ep_in = data_intf->endpoint[0].desc.bEndpointAddress & 0x7F; } else { // This endpoint is OUT - ether_dev->data_ep_out = data_intf->endpoint[0].bEndpointAddress & 0x7F; - ether_dev->data_ep_out_size = data_intf->endpoint[0].wMaxPacketSize; + ether_dev->data_ep_out = data_intf->endpoint[0].desc.bEndpointAddress & 0x7F; + ether_dev->data_ep_out_size = data_intf->endpoint[0].desc.wMaxPacketSize; } // Check the second endpoint to see if it is IN or OUT - if ( data_intf->endpoint[1].bEndpointAddress & 0x80 ) { + if ( data_intf->endpoint[1].desc.bEndpointAddress & 0x80 ) { // This endpoint is IN - ether_dev->data_ep_in = data_intf->endpoint[1].bEndpointAddress & 0x7F; + ether_dev->data_ep_in = data_intf->endpoint[1].desc.bEndpointAddress & 0x7F; } else { // This endpoint is OUT - ether_dev->data_ep_out = data_intf->endpoint[1].bEndpointAddress & 0x7F; - ether_dev->data_ep_out_size = data_intf->endpoint[1].wMaxPacketSize; + ether_dev->data_ep_out = data_intf->endpoint[1].desc.bEndpointAddress & 0x7F; + ether_dev->data_ep_out_size = data_intf->endpoint[1].desc.wMaxPacketSize; } // Now make sure we got both an IN and an OUT @@ -811,7 +811,7 @@ static int verify_ethernet_data_interface( struct usb_device *device, ether_dev_t *ether_dev ) { - struct usb_config_descriptor *conf = NULL; + struct usb_host_config *conf = NULL; struct usb_interface *data_intf_group = NULL; struct usb_interface_descriptor *data_intf = NULL; int rc = -1; @@ -834,7 +834,7 @@ // Walk through every possible setting for this interface until // we find what makes us happy. for ( altset_num = 0; altset_num < data_intf_group->num_altsetting; altset_num++ ) { - data_intf = &( data_intf_group->altsetting[altset_num] ); + data_intf = &( data_intf_group->altsetting[altset_num].desc ); // Is this a data interface we like? if ( ( data_intf->bInterfaceClass == 0x0A ) @@ -875,7 +875,7 @@ static int find_ethernet_comm_interface( struct usb_device *device, ether_dev_t *ether_dev ) { - struct usb_config_descriptor *conf = NULL; + struct usb_host_config *conf = NULL; struct usb_interface *comm_intf_group = NULL; struct usb_interface_descriptor *comm_intf = NULL; int intf_num; @@ -886,12 +886,12 @@ // We need to check and see if any of these interfaces are something we want. // Walk through each interface one at a time - for ( intf_num = 0; intf_num < conf->bNumInterfaces; intf_num++ ) { + for ( intf_num = 0; intf_num < conf->desc.bNumInterfaces; intf_num++ ) { comm_intf_group = &( conf->interface[intf_num] ); // Now for each of those interfaces, check every possible // alternate setting. for ( altset_num = 0; altset_num < comm_intf_group->num_altsetting; altset_num++ ) { - comm_intf = &( comm_intf_group->altsetting[altset_num] ); + comm_intf = &( comm_intf_group->altsetting[altset_num].desc); // Is this a communication class of interface of the // ethernet subclass variety. @@ -944,7 +944,7 @@ static int find_valid_configuration( struct usb_device *device, ether_dev_t *ether_dev ) { - struct usb_config_descriptor *conf = NULL; + struct usb_host_config *conf = NULL; int conf_num; int rc; @@ -953,7 +953,7 @@ conf = &( device->config[conf_num] ); // Our first requirement : 2 interfaces - if ( conf->bNumInterfaces != 2 ) { + if ( conf->desc.bNumInterfaces != 2 ) { // I currently don't know how to handle devices with any number of interfaces // other than 2. continue; @@ -962,7 +962,7 @@ // This one passed our first check, fill in some // useful data ether_dev->configuration_num = conf_num; - ether_dev->bConfigurationValue = conf->bConfigurationValue; + ether_dev->bConfigurationValue = conf->desc.bConfigurationValue; // Now run it through the ringers and see what comes // out the other side. @@ -983,14 +983,14 @@ // has claimed any of the devices interfaces ///////////////////////////////// ////////////////////////////////////////////////////////////////////////////// -static int check_for_claimed_interfaces( struct usb_config_descriptor *config ) +static int check_for_claimed_interfaces( struct usb_host_config *config ) { struct usb_interface *comm_intf_group; int intf_num; // Go through all the interfaces and make sure none are // claimed by anybody else. - for ( intf_num = 0; intf_num < config->bNumInterfaces; intf_num++ ) { + for ( intf_num = 0; intf_num < config->desc.bNumInterfaces; intf_num++ ) { comm_intf_group = &( config->interface[intf_num] ); if ( usb_interface_claimed( comm_intf_group ) ) { // Somebody has beat us to this guy. diff -Nru a/drivers/usb/net/kaweth.c b/drivers/usb/net/kaweth.c --- a/drivers/usb/net/kaweth.c Wed Oct 30 09:44:00 2002 +++ b/drivers/usb/net/kaweth.c Wed Oct 30 09:44:00 2002 @@ -449,7 +449,7 @@ usb_sndctrlpipe(kaweth->dev, 0), USB_REQ_SET_CONFIGURATION, 0, - kaweth->dev->config[0].bConfigurationValue, + kaweth->dev->config[0].desc.bConfigurationValue, 0, NULL, 0, diff -Nru a/drivers/usb/net/pegasus.c b/drivers/usb/net/pegasus.c --- a/drivers/usb/net/pegasus.c Wed Oct 30 09:44:00 2002 +++ b/drivers/usb/net/pegasus.c Wed Oct 30 09:44:00 2002 @@ -1061,7 +1061,7 @@ pegasus_t *pegasus; int dev_index = id - pegasus_ids; - if (usb_set_configuration(dev, dev->config[0].bConfigurationValue)) { + if (usb_set_configuration(dev, dev->config[0].desc.bConfigurationValue)) { err("usb_set_configuration() failed"); return -ENODEV; } diff -Nru a/drivers/usb/net/rtl8150.c b/drivers/usb/net/rtl8150.c --- a/drivers/usb/net/rtl8150.c Wed Oct 30 09:44:00 2002 +++ b/drivers/usb/net/rtl8150.c Wed Oct 30 09:44:00 2002 @@ -789,7 +789,7 @@ rtl8150_t *dev; struct net_device *netdev; - if (usb_set_configuration(udev, udev->config[0].bConfigurationValue)) { + if (usb_set_configuration(udev, udev->config[0].desc.bConfigurationValue)) { err("usb_set_configuration() failed"); return -EIO; } diff -Nru a/drivers/usb/net/usbnet.c b/drivers/usb/net/usbnet.c --- a/drivers/usb/net/usbnet.c Wed Oct 30 09:44:00 2002 +++ b/drivers/usb/net/usbnet.c Wed Oct 30 09:44:00 2002 @@ -2125,7 +2125,7 @@ { struct usbnet *dev; struct net_device *net; - struct usb_interface_descriptor *interface; + struct usb_host_interface *interface; struct driver_info *info; struct usb_device *xdev; @@ -2135,8 +2135,8 @@ interface = &udev->altsetting [udev->act_altsetting]; if (!(info->flags & FLAG_NO_SETINT)) { - if (usb_set_interface (xdev, interface->bInterfaceNumber, - interface->bAlternateSetting) < 0) { + if (usb_set_interface (xdev, interface->desc.bInterfaceNumber, + interface->desc.bAlternateSetting) < 0) { err ("set_interface failed"); return -EIO; } diff -Nru a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c --- a/drivers/usb/serial/usb-serial.c Wed Oct 30 09:43:59 2002 +++ b/drivers/usb/serial/usb-serial.c Wed Oct 30 09:43:59 2002 @@ -1147,7 +1147,7 @@ struct usb_device *dev = interface_to_usbdev (interface); struct usb_serial *serial = NULL; struct usb_serial_port *port; - struct usb_interface_descriptor *iface_desc; + struct usb_host_interface *iface_desc; struct usb_endpoint_descriptor *endpoint; struct usb_endpoint_descriptor *interrupt_in_endpoint[MAX_NUM_PORTS]; struct usb_endpoint_descriptor *bulk_in_endpoint[MAX_NUM_PORTS]; @@ -1208,8 +1208,8 @@ /* descriptor matches, let's find the endpoints needed */ /* check out the endpoints */ iface_desc = &interface->altsetting[0]; - for (i = 0; i < iface_desc->bNumEndpoints; ++i) { - endpoint = &iface_desc->endpoint[i]; + for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) { + endpoint = &iface_desc->endpoint[i].desc; if ((endpoint->bEndpointAddress & 0x80) && ((endpoint->bmAttributes & 3) == 0x02)) { @@ -1249,7 +1249,7 @@ //interface = &dev->actconfig->interface[ifnum ^ 1]; interface = &dev->actconfig->interface[0]; iface_desc = &interface->altsetting[0]; - for (i = 0; i < iface_desc->bNumEndpoints; ++i) { + for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) { endpoint = &iface_desc->endpoint[i]; if ((endpoint->bEndpointAddress & 0x80) && ((endpoint->bmAttributes & 3) == 0x03)) { diff -Nru a/drivers/usb/storage/scsiglue.c b/drivers/usb/storage/scsiglue.c --- a/drivers/usb/storage/scsiglue.c Wed Oct 30 09:44:00 2002 +++ b/drivers/usb/storage/scsiglue.c Wed Oct 30 09:44:00 2002 @@ -249,7 +249,7 @@ /* FIXME: This needs to lock out driver probing while it's working * or we can have race conditions */ /* This functionality really should be provided by the khubd thread */ - for (i = 0; i < pusb_dev_save->actconfig->bNumInterfaces; i++) { + for (i = 0; i < pusb_dev_save->actconfig->desc.bNumInterfaces; i++) { struct usb_interface *intf = &pusb_dev_save->actconfig->interface[i]; diff -Nru a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c --- a/drivers/usb/storage/usb.c Wed Oct 30 09:43:59 2002 +++ b/drivers/usb/storage/usb.c Wed Oct 30 09:43:59 2002 @@ -646,7 +646,7 @@ const struct usb_device_id *id) { struct usb_device *dev = interface_to_usbdev(intf); - int ifnum = intf->altsetting->bInterfaceNumber; + int ifnum = intf->altsetting->desc.bInterfaceNumber; int i; const int id_index = id - storage_usb_ids; char mf[USB_STOR_STRING_LEN]; /* manufacturer */ @@ -671,7 +671,7 @@ /* the altsetting on the interface we're probing that matched our * usb_match_id table */ - struct usb_interface_descriptor *altsetting = + struct usb_host_interface *altsetting = intf[ifnum].altsetting + intf[ifnum].act_altsetting; US_DEBUGP("act_altsetting is %d\n", intf[ifnum].act_altsetting); @@ -716,22 +716,25 @@ * An optional interrupt is OK (necessary for CBI protocol). * We will ignore any others. */ - for (i = 0; i < altsetting->bNumEndpoints; i++) { + for (i = 0; i < altsetting->desc.bNumEndpoints; i++) { + struct usb_endpoint_descriptor *ep; + + ep = &altsetting->endpoint[i].desc; + /* is it an BULK endpoint? */ - if ((altsetting->endpoint[i].bmAttributes & - USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_BULK) { + if ((ep->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) + == USB_ENDPOINT_XFER_BULK) { /* BULK in or out? */ - if (altsetting->endpoint[i].bEndpointAddress & - USB_DIR_IN) - ep_in = &altsetting->endpoint[i]; + if (ep->bEndpointAddress & USB_DIR_IN) + ep_in = ep; else - ep_out = &altsetting->endpoint[i]; + ep_out = ep; } /* is it an interrupt endpoint? */ - if ((altsetting->endpoint[i].bmAttributes & - USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_INT) { - ep_int = &altsetting->endpoint[i]; + else if ((ep->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) + == USB_ENDPOINT_XFER_INT) { + ep_int = ep; } } US_DEBUGP("Endpoints: In: 0x%p Out: 0x%p Int: 0x%p (Period %d)\n", diff -Nru a/drivers/usb/usb-skeleton.c b/drivers/usb/usb-skeleton.c --- a/drivers/usb/usb-skeleton.c Wed Oct 30 09:43:59 2002 +++ b/drivers/usb/usb-skeleton.c Wed Oct 30 09:43:59 2002 @@ -555,7 +555,7 @@ /* check out the endpoints */ iface_desc = &interface->altsetting[0]; for (i = 0; i < iface_desc->bNumEndpoints; ++i) { - endpoint = &iface_desc->endpoint[i]; + endpoint = &iface_desc->endpoint[i].desc; if ((endpoint->bEndpointAddress & 0x80) && ((endpoint->bmAttributes & 3) == 0x02)) { diff -Nru a/include/linux/usb.h b/include/linux/usb.h --- a/include/linux/usb.h Wed Oct 30 09:43:59 2002 +++ b/include/linux/usb.h Wed Oct 30 09:43:59 2002 @@ -41,56 +41,36 @@ /*-------------------------------------------------------------------------*/ /* - * Standard USB Descriptor support. + * Host-side wrappers for standard USB descriptors ... these are parsed + * from the data provided by devices. Parsing turns them from a flat + * sequence of descriptors into a hierarchy: + * + * - devices have one (usually) or more configs; + * - configs have one (often) or more interfaces; + * - interfaces have one (usually) or more settings; + * - each interface setting has zero or (usually) more endpoints. + * + * And there might be other descriptors mixed in with those. + * * Devices may also have class-specific or vendor-specific descriptors. */ -/* - * Descriptor sizes per descriptor type - */ -#define USB_DT_DEVICE_SIZE 18 -#define USB_DT_CONFIG_SIZE 9 -#define USB_DT_INTERFACE_SIZE 9 -#define USB_DT_ENDPOINT_SIZE 7 -#define USB_DT_ENDPOINT_AUDIO_SIZE 9 /* Audio extension */ - -/* most of these maximums are arbitrary */ -#define USB_MAXCONFIG 8 -#define USB_ALTSETTINGALLOC 4 -#define USB_MAXALTSETTING 128 /* Hard limit */ -#define USB_MAXINTERFACES 32 -#define USB_MAXENDPOINTS 32 /* Hard limit */ - -/* USB_DT_ENDPOINT: Endpoint descriptor */ -struct usb_endpoint_descriptor { - __u8 bLength __attribute__ ((packed)); - __u8 bDescriptorType __attribute__ ((packed)); - __u8 bEndpointAddress __attribute__ ((packed)); - __u8 bmAttributes __attribute__ ((packed)); - __u16 wMaxPacketSize __attribute__ ((packed)); - __u8 bInterval __attribute__ ((packed)); - __u8 bRefresh __attribute__ ((packed)); - __u8 bSynchAddress __attribute__ ((packed)); +/* host-side wrapper for parsed endpoint descriptors */ +struct usb_host_endpoint { + struct usb_endpoint_descriptor desc; - /* the rest is internal to the Linux implementation */ unsigned char *extra; /* Extra descriptors */ int extralen; }; -/* USB_DT_INTERFACE: Interface descriptor */ -struct usb_interface_descriptor { - __u8 bLength __attribute__ ((packed)); - __u8 bDescriptorType __attribute__ ((packed)); - __u8 bInterfaceNumber __attribute__ ((packed)); - __u8 bAlternateSetting __attribute__ ((packed)); - __u8 bNumEndpoints __attribute__ ((packed)); - __u8 bInterfaceClass __attribute__ ((packed)); - __u8 bInterfaceSubClass __attribute__ ((packed)); - __u8 bInterfaceProtocol __attribute__ ((packed)); - __u8 iInterface __attribute__ ((packed)); - - /* the rest is internal to the Linux implementation */ - struct usb_endpoint_descriptor *endpoint; +/* host-side wrapper for one interface setting's parsed descriptors */ +struct usb_host_interface { + struct usb_interface_descriptor desc; + + /* array of desc.bNumEndpoint endpoints associated with this + * interface setting. these will be in no particular order. + */ + struct usb_host_endpoint *endpoint; unsigned char *extra; /* Extra descriptors */ int extralen; @@ -127,7 +107,10 @@ * will use them in non-default settings. */ struct usb_interface { - struct usb_interface_descriptor *altsetting; + /* array of alternate settings for this interface. + * these will be in numeric order, 0..num_altsettting + */ + struct usb_host_interface *altsetting; unsigned act_altsetting; /* active alternate setting */ unsigned num_altsetting; /* number of alternate settings */ @@ -148,17 +131,12 @@ * different depending on what speed they're currently running. Only * devices with a USB_DT_DEVICE_QUALIFIER have an OTHER_SPEED_CONFIG. */ -struct usb_config_descriptor { - __u8 bLength __attribute__ ((packed)); - __u8 bDescriptorType __attribute__ ((packed)); - __u16 wTotalLength __attribute__ ((packed)); - __u8 bNumInterfaces __attribute__ ((packed)); - __u8 bConfigurationValue __attribute__ ((packed)); - __u8 iConfiguration __attribute__ ((packed)); - __u8 bmAttributes __attribute__ ((packed)); - __u8 MaxPower __attribute__ ((packed)); +struct usb_host_config { + struct usb_config_descriptor desc; - /* the rest is internal to the Linux implementation */ + /* the interfaces associated with this configuration + * these will be in numeric order, 0..desc.bNumInterfaces + */ struct usb_interface *interface; unsigned char *extra; /* Extra descriptors */ @@ -178,8 +156,6 @@ /* -------------------------------------------------------------------------- */ -/* Host Controller Driver (HCD) support */ - struct usb_operations; /* @@ -248,8 +224,8 @@ struct device dev; /* Generic device interface */ struct usb_device_descriptor descriptor;/* Descriptor */ - struct usb_config_descriptor *config; /* All of the configs */ - struct usb_config_descriptor *actconfig;/* the active configuration */ + struct usb_host_config *config; /* All of the configs */ + struct usb_host_config *actconfig;/* the active configuration */ char **rawdescriptors; /* Raw descriptors for each config */ diff -Nru a/include/linux/usb_ch9.h b/include/linux/usb_ch9.h --- a/include/linux/usb_ch9.h Wed Oct 30 09:43:59 2002 +++ b/include/linux/usb_ch9.h Wed Oct 30 09:43:59 2002 @@ -6,7 +6,7 @@ * * - the master/host side Linux-USB kernel driver API; * - the "usbfs" user space API; and - * - (eventually) a Linux slave/device side driver API. + * - (eventually) a Linux "gadget" slave/device side driver API. * * USB 2.0 adds an additional "On The Go" (OTG) mode, which lets systems * act either as a USB master/host or as a USB slave/device. That means @@ -101,7 +101,8 @@ * (rarely) accepted by SET_DESCRIPTOR. * * Note that all multi-byte values here are encoded in little endian - * byte order. + * byte order "on the wire". But when exposed through Linux-USB APIs, + * they've been converted to cpu byte order. */ /* @@ -123,10 +124,13 @@ } __attribute__ ((packed)); +/*-------------------------------------------------------------------------*/ + /* USB_DT_DEVICE: Device descriptor */ struct usb_device_descriptor { __u8 bLength; __u8 bDescriptorType; + __u16 bcdUSB; __u8 bDeviceClass; __u8 bDeviceSubClass; @@ -141,10 +145,12 @@ __u8 bNumConfigurations; } __attribute__ ((packed)); +#define USB_DT_DEVICE_SIZE 18 + /* * Device and/or Interface Class codes - * as found in device and interface descriptors + * as found in bDeviceClass or bInterfaceClass * and defined by www.usb.org documents */ #define USB_CLASS_PER_INTERFACE 0 /* for DeviceClass */ @@ -162,18 +168,88 @@ #define USB_CLASS_APP_SPEC 0xfe #define USB_CLASS_VENDOR_SPEC 0xff -// FIXME include struct usb_config_descriptor +/*-------------------------------------------------------------------------*/ + +/* USB_DT_CONFIG: Configuration descriptor information. + * + * USB_DT_OTHER_SPEED_CONFIG is the same descriptor, except that the + * descriptor type is different. Highspeed-capable devices can look + * different depending on what speed they're currently running. Only + * devices with a USB_DT_DEVICE_QUALIFIER have any OTHER_SPEED_CONFIG + * descriptors. + */ +struct usb_config_descriptor { + __u8 bLength; + __u8 bDescriptorType; + + __u16 wTotalLength; + __u8 bNumInterfaces; + __u8 bConfigurationValue; + __u8 iConfiguration; + __u8 bmAttributes; + __u8 bMaxPower; +} __attribute__ ((packed)); + +#define USB_DT_CONFIG_SIZE 9 + +/* from config descriptor bmAttributes */ +#define USB_CONFIG_ATT_ONE (1 << 7) /* must be set */ +#define USB_CONFIG_ATT_SELFPOWER (1 << 6) /* self powered */ +#define USB_CONFIG_ATT_WAKEUP (1 << 5) /* can wakeup */ + +/*-------------------------------------------------------------------------*/ /* USB_DT_STRING: String descriptor */ struct usb_string_descriptor { __u8 bLength; __u8 bDescriptorType; + __u16 wData[1]; /* UTF-16LE encoded */ } __attribute__ ((packed)); -// FIXME include struct usb_interface_descriptor +/* note that "string" zero is special, it holds language codes that + * the device supports, not Unicode characters. + */ + +/*-------------------------------------------------------------------------*/ + +/* USB_DT_INTERFACE: Interface descriptor */ +struct usb_interface_descriptor { + __u8 bLength; + __u8 bDescriptorType; + + __u8 bInterfaceNumber; + __u8 bAlternateSetting; + __u8 bNumEndpoints; + __u8 bInterfaceClass; + __u8 bInterfaceSubClass; + __u8 bInterfaceProtocol; + __u8 iInterface; +} __attribute__ ((packed)); + +#define USB_DT_INTERFACE_SIZE 9 + +/*-------------------------------------------------------------------------*/ + +/* USB_DT_ENDPOINT: Endpoint descriptor */ +struct usb_endpoint_descriptor { + __u8 bLength; + __u8 bDescriptorType; + + __u8 bEndpointAddress; + __u8 bmAttributes; + __u16 wMaxPacketSize; + __u8 bInterval; + + // NOTE: these two are _only_ in audio endpoints. + // use USB_DT_ENDPOINT*_SIZE in bLength, not sizeof. + __u8 bRefresh; + __u8 bSynchAddress; +} __attribute__ ((packed)); + +#define USB_DT_ENDPOINT_SIZE 7 +#define USB_DT_ENDPOINT_AUDIO_SIZE 9 /* Audio extension */ -// FIXME include struct usb_endpoint_descriptor /* * Endpoints @@ -188,10 +264,13 @@ #define USB_ENDPOINT_XFER_INT 3 +/*-------------------------------------------------------------------------*/ + /* USB_DT_DEVICE_QUALIFIER: Device Qualifier descriptor */ struct usb_qualifier_descriptor { __u8 bLength; __u8 bDescriptorType; + __u16 bcdUSB; __u8 bDeviceClass; __u8 bDeviceSubClass; diff -Nru a/sound/usb/usbaudio.c b/sound/usb/usbaudio.c --- a/sound/usb/usbaudio.c Wed Oct 30 09:44:00 2002 +++ b/sound/usb/usbaudio.c Wed Oct 30 09:44:00 2002 @@ -933,8 +933,8 @@ static int set_format(snd_usb_substream_t *subs, snd_pcm_runtime_t *runtime) { struct usb_device *dev = subs->dev; - struct usb_config_descriptor *config = dev->actconfig; - struct usb_interface_descriptor *alts; + struct usb_host_config *config = dev->actconfig; + struct usb_host_interface *alts; struct usb_interface *iface; struct audioformat *fmt; unsigned int ep, attr; @@ -951,7 +951,7 @@ iface = &config->interface[fmt->iface]; alts = &iface->altsetting[fmt->altset_idx]; - snd_assert(alts->bAlternateSetting == fmt->altsetting, return -EINVAL); + snd_assert(alts->desc.bAlternateSetting == fmt->altsetting, return -EINVAL); /* close the old interface */ if (subs->interface >= 0 && subs->interface != fmt->iface) { @@ -973,31 +973,31 @@ } /* create a data pipe */ - ep = alts->endpoint[0].bEndpointAddress & USB_ENDPOINT_NUMBER_MASK; + ep = alts->endpoint[0].desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK; if (is_playback) subs->datapipe = usb_sndisocpipe(dev, ep); else subs->datapipe = usb_rcvisocpipe(dev, ep); subs->syncpipe = subs->syncinterval = 0; - subs->maxpacksize = alts->endpoint[0].wMaxPacketSize; + subs->maxpacksize = alts->endpoint[0].desc.wMaxPacketSize; subs->maxframesize = bytes_to_frames(runtime, subs->maxpacksize); subs->fill_max = 0; /* we need a sync pipe in async OUT or adaptive IN mode */ - attr = alts->endpoint[0].bmAttributes & EP_ATTR_MASK; + attr = alts->endpoint[0].desc.bmAttributes & EP_ATTR_MASK; if ((is_playback && attr == EP_ATTR_ASYNC) || (! is_playback && attr == EP_ATTR_ADAPTIVE)) { /* check endpoint */ - if (alts->bNumEndpoints < 2 || - alts->endpoint[1].bmAttributes != 0x01 || - alts->endpoint[1].bSynchAddress != 0) { + if (alts->desc.bNumEndpoints < 2 || + alts->endpoint[1].desc.bmAttributes != 0x01 || + alts->endpoint[1].desc.bSynchAddress != 0) { snd_printk(KERN_ERR "%d:%d:%d : invalid synch pipe\n", dev->devnum, fmt->iface, fmt->altsetting); return -EINVAL; } - ep = alts->endpoint[1].bEndpointAddress; - if ((is_playback && ep != (alts->endpoint[0].bSynchAddress | USB_DIR_IN)) || - (! is_playback && ep != (alts->endpoint[0].bSynchAddress & ~USB_DIR_IN))) { + ep = alts->endpoint[1].desc.bEndpointAddress; + if ((is_playback && ep != (alts->endpoint[0].desc.bSynchAddress | USB_DIR_IN)) || + (! is_playback && ep != (alts->endpoint[0].desc.bSynchAddress & ~USB_DIR_IN))) { snd_printk(KERN_ERR "%d:%d:%d : invalid synch pipe\n", dev->devnum, fmt->iface, fmt->altsetting); return -EINVAL; @@ -1007,10 +1007,10 @@ subs->syncpipe = usb_rcvisocpipe(dev, ep); else subs->syncpipe = usb_sndisocpipe(dev, ep); - subs->syncinterval = alts->endpoint[1].bRefresh; + subs->syncinterval = alts->endpoint[1].desc.bRefresh; } - ep = alts->endpoint[0].bEndpointAddress; + ep = alts->endpoint[0].desc.bEndpointAddress; /* if endpoint has pitch control, enable it */ if (fmt->attributes & EP_CS_ATTR_PITCH_CONTROL) { data[0] = 1; @@ -1673,9 +1673,9 @@ static int parse_audio_endpoints(snd_usb_audio_t *chip, unsigned char *buffer, int buflen, int iface_no) { struct usb_device *dev; - struct usb_config_descriptor *config; + struct usb_host_config *config; struct usb_interface *iface; - struct usb_interface_descriptor *alts; + struct usb_host_interface *alts; int i, altno, err, stream; int channels, nr_rates, pcm_format, format; struct audioformat *fp; @@ -1689,18 +1689,18 @@ for (i = 0; i < iface->num_altsetting; i++) { alts = &iface->altsetting[i]; /* skip invalid one */ - if (alts->bInterfaceClass != USB_CLASS_AUDIO || - alts->bInterfaceSubClass != USB_SUBCLASS_AUDIO_STREAMING || - alts->bNumEndpoints < 1) + if (alts->desc.bInterfaceClass != USB_CLASS_AUDIO || + alts->desc.bInterfaceSubClass != USB_SUBCLASS_AUDIO_STREAMING || + alts->desc.bNumEndpoints < 1) continue; /* must be isochronous */ - if ((alts->endpoint[0].bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) != + if ((alts->endpoint[0].desc.bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) != USB_ENDPOINT_XFER_ISOC) continue; /* check direction */ - stream = (alts->endpoint[0].bEndpointAddress & USB_DIR_IN) ? + stream = (alts->endpoint[0].desc.bEndpointAddress & USB_DIR_IN) ? SNDRV_PCM_STREAM_CAPTURE : SNDRV_PCM_STREAM_PLAYBACK; - altno = alts->bAlternateSetting; + altno = alts->desc.bAlternateSetting; /* get audio formats */ fmt = snd_usb_find_csint_desc(buffer, buflen, NULL, AS_GENERAL, iface_no, altno); @@ -1767,8 +1767,8 @@ fp->altsetting = altno; fp->altset_idx = i; fp->format = pcm_format; - fp->endpoint = alts->endpoint[0].bEndpointAddress; - fp->ep_attr = alts->endpoint[0].bmAttributes; + fp->endpoint = alts->endpoint[0].desc.bEndpointAddress; + fp->ep_attr = alts->endpoint[0].desc.bmAttributes; fp->channels = channels; fp->attributes = csep[3]; @@ -1837,7 +1837,7 @@ unsigned char *buffer, int buflen) { struct usb_device *dev = chip->dev; - struct usb_config_descriptor *config; + struct usb_host_config *config; struct usb_interface *iface; unsigned char *p1; int i, j; @@ -1858,7 +1858,7 @@ config = dev->actconfig; for (i = 0; i < p1[7]; i++) { j = p1[8 + i]; - if (j >= config->bNumInterfaces) { + if (j >= config->desc.bNumInterfaces) { snd_printk(KERN_ERR "%d:%u:%d : does not exist\n", dev->devnum, ctrlif, j); continue; @@ -1868,8 +1868,8 @@ snd_printdd(KERN_INFO "%d:%d:%d: skipping, already claimed\n", dev->devnum, ctrlif, j); continue; } - if (iface->altsetting[0].bInterfaceClass == USB_CLASS_AUDIO && - iface->altsetting[0].bInterfaceSubClass == USB_SUBCLASS_MIDI_STREAMING) { + if (iface->altsetting[0].desc.bInterfaceClass == USB_CLASS_AUDIO && + iface->altsetting[0].desc.bInterfaceSubClass == USB_SUBCLASS_MIDI_STREAMING) { if (snd_usb_create_midi_interface(chip, iface, NULL) < 0) { snd_printk(KERN_ERR "%d:%u:%d: cannot create sequencer device\n", dev->devnum, ctrlif, j); continue; @@ -1877,8 +1877,8 @@ usb_driver_claim_interface(&usb_audio_driver, iface, (void *)-1); continue; } - if (iface->altsetting[0].bInterfaceClass != USB_CLASS_AUDIO || - iface->altsetting[0].bInterfaceSubClass != USB_SUBCLASS_AUDIO_STREAMING) { + if (iface->altsetting[0].desc.bInterfaceClass != USB_CLASS_AUDIO || + iface->altsetting[0].desc.bInterfaceSubClass != USB_SUBCLASS_AUDIO_STREAMING) { snd_printdd(KERN_ERR "%d:%u:%d: skipping non-supported interface %d\n", dev->devnum, ctrlif, j, iface->altsetting[0].bInterfaceClass); /* skip non-supported classes */ continue; diff -Nru a/sound/usb/usbmidi.c b/sound/usb/usbmidi.c --- a/sound/usb/usbmidi.c Wed Oct 30 09:44:00 2002 +++ b/sound/usb/usbmidi.c Wed Oct 30 09:44:00 2002 @@ -526,20 +526,20 @@ return NULL; intfd = &intf->altsetting[0]; - if (intfd->bNumEndpoints != 2 || - (intfd->endpoint[0].bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) != USB_ENDPOINT_XFER_BULK || - (intfd->endpoint[1].bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) != USB_ENDPOINT_XFER_BULK) + if (intfd->desc.bNumEndpoints != 2 || + (intfd->endpoint[0].desc.bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) != USB_ENDPOINT_XFER_BULK || + (intfd->endpoint[1].desc.bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) != USB_ENDPOINT_XFER_BULK) return NULL; intfd = &intf->altsetting[1]; - if (intfd->bNumEndpoints != 2 || - (intfd->endpoint[0].bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) != USB_ENDPOINT_XFER_BULK || - (intfd->endpoint[1].bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) != USB_ENDPOINT_XFER_INT) + if (intfd->desc.bNumEndpoints != 2 || + (intfd->endpoint[0].desc.bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) != USB_ENDPOINT_XFER_BULK || + (intfd->endpoint[1].desc.bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) != USB_ENDPOINT_XFER_INT) return NULL; - usb_set_interface(umidi->chip->dev, intfd->bInterfaceNumber, - intfd->bAlternateSetting); - return &intfd->endpoint[1]; + usb_set_interface(umidi->chip->dev, intfd->desc.bInterfaceNumber, + intfd->desc.bAlternateSetting); + return &intfd->endpoint[1].desc; } static struct usb_endpoint_descriptor* snd_usbmidi_get_midiman_int_epd(snd_usb_midi_t* umidi) @@ -547,7 +547,7 @@ struct usb_interface* intf = umidi->iface; if (!intf || intf->altsetting[0].bNumEndpoints < 1) return NULL; - return &intf->altsetting[0].endpoint[0]; + return &intf->altsetting[0].endpoint[0].desc; } /* @@ -843,9 +843,9 @@ if (!intf || intf->num_altsetting < 1) return -ENOENT; intfd = intf->altsetting; - if (intfd->bNumEndpoints < 1) + if (intfd->desc.bNumEndpoints < 1) return -ENOENT; - epd = intfd->endpoint; + epd = &intfd->endpoint [0].desc; endpoint->epnum = epd->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK; } return 0; @@ -900,25 +900,25 @@ if (!intf) return -ENOENT; intfd = intf->altsetting; - if (intfd->bNumEndpoints < (ports > 1 ? 5 : 3)) { + if (intfd->desc.bNumEndpoints < (ports > 1 ? 5 : 3)) { snd_printdd(KERN_ERR "not enough endpoints\n"); return -ENOENT; } - epd = &intfd->endpoint[0]; + epd = &intfd->endpoint[0].desc; if ((epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) != USB_DIR_IN || (epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) != USB_ENDPOINT_XFER_INT) { snd_printdd(KERN_ERR "endpoint[0] isn't interrupt\n"); return -ENXIO; } - epd = &intfd->endpoint[2]; + epd = &intfd->endpoint[2].desc; if ((epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) != USB_DIR_OUT || (epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) != USB_ENDPOINT_XFER_BULK) { snd_printdd(KERN_ERR "endpoint[2] isn't bulk output\n"); return -ENXIO; } if (ports > 1) { - epd = &intfd->endpoint[4]; + epd = &intfd->endpoint[4].desc; if ((epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) != USB_DIR_OUT || (epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) != USB_ENDPOINT_XFER_BULK) { snd_printdd(KERN_ERR "endpoint[4] isn't bulk output\n"); @@ -926,13 +926,13 @@ } } - ep_info.epnum = intfd->endpoint[2].bEndpointAddress & USB_ENDPOINT_NUMBER_MASK; + ep_info.epnum = intfd->endpoint[2].desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK; ep_info.out_cables = 0x5555 & ((1 << ports) - 1); err = snd_usbmidi_out_endpoint_create(umidi, &ep_info, &umidi->endpoints[0]); if (err < 0) return err; - ep_info.epnum = intfd->endpoint[0].bEndpointAddress & USB_ENDPOINT_NUMBER_MASK; + ep_info.epnum = intfd->endpoint[0].desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK; ep_info.in_cables = (1 << ports) - 1; err = snd_usbmidi_in_endpoint_create(umidi, &ep_info, &umidi->endpoints[0]); if (err < 0) @@ -940,7 +940,7 @@ umidi->endpoints[0].in->urb->complete = snd_usbmidi_in_midiman_complete; if (ports > 1) { - ep_info.epnum = intfd->endpoint[4].bEndpointAddress & USB_ENDPOINT_NUMBER_MASK; + ep_info.epnum = intfd->endpoint[4].desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK; ep_info.out_cables = 0xaaaa & ((1 << ports) - 1); err = snd_usbmidi_out_endpoint_create(umidi, &ep_info, &umidi->endpoints[1]); if (err < 0)