2 * debug.c - USB debug helper routines.
4 * I just want these out of the way where they aren't in your
5 * face, but so that you can still use them..
7 #define CONFIG_USB_DEBUG
9 #include <linux/config.h>
10 #include <linux/kernel.h>
12 #include <linux/slab.h>
13 #ifdef CONFIG_USB_DEBUG
18 #include <linux/usb.h>
20 #include "../miniport/usb_wrapper.h"
23 static void usb_show_endpoint(struct usb_host_endpoint
*endpoint
)
25 usb_show_endpoint_descriptor(&endpoint
->desc
);
28 static void usb_show_interface(struct usb_host_interface
*altsetting
)
32 usb_show_interface_descriptor(&altsetting
->desc
);
34 for (i
= 0; i
< altsetting
->desc
.bNumEndpoints
; i
++)
35 usb_show_endpoint(altsetting
->endpoint
+ i
);
38 static void usb_show_config(struct usb_host_config
*config
)
41 struct usb_interface
*ifp
;
43 usb_show_config_descriptor(&config
->desc
);
44 for (i
= 0; i
< config
->desc
.bNumInterfaces
; i
++) {
45 ifp
= config
->interface
+ i
;
50 printk("\n Interface: %d\n", i
);
51 for (j
= 0; j
< ifp
->num_altsetting
; j
++)
52 usb_show_interface(ifp
->altsetting
+ j
);
56 void usb_show_device(struct usb_device
*dev
)
60 usb_show_device_descriptor(&dev
->descriptor
);
61 for (i
= 0; i
< dev
->descriptor
.bNumConfigurations
; i
++)
62 usb_show_config(dev
->config
+ i
);
66 * Parse and show the different USB descriptors.
68 void usb_show_device_descriptor(struct usb_device_descriptor
*desc
)
72 printk("Invalid USB device descriptor (NULL POINTER)\n");
75 printk(" Length = %2d%s\n", desc
->bLength
,
76 desc
->bLength
== USB_DT_DEVICE_SIZE
? "" : " (!!!)");
77 printk(" DescriptorType = %02x\n", desc
->bDescriptorType
);
79 printk(" USB version = %x.%02x\n",
80 desc
->bcdUSB
>> 8, desc
->bcdUSB
& 0xff);
81 printk(" Vendor:Product = %04x:%04x\n",
82 desc
->idVendor
, desc
->idProduct
);
83 printk(" MaxPacketSize0 = %d\n", desc
->bMaxPacketSize0
);
84 printk(" NumConfigurations = %d\n", desc
->bNumConfigurations
);
85 printk(" Device version = %x.%02x\n",
86 desc
->bcdDevice
>> 8, desc
->bcdDevice
& 0xff);
88 printk(" Device Class:SubClass:Protocol = %02x:%02x:%02x\n",
89 desc
->bDeviceClass
, desc
->bDeviceSubClass
, desc
->bDeviceProtocol
);
90 switch (desc
->bDeviceClass
) {
92 printk(" Per-interface classes\n");
95 printk(" Audio device class\n");
98 printk(" Communications class\n");
101 printk(" Human Interface Devices class\n");
103 case USB_CLASS_PRINTER
:
104 printk(" Printer device class\n");
106 case USB_CLASS_MASS_STORAGE
:
107 printk(" Mass Storage device class\n");
110 printk(" Hub device class\n");
112 case USB_CLASS_VENDOR_SPEC
:
113 printk(" Vendor class\n");
116 printk(" Unknown class\n");
120 void usb_show_config_descriptor(struct usb_config_descriptor
*desc
)
122 printk("Configuration:\n");
123 printk(" bLength = %4d%s\n", desc
->bLength
,
124 desc
->bLength
== USB_DT_CONFIG_SIZE
? "" : " (!!!)");
125 printk(" bDescriptorType = %02x\n", desc
->bDescriptorType
);
126 printk(" wTotalLength = %04x\n", desc
->wTotalLength
);
127 printk(" bNumInterfaces = %02x\n", desc
->bNumInterfaces
);
128 printk(" bConfigurationValue = %02x\n", desc
->bConfigurationValue
);
129 printk(" iConfiguration = %02x\n", desc
->iConfiguration
);
130 printk(" bmAttributes = %02x\n", desc
->bmAttributes
);
131 printk(" bMaxPower = %4dmA\n", desc
->bMaxPower
* 2);
134 void usb_show_interface_descriptor(struct usb_interface_descriptor
*desc
)
136 printk(" Alternate Setting: %2d\n", desc
->bAlternateSetting
);
137 printk(" bLength = %4d%s\n", desc
->bLength
,
138 desc
->bLength
== USB_DT_INTERFACE_SIZE
? "" : " (!!!)");
139 printk(" bDescriptorType = %02x\n", desc
->bDescriptorType
);
140 printk(" bInterfaceNumber = %02x\n", desc
->bInterfaceNumber
);
141 printk(" bAlternateSetting = %02x\n", desc
->bAlternateSetting
);
142 printk(" bNumEndpoints = %02x\n", desc
->bNumEndpoints
);
143 printk(" bInterface Class:SubClass:Protocol = %02x:%02x:%02x\n",
144 desc
->bInterfaceClass
, desc
->bInterfaceSubClass
, desc
->bInterfaceProtocol
);
145 printk(" iInterface = %02x\n", desc
->iInterface
);
148 void usb_show_endpoint_descriptor(struct usb_endpoint_descriptor
*desc
)
150 char *LengthCommentString
= (desc
->bLength
==
151 USB_DT_ENDPOINT_AUDIO_SIZE
) ? " (Audio)" : (desc
->bLength
==
152 USB_DT_ENDPOINT_SIZE
) ? "" : " (!!!)";
153 char *EndpointType
[4] = { "Control", "Isochronous", "Bulk", "Interrupt" };
155 printk(" Endpoint:\n");
156 printk(" bLength = %4d%s\n",
157 desc
->bLength
, LengthCommentString
);
158 printk(" bDescriptorType = %02x\n", desc
->bDescriptorType
);
159 printk(" bEndpointAddress = %02x (%s)\n", desc
->bEndpointAddress
,
160 (desc
->bmAttributes
& USB_ENDPOINT_XFERTYPE_MASK
) ==
161 USB_ENDPOINT_XFER_CONTROL
? "i/o" :
162 (desc
->bEndpointAddress
& USB_ENDPOINT_DIR_MASK
) ? "in" : "out");
163 printk(" bmAttributes = %02x (%s)\n", desc
->bmAttributes
,
164 EndpointType
[USB_ENDPOINT_XFERTYPE_MASK
& desc
->bmAttributes
]);
165 printk(" wMaxPacketSize = %04x\n", desc
->wMaxPacketSize
);
166 printk(" bInterval = %02x\n", desc
->bInterval
);
168 /* Audio extensions to the endpoint descriptor */
169 if (desc
->bLength
== USB_DT_ENDPOINT_AUDIO_SIZE
) {
170 printk(" bRefresh = %02x\n", desc
->bRefresh
);
171 printk(" bSynchAddress = %02x\n", desc
->bSynchAddress
);
175 void usb_show_string(struct usb_device
*dev
, char *id
, int index
)
181 if (!(buf
= kmalloc(256, GFP_KERNEL
)))
183 if (usb_string(dev
, index
, buf
, 256) > 0)
184 dev_printk(KERN_INFO
, &dev
->dev
, "%s: %s\n", id
, buf
);
188 void usb_dump_urb (struct urb
*urb
)
190 printk ("urb :%p\n", urb
);
191 printk ("dev :%p\n", urb
->dev
);
192 printk ("pipe :%08X\n", urb
->pipe
);
193 printk ("status :%d\n", urb
->status
);
194 printk ("transfer_flags :%08X\n", urb
->transfer_flags
);
195 printk ("transfer_buffer :%p\n", urb
->transfer_buffer
);
196 printk ("transfer_buffer_length:%d\n", urb
->transfer_buffer_length
);
197 printk ("actual_length :%d\n", urb
->actual_length
);
198 printk ("setup_packet :%p\n", urb
->setup_packet
);
199 printk ("start_frame :%d\n", urb
->start_frame
);
200 printk ("number_of_packets :%d\n", urb
->number_of_packets
);
201 printk ("interval :%d\n", urb
->interval
);
202 printk ("error_count :%d\n", urb
->error_count
);
203 printk ("context :%p\n", urb
->context
);
204 printk ("complete :%p\n", urb
->complete
);