Skip to content

Commit

Permalink
add device_qualifier logic
Browse files Browse the repository at this point in the history
Unfortunatly it's not in the main config descriptor, we
need to ask for it "special".  That logic has not been
added yet.

Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
gregkh committed Dec 8, 2009
1 parent 9f54c24 commit f6581d3
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 2 deletions.
43 changes: 41 additions & 2 deletions lsusb.c
Expand Up @@ -417,7 +417,45 @@ static void parse_endpoint_descriptor(const unsigned char *descriptor)
printf("\tbInterval\t\t%d\n", bInterval);
}

static void read_raw_usb_descriptor(struct udev_device *device)
static void parse_device_qualifier(struct usb_device *usb_device, const unsigned char *descriptor)
{
struct usb_device_qualifier *dq;
char string[255];
unsigned char bLength = descriptor[0];
unsigned char bDescriptorType = descriptor[1];
unsigned char bcdUSB0 = descriptor[3];
unsigned char bcdUSB1 = descriptor[2];
unsigned char bDeviceClass = descriptor[4];
unsigned char bDeviceSubClass = descriptor[5];
unsigned char bDeviceProtocol = descriptor[6];
unsigned char bMaxPacketSize0 = descriptor[7];
unsigned char bNumConfigurations = descriptor[8];

dq = robust_malloc(sizeof(struct usb_device_qualifier));

#define build_string(name) \
sprintf(string, "%d", name); \
dq->name = strdup(string);

build_string(bLength);
build_string(bDescriptorType);
build_string(bDeviceClass);
build_string(bDeviceSubClass);
build_string(bDeviceProtocol);
build_string(bMaxPacketSize0);
build_string(bNumConfigurations);
sprintf(string, "%2x.%2x", bcdUSB0, bcdUSB1);
dq->bcdUSB = strdup(string);

usb_device->qualifier = dq;

printf("Device Qualifier\n");
printf("\tbLength\t\t\t%s\n", dq->bLength);
printf("\tbDescriptorType\t\t%s\n", dq->bDescriptorType);
printf("\tbcdUSB\t\t%s", dq->bcdUSB);
}

static void read_raw_usb_descriptor(struct udev_device *device, struct usb_device *usb_device)
{
char filename[PATH_MAX];
int file;
Expand Down Expand Up @@ -463,6 +501,7 @@ static void read_raw_usb_descriptor(struct udev_device *device)
break;
case 0x06:
/* device qualifier */
parse_device_qualifier(usb_device, data);
break;
case 0x07:
/* other speed config */
Expand Down Expand Up @@ -523,7 +562,7 @@ static void create_usb_device(struct udev_device *device)
* configurations, interfaces, etc.)
*/
sprintf(file, "%s/descriptors", udev_device_get_syspath(device));
read_raw_usb_descriptor(device);
read_raw_usb_descriptor(device, usb_device);

/* Add the device to the list of global devices in the system */
list_add_tail(&usb_device->list, &usb_devices);
Expand Down
12 changes: 12 additions & 0 deletions usb.h
Expand Up @@ -41,6 +41,17 @@ struct usb_interface {
char *driver;
};

struct usb_device_qualifier {
char *bLength;
char *bDescriptorType;
char *bcdUSB;
char *bDeviceClass;
char *bDeviceSubClass;
char *bDeviceProtocol;
char *bMaxPacketSize0;
char *bNumConfigurations;
};

struct usb_device {
struct list_head list; /* connect devices independant of the bus */
struct list_head interfaces;
Expand Down Expand Up @@ -69,6 +80,7 @@ struct usb_device {
char *serial;

struct usb_endpoint *ep0;
struct usb_device_qualifier *qualifier;
char *name;
char *driver; /* always "usb" but hey, it's nice to be complete */
};
Expand Down

0 comments on commit f6581d3

Please sign in to comment.