~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Linux Cross Reference
Linux/drivers/usb/usb-debug.c

Version: ~ [ 2.4.0 ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2  * debug.c - USB debug helper routines.
  3  *
  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..
  6  */
  7 #include <linux/config.h>
  8 #include <linux/version.h>
  9 #include <linux/kernel.h>
 10 #include <linux/mm.h>
 11 #include <linux/malloc.h>
 12 #ifdef CONFIG_USB_DEBUG
 13         #define DEBUG
 14 #else
 15         #undef DEBUG
 16 #endif
 17 #include <linux/usb.h>
 18 
 19 static void usb_show_endpoint(struct usb_endpoint_descriptor *endpoint)
 20 {
 21         usb_show_endpoint_descriptor(endpoint);
 22 }
 23 
 24 static void usb_show_interface(struct usb_interface_descriptor *altsetting)
 25 {
 26         int i;
 27 
 28         usb_show_interface_descriptor(altsetting);
 29 
 30         for (i = 0; i < altsetting->bNumEndpoints; i++)
 31                 usb_show_endpoint(altsetting->endpoint + i);
 32 }
 33 
 34 static void usb_show_config(struct usb_config_descriptor *config)
 35 {
 36         int i, j;
 37         struct usb_interface *ifp;
 38 
 39         usb_show_config_descriptor(config);
 40         for (i = 0; i < config->bNumInterfaces; i++) {
 41                 ifp = config->interface + i;
 42 
 43                 if (!ifp)
 44                         break;
 45 
 46                 printk("\n  Interface: %d\n", i);
 47                 for (j = 0; j < ifp->num_altsetting; j++)
 48                         usb_show_interface(ifp->altsetting + j);
 49         }
 50 }
 51 
 52 void usb_show_device(struct usb_device *dev)
 53 {
 54         int i;
 55 
 56         usb_show_device_descriptor(&dev->descriptor);
 57         for (i = 0; i < dev->descriptor.bNumConfigurations; i++)
 58                 usb_show_config(dev->config + i);
 59 }
 60 
 61 /*
 62  * Parse and show the different USB descriptors.
 63  */
 64 void usb_show_device_descriptor(struct usb_device_descriptor *desc)
 65 {
 66         if (!desc)
 67         {
 68                 printk("Invalid USB device descriptor (NULL POINTER)\n");
 69                 return;
 70         }
 71         printk("  Length              = %2d%s\n", desc->bLength,
 72                 desc->bLength == USB_DT_DEVICE_SIZE ? "" : " (!!!)");
 73         printk("  DescriptorType      = %02x\n", desc->bDescriptorType);
 74 
 75         printk("  USB version         = %x.%02x\n",
 76                 desc->bcdUSB >> 8, desc->bcdUSB & 0xff);
 77         printk("  Vendor:Product      = %04x:%04x\n",
 78                 desc->idVendor, desc->idProduct);
 79         printk("  MaxPacketSize0      = %d\n", desc->bMaxPacketSize0);
 80         printk("  NumConfigurations   = %d\n", desc->bNumConfigurations);
 81         printk("  Device version      = %x.%02x\n",
 82                 desc->bcdDevice >> 8, desc->bcdDevice & 0xff);
 83 
 84         printk("  Device Class:SubClass:Protocol = %02x:%02x:%02x\n",
 85                 desc->bDeviceClass, desc->bDeviceSubClass, desc->bDeviceProtocol);
 86         switch (desc->bDeviceClass) {
 87         case 0:
 88                 printk("    Per-interface classes\n");
 89                 break;
 90         case USB_CLASS_AUDIO:
 91                 printk("    Audio device class\n");
 92                 break;
 93         case USB_CLASS_COMM:
 94                 printk("    Communications class\n");
 95                 break;
 96         case USB_CLASS_HID:
 97                 printk("    Human Interface Devices class\n");
 98                 break;
 99         case USB_CLASS_PRINTER:
100                 printk("    Printer device class\n");
101                 break;
102         case USB_CLASS_MASS_STORAGE:
103                 printk("    Mass Storage device class\n");
104                 break;
105         case USB_CLASS_HUB:
106                 printk("    Hub device class\n");
107                 break;
108         case USB_CLASS_VENDOR_SPEC:
109                 printk("    Vendor class\n");
110                 break;
111         default:
112                 printk("    Unknown class\n");
113         }
114 }
115 
116 void usb_show_config_descriptor(struct usb_config_descriptor *desc)
117 {
118         printk("Configuration:\n");
119         printk("  bLength             = %4d%s\n", desc->bLength,
120                 desc->bLength == USB_DT_CONFIG_SIZE ? "" : " (!!!)");
121         printk("  bDescriptorType     =   %02x\n", desc->bDescriptorType);
122         printk("  wTotalLength        = %04x\n", desc->wTotalLength);
123         printk("  bNumInterfaces      =   %02x\n", desc->bNumInterfaces);
124         printk("  bConfigurationValue =   %02x\n", desc->bConfigurationValue);
125         printk("  iConfiguration      =   %02x\n", desc->iConfiguration);
126         printk("  bmAttributes        =   %02x\n", desc->bmAttributes);
127         printk("  MaxPower            = %4dmA\n", desc->MaxPower * 2);
128 }
129 
130 void usb_show_interface_descriptor(struct usb_interface_descriptor *desc)
131 {
132         printk("  Alternate Setting: %2d\n", desc->bAlternateSetting);
133         printk("    bLength             = %4d%s\n", desc->bLength,
134                 desc->bLength == USB_DT_INTERFACE_SIZE ? "" : " (!!!)");
135         printk("    bDescriptorType     =   %02x\n", desc->bDescriptorType);
136         printk("    bInterfaceNumber    =   %02x\n", desc->bInterfaceNumber);
137         printk("    bAlternateSetting   =   %02x\n", desc->bAlternateSetting);
138         printk("    bNumEndpoints       =   %02x\n", desc->bNumEndpoints);
139         printk("    bInterface Class:SubClass:Protocol =   %02x:%02x:%02x\n",
140                 desc->bInterfaceClass, desc->bInterfaceSubClass, desc->bInterfaceProtocol);
141         printk("    iInterface          =   %02x\n", desc->iInterface);
142 }
143 
144 void usb_show_endpoint_descriptor(struct usb_endpoint_descriptor *desc)
145 {
146         char *LengthCommentString = (desc->bLength ==
147                 USB_DT_ENDPOINT_AUDIO_SIZE) ? " (Audio)" : (desc->bLength ==
148                 USB_DT_ENDPOINT_SIZE) ? "" : " (!!!)";
149         char *EndpointType[4] = { "Control", "Isochronous", "Bulk", "Interrupt" };
150 
151         printk("    Endpoint:\n");
152         printk("      bLength             = %4d%s\n",
153                 desc->bLength, LengthCommentString);
154         printk("      bDescriptorType     =   %02x\n", desc->bDescriptorType);
155         printk("      bEndpointAddress    =   %02x (%s)\n", desc->bEndpointAddress,
156                 (desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
157                         USB_ENDPOINT_XFER_CONTROL ? "i/o" :
158                 (desc->bEndpointAddress & USB_ENDPOINT_DIR_MASK) ? "in" : "out");
159         printk("      bmAttributes        =   %02x (%s)\n", desc->bmAttributes,
160                 EndpointType[USB_ENDPOINT_XFERTYPE_MASK & desc->bmAttributes]);
161         printk("      wMaxPacketSize      = %04x\n", desc->wMaxPacketSize);
162         printk("      bInterval           =   %02x\n", desc->bInterval);
163 
164         /* Audio extensions to the endpoint descriptor */
165         if (desc->bLength == USB_DT_ENDPOINT_AUDIO_SIZE) {
166                 printk("      bRefresh            =   %02x\n", desc->bRefresh);
167                 printk("      bSynchAddress       =   %02x\n", desc->bSynchAddress);
168         }
169 }
170 
171 void usb_show_string(struct usb_device *dev, char *id, int index)
172 {
173         char *buf;
174 
175         if (!index)
176                 return;
177         if (!(buf = kmalloc(256, GFP_KERNEL)))
178                 return;
179         if (usb_string(dev, index, buf, 256) > 0)
180                 printk(KERN_INFO "%s: %s\n", id, buf);
181         kfree(buf);
182 }
183 
184 void usb_dump_urb (purb_t purb)
185 {
186         printk ("urb                   :%p\n", purb);
187         printk ("next                  :%p\n", purb->next);
188         printk ("dev                   :%p\n", purb->dev);
189         printk ("pipe                  :%08X\n", purb->pipe);
190         printk ("status                :%d\n", purb->status);
191         printk ("transfer_flags        :%08X\n", purb->transfer_flags);
192         printk ("transfer_buffer       :%p\n", purb->transfer_buffer);
193         printk ("transfer_buffer_length:%d\n", purb->transfer_buffer_length);
194         printk ("actual_length         :%d\n", purb->actual_length);
195         printk ("setup_packet          :%p\n", purb->setup_packet);
196         printk ("start_frame           :%d\n", purb->start_frame);
197         printk ("number_of_packets     :%d\n", purb->number_of_packets);
198         printk ("interval              :%d\n", purb->interval);
199         printk ("error_count           :%d\n", purb->error_count);
200         printk ("context               :%p\n", purb->context);
201         printk ("complete              :%p\n", purb->complete);
202 }
203 
204 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.