Commit 63bc762f authored by David Brownell's avatar David Brownell Committed by Greg Kroah-Hartman

[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.
parent 844acee5
This diff is collapsed.
......@@ -1053,7 +1053,7 @@ static int usb_bluetooth_probe (struct usb_interface *intf,
{
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 @@ static int usb_bluetooth_probe (struct usb_interface *intf,
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)) {
......
......@@ -166,7 +166,9 @@ static struct acm *acm_table[ACM_TTY_MINORS];
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 @@ static int acm_probe (struct usb_interface *intf,
{
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 @@ static int acm_probe (struct usb_interface *intf,
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 @@ static int acm_probe (struct usb_interface *intf,
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 @@ static int acm_probe (struct usb_interface *intf,
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]) {
......
......@@ -1519,7 +1519,7 @@ static int on_bits( unsigned short v )
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 @@ static int get_alt_setting( struct usb_device *d, int ifnum )
epin = -1;
epout = -1;
for ( i=0 ; i<interface->bNumEndpoints ; i++ ) {
ep = &interface->endpoint[i];
for ( i=0 ; i<interface->desc.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 alloc_usb_midi_device( struct usb_device *d, struct usb_midi_state *s
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 @@ static int detect_yamaha_device( struct usb_device *d, unsigned int ifnum, struc
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 @@ static int detect_yamaha_device( struct usb_device *d, unsigned int ifnum, struc
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_vendor_specific_device( struct usb_device *d, unsigned int ifn
**/
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 @@ static int detect_midi_subclass(struct usb_device *d, unsigned int ifnum, struct
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 @@ static int detect_midi_subclass(struct usb_device *d, unsigned int ifnum, struct
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 @@ static int usb_midi_probe(struct usb_interface *intf,
{
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 )
......
......@@ -814,7 +814,7 @@ static int usblp_probe(struct usb_interface *intf,
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_probe(struct usb_interface *intf,
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 @@ static int usblp_select_alts(struct usblp *usblp)
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 @@ static int usblp_select_alts(struct usblp *usblp)
}
/* 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 @@ static int usblp_select_alts(struct usblp *usblp)
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. */
......
......@@ -4,7 +4,16 @@
#include <linux/slab.h>
#include <asm/byteorder.h>
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 @@ static int usb_parse_endpoint(struct usb_endpoint_descriptor *endpoint, unsigned
}
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 @@ static int usb_parse_interface(struct usb_interface *interface, unsigned char *b
{
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 @@ static int usb_parse_interface(struct usb_interface *interface, unsigned char *b
}
while (size > 0) {
struct usb_interface_descriptor *d;
if (interface->num_altsetting >= interface->max_altsetting) {
void *ptr;
int oldmas;
......@@ -141,9 +152,9 @@ static int usb_parse_interface(struct usb_interface *interface, unsigned char *b
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 @@ static int usb_parse_interface(struct usb_interface *interface, unsigned char *b
(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 @@ static int usb_parse_interface(struct usb_interface *interface, unsigned char *b
}
/* 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 @@ void usb_destroy_configuration(struct usb_device *dev)
}
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 @@ void usb_destroy_configuration(struct usb_device *dev)
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 @@ void usb_destroy_configuration(struct usb_device *dev)
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 @@ int usb_get_configuration(struct usb_device *dev)
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);
......
......@@ -234,7 +234,7 @@ static char *usb_dump_endpoint_descriptor (
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 @@ static char *usb_dump_interface(
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 @@ static char *usb_dump_config_descriptor(char *start, char *end, const struct usb
desc->bNumInterfaces,
desc->bConfigurationValue,
desc->bmAttributes,
desc->MaxPower * 2);
desc->bMaxPower * 2);
return start;
}
......@@ -296,7 +296,7 @@ static char *usb_dump_config (
int speed,
char *start,
char *end,
const struct usb_config_descriptor *config,
const struct usb_host_config *config,
int active
)
{
......@@ -307,8 +307,8 @@ static char *usb_dump_config (
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;
......
......@@ -337,7 +337,8 @@ static int claimintf(struct dev_state *ps, unsigned int intf)
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 @@ static int findintfep(struct usb_device *dev, unsigned int ep)
{
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 @@ static int findintfif(struct usb_device *dev, unsigned int ifn)
{
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 @@ static int proc_resetdevice(struct dev_state *ps)
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 */
......
......@@ -33,14 +33,14 @@ show_##field (struct device *dev, char *buf, size_t count, loff_t off) \
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 @@ void usb_create_driverfs_dev_files (struct usb_device *udev)
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 @@ show_##field (struct device *dev, char *buf, size_t count, loff_t off) \
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);
......
......@@ -478,7 +478,7 @@ static void hub_disconnect(struct usb_interface *intf)
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 @@ static int hub_probe(struct usb_interface *intf, const struct usb_device_id *id)
/* 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 @@ int usb_reset_device(struct usb_device *dev)
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) {
......
......@@ -640,31 +640,33 @@ int usb_get_status(struct usb_device *dev, int type, int target, void *data)
// 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; i<dev->actconfig->bNumInterfaces; i++) {
for (i=0; i<dev->actconfig->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; e<as->bNumEndpoints; e++) {
b = ep[e].bEndpointAddress & USB_ENDPOINT_NUMBER_MASK;
if ((ep[e].bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
for (e=0; e<as->desc.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_clear_halt(struct usb_device *dev, int pipe)
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 @@ int usb_set_interface(struct usb_device *dev, int interface, int alternate)
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 @@ int usb_set_interface(struct usb_device *dev, int interface, int alternate)
/* 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 @@ int usb_set_interface(struct usb_device *dev, int interface, int alternate)
*/
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_interface(struct usb_device *dev, int interface, int alternate)
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; i<dev->descriptor.bNumConfigurations; i++) {
if (dev->config[i].bConfigurationValue == configuration) {
if (dev->config[i].desc.bConfigurationValue == configuration) {
cp = &dev->config[i];
break;
}
......
......@@ -16,28 +16,28 @@
#endif
#include <linux/usb.h>
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 @@ void usb_show_config_descriptor(struct usb_config_descriptor *desc)
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)
......
......@@ -233,8 +233,9 @@ struct usb_interface *usb_ifnum_to_if(struct usb_device *dev, unsigned ifnum)
{
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 @@ struct usb_interface *usb_ifnum_to_if(struct usb_device *dev, unsigned ifnum)
* 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 @@ void usb_driver_release_interface(struct usb_driver *driver, struct usb_interfac
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 @@ usb_match_id(struct usb_interface *interface, const struct usb_device_id *id)
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 @@ static int usb_hotplug (struct device *dev, char **envp, int num_envp,
*/
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 @@ void usb_disconnect(struct usb_device **pdev)
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 @@ int usb_new_device(struct usb_device *dev, struct device *parent)
}
/* 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 @@ int usb_new_device(struct usb_device *dev, struct device *parent)
/* 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 @@ int usb_new_device(struct usb_device *dev, struct device *parent)
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);
......
......@@ -35,14 +35,14 @@ hpusbscsi_usb_probe (struct usb_interface *intf,
{
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 @@ hpusbscsi_usb_probe (struct usb_interface *intf,
/* 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 */
......
......@@ -410,7 +410,7 @@ static int mdc800_usb_probe (struct usb_interface *intf,
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 @@ static int mdc800_usb_probe (struct usb_interface *intf,
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 @@ static int mdc800_usb_probe (struct usb_interface *intf,
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 @@ static int mdc800_usb_probe (struct usb_interface *intf,
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;
......
......@@ -851,7 +851,7 @@ static int mts_usb_probe (struct usb_interface *intf,
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 @@ static int mts_usb_probe (struct usb_interface *intf,
/* 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 @@ static int mts_usb_probe (struct usb_interface *intf,
return -ENODEV;
}
ep_out = altsetting->endpoint[i].bEndpointAddress &
ep_out = altsetting->endpoint[i].desc.bEndpointAddress &
USB_ENDPOINT_NUMBER_MASK;
}
}
......
......@@ -839,7 +839,7 @@ probe_scanner(struct usb_interface *intf,
{
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 @@ probe_scanner(struct usb_interface *intf,
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 @@ probe_scanner(struct usb_interface *intf,
* 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 @@ probe_scanner(struct usb_interface *intf,
* 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.");
......
......@@ -313,7 +313,7 @@ aiptek_probe(struct usb_interface *intf,
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();
......
......@@ -1386,7 +1386,7 @@ static void hid_free_buffers(struct usb_device *dev, struct hid_device *hid)
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 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf)
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 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf)
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 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf)
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 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf)
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 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf)
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;
......
......@@ -290,14 +290,14 @@ static void powermate_free_buffers(struct usb_device *udev, struct powermate_dev
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 @@ static int powermate_probe(struct usb_interface *intf, const struct usb_device_i
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)))
......
......@@ -228,7 +228,7 @@ static int usb_kbd_probe(struct usb_interface *iface,
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 @@ static int usb_kbd_probe(struct usb_interface *iface,
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 @@ static int usb_kbd_probe(struct usb_interface *iface,
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);
......
......@@ -121,7 +121,7 @@ static void usb_mouse_close(struct input_dev *dev)
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 @@ static int usb_mouse_probe(struct usb_interface * intf, const struct usb_device_
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)
......
......@@ -561,7 +561,7 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i
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();
......
......@@ -249,7 +249,7 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id
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),
......
......@@ -728,7 +728,7 @@ static int dabusb_probe (struct usb_interface *intf,
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 @@ static int dabusb_probe (struct usb_interface *intf,
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;
}
......
......@@ -3662,7 +3662,7 @@ static int ibmcam_probe(struct usb_interface *intf, const struct usb_device_id *
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 @@ static int ibmcam_probe(struct usb_interface *intf, const struct usb_device_id *
}
/* 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) {
......
......@@ -381,10 +381,10 @@ static int konicawc_start_data(struct uvd *uvd)
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 @@ static int konicawc_probe(struct usb_interface *intf, const struct usb_device_id
}
/* 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 @@ static int konicawc_probe(struct usb_interface *intf, const struct usb_device_id
}
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 @@ static int konicawc_probe(struct usb_interface *intf, const struct usb_device_id
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;
......
......@@ -5988,7 +5988,7 @@ ov518_configure(struct usb_ov511 *ov)
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 @@ ov51x_probe(struct usb_interface *intf,
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)
......
......@@ -761,7 +761,7 @@ static int pwc_isoc_init(struct pwc_device *pdev)
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 @@ static int pwc_isoc_init(struct pwc_device *pdev)
/* 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 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id
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;
......
......@@ -1456,7 +1456,7 @@ static int se401_probe(struct usb_interface *intf,
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 &&
......
......@@ -569,17 +569,17 @@ static int ultracam_probe(struct usb_interface *intf, const struct usb_device_id
}
/* 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 @@ static int ultracam_probe(struct usb_interface *intf, const struct usb_device_id
}
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 @@ static int ultracam_probe(struct usb_interface *intf, const struct usb_device_id
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;
......
......@@ -1253,7 +1253,7 @@ vicam_probe( struct usb_interface *intf, const struct usb_device_id *id)
{
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 @@ vicam_probe( struct usb_interface *intf, const struct usb_device_id *id)
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)) {
......
......@@ -1943,7 +1943,7 @@ static int auerswald_probe (struct usb_interface *intf,
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 */
......
......@@ -290,7 +290,7 @@ brlvger_probe (struct usb_interface *intf,
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 @@ brlvger_probe (struct usb_interface *intf,
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");
......
......@@ -64,7 +64,7 @@ static devfs_handle_t devfs_handle;
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 @@ tiglusb_probe (struct usb_interface *intf,
&& (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;
}
......
......@@ -290,7 +290,7 @@ static int get_altsetting (struct usbtest_dev *dev)
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 @@ static int set_altsetting (struct usbtest_dev *dev, int alternate)
{
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 @@ static int set_altsetting (struct usbtest_dev *dev, int alternate)
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 @@ static int set_altsetting (struct usbtest_dev *dev, int alternate)
/* 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 @@ static int set_altsetting (struct usbtest_dev *dev, int alternate)
/* 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 @@ static int ch9_postconfig (struct usbtest_dev *dev)
/* 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 @@ static int ch9_postconfig (struct usbtest_dev *dev)
/* [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 @@ static int ch9_postconfig (struct usbtest_dev *dev)
// 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 @@ static int usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *b
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 @@ usbtest_probe (struct usb_interface *intf, const struct usb_device_id *id)
/* 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 */
......
......@@ -783,7 +783,8 @@ static int catc_probe(struct usb_interface *intf, const struct usb_device_id *id
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;
}
......
......@@ -723,9 +723,9 @@ static int parse_ethernet_class_information( unsigned char *data, int length, et
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 find_and_parse_ethernet_class_information( struct usb_device *device,
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 @@ static int get_data_interface_endpoints( struct usb_device *device, ether_dev_t
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 get_data_interface_endpoints( struct usb_device *device, ether_dev_t
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 @@ static int verify_ethernet_data_interface( struct usb_device *device, ether_dev_
// 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 verify_ethernet_data_interface( struct usb_device *device, ether_dev_
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 @@ static int find_ethernet_comm_interface( struct usb_device *device, ether_dev_t
// 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_ethernet_comm_interface( struct usb_device *device, ether_dev_t
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 @@ static int find_valid_configuration( struct usb_device *device, ether_dev_t *eth
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 @@ static int find_valid_configuration( struct usb_device *device, ether_dev_t *eth
// 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 @@ static int find_valid_configuration( struct usb_device *device, ether_dev_t *eth
// 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.
......
......@@ -449,7 +449,7 @@ static int kaweth_reset(struct kaweth_device *kaweth)
usb_sndctrlpipe(kaweth->dev, 0),
USB_REQ_SET_CONFIGURATION,
0,
kaweth->dev->config[0].bConfigurationValue,
kaweth->dev->config[0].desc.bConfigurationValue,
0,
NULL,
0,
......
......@@ -1061,7 +1061,7 @@ static int pegasus_probe(struct usb_interface *intf,
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;
}
......
......@@ -789,7 +789,7 @@ static int rtl8150_probe(struct usb_interface *intf,
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;
}
......
......@@ -2125,7 +2125,7 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod)
{
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 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod)
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;
}
......
......@@ -1147,7 +1147,7 @@ int usb_serial_probe(struct usb_interface *interface,
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 @@ int usb_serial_probe(struct usb_interface *interface,
/* 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 @@ int usb_serial_probe(struct usb_interface *interface,
//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)) {
......
......@@ -249,7 +249,7 @@ static int bus_reset( Scsi_Cmnd *srb )
/* 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];
......
......@@ -646,7 +646,7 @@ static int storage_probe(struct usb_interface *intf,
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 @@ static int storage_probe(struct usb_interface *intf,
/* 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 @@ static int storage_probe(struct usb_interface *intf,
* 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",
......
......@@ -555,7 +555,7 @@ static int skel_probe(struct usb_interface *interface, const struct usb_device_i
/* 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)) {
......
......@@ -41,56 +41,36 @@ struct usb_device;
/*-------------------------------------------------------------------------*/
/*
* 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));
/* the rest is internal to the Linux implementation */
/* host-side wrapper for parsed endpoint descriptors */
struct usb_host_endpoint {
struct usb_endpoint_descriptor desc;
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 @@ struct usb_interface_descriptor {
* 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 @@ struct usb_interface {
* 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));
/* the rest is internal to the Linux implementation */
struct usb_host_config {
struct usb_config_descriptor desc;
/* 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 @@ int __usb_get_extra_descriptor(char *buffer, unsigned size,
/* -------------------------------------------------------------------------- */
/* Host Controller Driver (HCD) support */
struct usb_operations;
/*
......@@ -248,8 +224,8 @@ struct usb_device {
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 */
......
......@@ -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 @@ struct usb_ctrlrequest {
* (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 @@ struct usb_descriptor_header {
} __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 @@ struct usb_device_descriptor {
__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 @@ struct usb_device_descriptor {
#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 @@ struct usb_string_descriptor {
#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;
......
......@@ -933,8 +933,8 @@ static struct audioformat *find_format(snd_usb_substream_t *subs, snd_pcm_runtim
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 @@ static int set_format(snd_usb_substream_t *subs, snd_pcm_runtime_t *runtime)
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 @@ static int set_format(snd_usb_substream_t *subs, snd_pcm_runtime_t *runtime)
}
/* 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 @@ static int set_format(snd_usb_substream_t *subs, snd_pcm_runtime_t *runtime)
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_format_type(struct usb_device *dev, int iface_no, int alt
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 @@ static int parse_audio_endpoints(snd_usb_audio_t *chip, unsigned char *buffer, i
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 @@ static int parse_audio_endpoints(snd_usb_audio_t *chip, unsigned char *buffer, i
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 @@ static int snd_usb_create_streams(snd_usb_audio_t *chip, int ctrlif,
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 @@ static int snd_usb_create_streams(snd_usb_audio_t *chip, int ctrlif,
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 @@ static int snd_usb_create_streams(snd_usb_audio_t *chip, int ctrlif,
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 @@ static int snd_usb_create_streams(snd_usb_audio_t *chip, int ctrlif,
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;
......
......@@ -526,20 +526,20 @@ static struct usb_endpoint_descriptor* snd_usbmidi_get_int_epd(snd_usb_midi_t* u
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 @@ static struct usb_endpoint_descriptor* snd_usbmidi_get_midiman_int_epd(snd_usb_m
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 @@ static int snd_usbmidi_detect_endpoint(snd_usb_midi_t* umidi,
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 @@ static int snd_usbmidi_create_endpoints_midiman(snd_usb_midi_t* umidi, int ports
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 @@ static int snd_usbmidi_create_endpoints_midiman(snd_usb_midi_t* umidi, int ports
}
}
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 @@ static int snd_usbmidi_create_endpoints_midiman(snd_usb_midi_t* umidi, int ports
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)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment