1#ifndef __LINUX_USB_H 2#define __LINUX_USB_H 3 4/* USB constants */ 5 6/* 7 * Device and/or Interface Class codes 8 */ 9#define USB_CLASS_PER_INTERFACE 0 /* for DeviceClass */ 10#define USB_CLASS_AUDIO 1 11#define USB_CLASS_COMM 2 12#define USB_CLASS_HID 3 13#define USB_CLASS_PHYSICAL 5 14#define USB_CLASS_STILL_IMAGE 6 15#define USB_CLASS_PRINTER 7 16#define USB_CLASS_MASS_STORAGE 8 17#define USB_CLASS_HUB 9 18#define USB_CLASS_CDC_DATA 0x0a 19#define USB_CLASS_CSCID 0x0b /* chip+ smart card */ 20#define USB_CLASS_CONTENT_SEC 0x0d /* content security */ 21#define USB_CLASS_APP_SPEC 0xfe 22#define USB_CLASS_VENDOR_SPEC 0xff 23 24/* 25 * USB types 26 */ 27#define USB_TYPE_MASK (0x03 << 5) 28#define USB_TYPE_STANDARD (0x00 << 5) 29#define USB_TYPE_CLASS (0x01 << 5) 30#define USB_TYPE_VENDOR (0x02 << 5) 31#define USB_TYPE_RESERVED (0x03 << 5) 32 33/* 34 * USB recipients 35 */ 36#define USB_RECIP_MASK 0x1f 37#define USB_RECIP_DEVICE 0x00 38#define USB_RECIP_INTERFACE 0x01 39#define USB_RECIP_ENDPOINT 0x02 40#define USB_RECIP_OTHER 0x03 41 42/* 43 * USB directions 44 */ 45#define USB_DIR_OUT 0 /* to device */ 46#define USB_DIR_IN 0x80 /* to host */ 47 48/* 49 * Descriptor types 50 */ 51#define USB_DT_DEVICE 0x01 52#define USB_DT_CONFIG 0x02 53#define USB_DT_STRING 0x03 54#define USB_DT_INTERFACE 0x04 55#define USB_DT_ENDPOINT 0x05 56 57#define USB_DT_HID (USB_TYPE_CLASS | 0x01) 58#define USB_DT_REPORT (USB_TYPE_CLASS | 0x02) 59#define USB_DT_PHYSICAL (USB_TYPE_CLASS | 0x03) 60#define USB_DT_HUB (USB_TYPE_CLASS | 0x09) 61 62/* 63 * Descriptor sizes per descriptor type 64 */ 65#define USB_DT_DEVICE_SIZE 18 66#define USB_DT_CONFIG_SIZE 9 67#define USB_DT_INTERFACE_SIZE 9 68#define USB_DT_ENDPOINT_SIZE 7 69#define USB_DT_ENDPOINT_AUDIO_SIZE 9 /* Audio extension */ 70#define USB_DT_HUB_NONVAR_SIZE 7 71#define USB_DT_HID_SIZE 9 72 73/* 74 * Endpoints 75 */ 76#define USB_ENDPOINT_NUMBER_MASK 0x0f /* in bEndpointAddress */ 77#define USB_ENDPOINT_DIR_MASK 0x80 78 79#define USB_ENDPOINT_XFERTYPE_MASK 0x03 /* in bmAttributes */ 80#define USB_ENDPOINT_XFER_CONTROL 0 81#define USB_ENDPOINT_XFER_ISOC 1 82#define USB_ENDPOINT_XFER_BULK 2 83#define USB_ENDPOINT_XFER_INT 3 84 85/* 86 * USB Packet IDs (PIDs) 87 */ 88#define USB_PID_UNDEF_0 0xf0 89#define USB_PID_OUT 0xe1 90#define USB_PID_ACK 0xd2 91#define USB_PID_DATA0 0xc3 92#define USB_PID_PING 0xb4 /* USB 2.0 */ 93#define USB_PID_SOF 0xa5 94#define USB_PID_NYET 0x96 /* USB 2.0 */ 95#define USB_PID_DATA2 0x87 /* USB 2.0 */ 96#define USB_PID_SPLIT 0x78 /* USB 2.0 */ 97#define USB_PID_IN 0x69 98#define USB_PID_NAK 0x5a 99#define USB_PID_DATA1 0x4b 100#define USB_PID_PREAMBLE 0x3c /* Token mode */ 101#define USB_PID_ERR 0x3c /* USB 2.0: handshake mode */ 102#define USB_PID_SETUP 0x2d 103#define USB_PID_STALL 0x1e 104#define USB_PID_MDATA 0x0f /* USB 2.0 */ 105 106/* 107 * Standard requests 108 */ 109#define USB_REQ_GET_STATUS 0x00 110#define USB_REQ_CLEAR_FEATURE 0x01 111#define USB_REQ_SET_FEATURE 0x03 112#define USB_REQ_SET_ADDRESS 0x05 113#define USB_REQ_GET_DESCRIPTOR 0x06 114#define USB_REQ_SET_DESCRIPTOR 0x07 115#define USB_REQ_GET_CONFIGURATION 0x08 116#define USB_REQ_SET_CONFIGURATION 0x09 117#define USB_REQ_GET_INTERFACE 0x0A 118#define USB_REQ_SET_INTERFACE 0x0B 119#define USB_REQ_SYNCH_FRAME 0x0C 120 121/* 122 * HID requests 123 */ 124#define USB_REQ_GET_REPORT 0x01 125#define USB_REQ_GET_IDLE 0x02 126#define USB_REQ_GET_PROTOCOL 0x03 127#define USB_REQ_SET_REPORT 0x09 128#define USB_REQ_SET_IDLE 0x0A 129#define USB_REQ_SET_PROTOCOL 0x0B 130 131 132#ifdef __KERNEL__ 133 134#include <linux/types.h> 135#include <linux/ioctl.h> 136#include <linux/version.h> 137#include <linux/sched.h> 138#include <linux/delay.h> 139#include <linux/interrupt.h> /* for in_interrupt() */ 140#include <linux/config.h> 141#include <linux/list.h> 142 143#define USB_MAJOR 180 144 145static __inline__ void wait_ms(unsigned int ms) 146{ 147 if(!in_interrupt()) { 148 current->state = TASK_UNINTERRUPTIBLE; 149 schedule_timeout(1 + ms * HZ / 1000); 150 } 151 else 152 mdelay(ms); 153} 154 155/** 156 * struct usb_ctrlrequest - structure used to make USB device control requests easier to create and decode 157 * @bRequestType: matches the USB bmRequestType field 158 * @bRequest: matches the USB bRequest field 159 * @wValue: matches the USB wValue field 160 * @wIndex: matches the USB wIndex field 161 * @wLength: matches the USB wLength field 162 * 163 * This structure is used to send control requests to a USB device. It matches 164 * the different fields of the USB 2.0 Spec section 9.3, table 9-2. See the 165 * USB spec for a fuller description of the different fields, and what they are 166 * used for. 167 */ 168struct usb_ctrlrequest { 169 __u8 bRequestType; 170 __u8 bRequest; 171 __u16 wValue; 172 __u16 wIndex; 173 __u16 wLength; 174} __attribute__ ((packed)); 175 176/* 177 * USB-status codes: 178 * USB_ST* maps to -E* and should go away in the future 179 */ 180 181#define USB_ST_NOERROR 0 182#define USB_ST_CRC (-EILSEQ) 183#define USB_ST_BITSTUFF (-EPROTO) 184#define USB_ST_NORESPONSE (-ETIMEDOUT) /* device not responding/handshaking */ 185#define USB_ST_DATAOVERRUN (-EOVERFLOW) 186#define USB_ST_DATAUNDERRUN (-EREMOTEIO) 187#define USB_ST_BUFFEROVERRUN (-ECOMM) 188#define USB_ST_BUFFERUNDERRUN (-ENOSR) 189#define USB_ST_INTERNALERROR (-EPROTO) /* unknown error */ 190#define USB_ST_SHORT_PACKET (-EREMOTEIO) 191#define USB_ST_PARTIAL_ERROR (-EXDEV) /* ISO transfer only partially completed */ 192#define USB_ST_URB_KILLED (-ENOENT) /* URB canceled by user */ 193#define USB_ST_URB_PENDING (-EINPROGRESS) 194#define USB_ST_REMOVED (-ENODEV) /* device not existing or removed */ 195#define USB_ST_TIMEOUT (-ETIMEDOUT) /* communication timed out, also in urb->status**/ 196#define USB_ST_NOTSUPPORTED (-ENOSYS) 197#define USB_ST_BANDWIDTH_ERROR (-ENOSPC) /* too much bandwidth used */ 198#define USB_ST_URB_INVALID_ERROR (-EINVAL) /* invalid value/transfer type */ 199#define USB_ST_URB_REQUEST_ERROR (-ENXIO) /* invalid endpoint */ 200#define USB_ST_STALL (-EPIPE) /* pipe stalled, also in urb->status*/ 201 202/* 203 * USB device number allocation bitmap. There's one bitmap 204 * per USB tree. 205 */ 206struct usb_devmap { 207 unsigned long devicemap[128 / (8*sizeof(unsigned long))]; 208}; 209 210#define USB_MAXBUS 64 211 212struct usb_busmap { 213 unsigned long busmap[USB_MAXBUS / (8*sizeof(unsigned long))]; 214}; 215 216/* 217 * This is a USB device descriptor. 218 * 219 * USB device information 220 */ 221 222/* Everything but the endpoint maximums are aribtrary */ 223#define USB_MAXCONFIG 8 224#define USB_ALTSETTINGALLOC 4 225#define USB_MAXALTSETTING 128 /* Hard limit */ 226#define USB_MAXINTERFACES 32 227#define USB_MAXENDPOINTS 32 228 229/* All standard descriptors have these 2 fields in common */ 230struct usb_descriptor_header { 231 __u8 bLength; 232 __u8 bDescriptorType; 233} __attribute__ ((packed)); 234 235/* Device descriptor */ 236struct usb_device_descriptor { 237 __u8 bLength; 238 __u8 bDescriptorType; 239 __u16 bcdUSB; 240 __u8 bDeviceClass; 241 __u8 bDeviceSubClass; 242 __u8 bDeviceProtocol; 243 __u8 bMaxPacketSize0; 244 __u16 idVendor; 245 __u16 idProduct; 246 __u16 bcdDevice; 247 __u8 iManufacturer; 248 __u8 iProduct; 249 __u8 iSerialNumber; 250 __u8 bNumConfigurations; 251} __attribute__ ((packed)); 252 253/* Endpoint descriptor */ 254struct usb_endpoint_descriptor { 255 __u8 bLength __attribute__ ((packed)); 256 __u8 bDescriptorType __attribute__ ((packed)); 257 __u8 bEndpointAddress __attribute__ ((packed)); 258 __u8 bmAttributes __attribute__ ((packed)); 259 __u16 wMaxPacketSize __attribute__ ((packed)); 260 __u8 bInterval __attribute__ ((packed)); 261 __u8 bRefresh __attribute__ ((packed)); 262 __u8 bSynchAddress __attribute__ ((packed)); 263 264 unsigned char *extra; /* Extra descriptors */ 265 int extralen; 266}; 267 268/* Interface descriptor */ 269struct usb_interface_descriptor { 270 __u8 bLength __attribute__ ((packed)); 271 __u8 bDescriptorType __attribute__ ((packed)); 272 __u8 bInterfaceNumber __attribute__ ((packed)); 273 __u8 bAlternateSetting __attribute__ ((packed)); 274 __u8 bNumEndpoints __attribute__ ((packed)); 275 __u8 bInterfaceClass __attribute__ ((packed)); 276 __u8 bInterfaceSubClass __attribute__ ((packed)); 277 __u8 bInterfaceProtocol __attribute__ ((packed)); 278 __u8 iInterface __attribute__ ((packed)); 279 280 struct usb_endpoint_descriptor *endpoint; 281 282 unsigned char *extra; /* Extra descriptors */ 283 int extralen; 284}; 285 286struct usb_interface { 287 struct usb_interface_descriptor *altsetting; 288 289 int act_altsetting; /* active alternate setting */ 290 int num_altsetting; /* number of alternate settings */ 291 int max_altsetting; /* total memory allocated */ 292 293 struct usb_driver *driver; /* driver */ 294 void *private_data; 295}; 296 297/* Configuration descriptor information.. */ 298struct usb_config_descriptor { 299 __u8 bLength __attribute__ ((packed)); 300 __u8 bDescriptorType __attribute__ ((packed)); 301 __u16 wTotalLength __attribute__ ((packed)); 302 __u8 bNumInterfaces __attribute__ ((packed)); 303 __u8 bConfigurationValue __attribute__ ((packed)); 304 __u8 iConfiguration __attribute__ ((packed)); 305 __u8 bmAttributes __attribute__ ((packed)); 306 __u8 MaxPower __attribute__ ((packed)); 307 308 struct usb_interface *interface; 309 310 unsigned char *extra; /* Extra descriptors */ 311 int extralen; 312}; 313 314/* String descriptor */ 315struct usb_string_descriptor { 316 __u8 bLength; 317 __u8 bDescriptorType; 318 __u16 wData[1]; 319} __attribute__ ((packed)); 320 321struct usb_device; 322 323/* 324 * Device table entry for "new style" table-driven USB drivers. 325 * User mode code can read these tables to choose which modules to load. 326 * Declare the table as __devinitdata, and as a MODULE_DEVICE_TABLE. 327 * 328 * With a device table provide bind() instead of probe(). Then the 329 * third bind() parameter will point to a matching entry from this 330 * table. (Null value reserved.) 331 * 332 * Terminate the driver's table with an all-zeroes entry. 333 * Init the fields you care about; zeroes are not used in comparisons. 334 */ 335#define USB_DEVICE_ID_MATCH_VENDOR 0x0001 336#define USB_DEVICE_ID_MATCH_PRODUCT 0x0002 337#define USB_DEVICE_ID_MATCH_DEV_LO 0x0004 338#define USB_DEVICE_ID_MATCH_DEV_HI 0x0008 339#define USB_DEVICE_ID_MATCH_DEV_CLASS 0x0010 340#define USB_DEVICE_ID_MATCH_DEV_SUBCLASS 0x0020 341#define USB_DEVICE_ID_MATCH_DEV_PROTOCOL 0x0040 342#define USB_DEVICE_ID_MATCH_INT_CLASS 0x0080 343#define USB_DEVICE_ID_MATCH_INT_SUBCLASS 0x0100 344#define USB_DEVICE_ID_MATCH_INT_PROTOCOL 0x0200 345 346#define USB_DEVICE_ID_MATCH_DEVICE (USB_DEVICE_ID_MATCH_VENDOR | USB_DEVICE_ID_MATCH_PRODUCT) 347#define USB_DEVICE_ID_MATCH_DEV_RANGE (USB_DEVICE_ID_MATCH_DEV_LO | USB_DEVICE_ID_MATCH_DEV_HI) 348#define USB_DEVICE_ID_MATCH_DEVICE_AND_VERSION (USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_DEV_RANGE) 349#define USB_DEVICE_ID_MATCH_DEV_INFO \ 350 (USB_DEVICE_ID_MATCH_DEV_CLASS | USB_DEVICE_ID_MATCH_DEV_SUBCLASS | USB_DEVICE_ID_MATCH_DEV_PROTOCOL) 351#define USB_DEVICE_ID_MATCH_INT_INFO \ 352 (USB_DEVICE_ID_MATCH_INT_CLASS | USB_DEVICE_ID_MATCH_INT_SUBCLASS | USB_DEVICE_ID_MATCH_INT_PROTOCOL) 353 354/* Some useful macros */ 355#define USB_DEVICE(vend,prod) \ 356 match_flags: USB_DEVICE_ID_MATCH_DEVICE, idVendor: (vend), idProduct: (prod) 357#define USB_DEVICE_VER(vend,prod,lo,hi) \ 358 match_flags: USB_DEVICE_ID_MATCH_DEVICE_AND_VERSION, idVendor: (vend), idProduct: (prod), bcdDevice_lo: (lo), bcdDevice_hi: (hi) 359#define USB_DEVICE_INFO(cl,sc,pr) \ 360 match_flags: USB_DEVICE_ID_MATCH_DEV_INFO, bDeviceClass: (cl), bDeviceSubClass: (sc), bDeviceProtocol: (pr) 361#define USB_INTERFACE_INFO(cl,sc,pr) \ 362 match_flags: USB_DEVICE_ID_MATCH_INT_INFO, bInterfaceClass: (cl), bInterfaceSubClass: (sc), bInterfaceProtocol: (pr) 363 364struct usb_device_id { 365 /* This bitmask is used to determine which of the following fields 366 * are to be used for matching. 367 */ 368 __u16 match_flags; 369 370 /* 371 * vendor/product codes are checked, if vendor is nonzero 372 * Range is for device revision (bcdDevice), inclusive; 373 * zero values here mean range isn't considered 374 */ 375 __u16 idVendor; 376 __u16 idProduct; 377 __u16 bcdDevice_lo, bcdDevice_hi; 378 379 /* 380 * if device class != 0, these can be match criteria; 381 * but only if this bDeviceClass value is nonzero 382 */ 383 __u8 bDeviceClass; 384 __u8 bDeviceSubClass; 385 __u8 bDeviceProtocol; 386 387 /* 388 * if interface class != 0, these can be match criteria; 389 * but only if this bInterfaceClass value is nonzero 390 */ 391 __u8 bInterfaceClass; 392 __u8 bInterfaceSubClass; 393 __u8 bInterfaceProtocol; 394 395 /* 396 * for driver's use; not involved in driver matching. 397 */ 398 unsigned long driver_info; 399}; 400 401/** 402 * struct usb_driver - identifies USB driver to usbcore 403 * @owner: Pointer to the module owner of this driver; initialize 404 * it using THIS_MODULE. 405 * @name: The driver name should be unique among USB drivers, 406 * and should normally be the same as the module name. 407 * @probe: Called to see if the driver is willing to manage a particular 408 * interface on a device. The probe routine returns a handle that 409 * will later be provided to disconnect(), or a null pointer to 410 * indicate that the driver will not handle the interface. 411 * The handle is normally a pointer to driver-specific data. 412 * If the probe() routine needs to access the interface 413 * structure itself, use usb_ifnum_to_if() to make sure it's using 414 * the right one. 415 * @disconnect: Called when the interface is no longer accessible, usually 416 * because its device has been (or is being) disconnected. The 417 * handle passed is what was returned by probe(), or was provided 418 * to usb_driver_claim_interface(). 419 * @ioctl: Used for drivers that want to talk to userspace through 420 * the "usbfs" filesystem. This lets devices provide ways to 421 * expose information to user space regardless of where they 422 * do (or don't) show up otherwise in the filesystem. 423 * @fops: pointer to a fops structure if the driver wants to use the USB 424 * major number. 425 * @minor: the starting minor number for this driver, if the fops 426 * pointer is set. 427 * @id_table: USB drivers use ID table to support hotplugging. 428 * Export this with MODULE_DEVICE_TABLE(usb,...), or use NULL to 429 * say that probe() should be called for any unclaimed interface. 430 * 431 * USB drivers must provide a name, probe() and disconnect() methods, 432 * and an id_table. Other driver fields are optional. 433 * 434 * The id_table is used in hotplugging. It holds a set of descriptors, 435 * and specialized data may be associated with each entry. That table 436 * is used by both user and kernel mode hotplugging support. 437 * The probe() and disconnect() methods are called in a context where 438 * they can sleep, but they should avoid abusing the privilege. Most 439 * work to connect to a device should be done when the device is opened, 440 * and undone at the last close. The disconnect code needs to address 441 * concurrency issues with respect to open() and close() methods, as 442 * well as forcing all pending I/O requests to complete (by unlinking 443 * them as necessary, and blocking until the unlinks complete). 444 */ 445struct usb_driver { 446 struct module *owner; 447 448 const char *name; 449 450 void *(*probe)( 451 struct usb_device *dev, /* the device */ 452 unsigned intf, /* what interface */ 453 const struct usb_device_id *id /* from id_table */ 454 ); 455 void (*disconnect)(struct usb_device *, void *); 456 457 struct list_head driver_list; 458 459 struct file_operations *fops; 460 int minor; 461 462 struct semaphore serialize; 463 464 int (*ioctl)(struct usb_device *dev, unsigned int code, void *buf); 465 466 const struct usb_device_id *id_table; 467}; 468 469/*----------------------------------------------------------------------------* 470 * New USB Structures * 471 *----------------------------------------------------------------------------*/ 472 473/* 474 * urb->transfer_flags: 475 */ 476#define USB_DISABLE_SPD 0x0001 477#define URB_SHORT_NOT_OK USB_DISABLE_SPD 478#define USB_ISO_ASAP 0x0002 479#define USB_ASYNC_UNLINK 0x0008 480#define USB_QUEUE_BULK 0x0010 481#define USB_NO_FSBR 0x0020 482#define USB_ZERO_PACKET 0x0040 // Finish bulk OUTs always with zero length packet 483#define URB_NO_INTERRUPT 0x0080 /* HINT: no non-error interrupt needed */ 484 /* ... less overhead for QUEUE_BULK */ 485#define USB_TIMEOUT_KILLED 0x1000 // only set by HCD! 486 487struct iso_packet_descriptor 488{ 489 unsigned int offset; 490 unsigned int length; // expected length 491 unsigned int actual_length; 492 unsigned int status; 493}; 494 495#define usb_iso_packet_descriptor iso_packet_descriptor 496 497struct urb; 498typedef void (*usb_complete_t)(struct urb *); 499 500struct urb 501{ 502 spinlock_t lock; // lock for the URB 503 void *hcpriv; // private data for host controller 504 struct list_head urb_list; // list pointer to all active urbs 505 struct urb *next; // pointer to next URB 506 struct usb_device *dev; // pointer to associated USB device 507 unsigned int pipe; // pipe information 508 int status; // returned status 509 unsigned int transfer_flags; // USB_DISABLE_SPD | USB_ISO_ASAP | etc. 510 void *transfer_buffer; // associated data buffer 511 dma_addr_t transfer_dma; // dma addr for transfer_buffer 512 int transfer_buffer_length; // data buffer length 513 int actual_length; // actual data buffer length 514 int bandwidth; // bandwidth for this transfer request (INT or ISO) 515 unsigned char *setup_packet; // setup packet (control only) 516 dma_addr_t setup_dma; // dma addr for setup_packet 517 // 518 int start_frame; // start frame (iso/irq only) 519 int number_of_packets; // number of packets in this request (iso) 520 int interval; // polling interval (irq only) 521 int error_count; // number of errors in this transfer (iso only) 522 int timeout; // timeout (in jiffies) 523 // 524 void *context; // context for completion routine 525 usb_complete_t complete; // pointer to completion routine 526 // 527 struct iso_packet_descriptor iso_frame_desc[0]; 528}; 529 530/** 531 * FILL_CONTROL_URB - macro to help initialize a control urb 532 * @URB: pointer to the urb to initialize. 533 * @DEV: pointer to the struct usb_device for this urb. 534 * @PIPE: the endpoint pipe 535 * @SETUP_PACKET: pointer to the setup_packet buffer 536 * @TRANSFER_BUFFER: pointer to the transfer buffer 537 * @BUFFER_LENGTH: length of the transfer buffer 538 * @COMPLETE: pointer to the usb_complete_t function 539 * @CONTEXT: what to set the urb context to. 540 * 541 * Initializes a control urb with the proper information needed to submit 542 * it to a device. This macro is depreciated, the usb_fill_control_urb() 543 * function should be used instead. 544 */ 545#define FILL_CONTROL_URB(URB,DEV,PIPE,SETUP_PACKET,TRANSFER_BUFFER,BUFFER_LENGTH,COMPLETE,CONTEXT) \ 546 do {\ 547 spin_lock_init(&(URB)->lock);\ 548 (URB)->dev=DEV;\ 549 (URB)->pipe=PIPE;\ 550 (URB)->setup_packet=SETUP_PACKET;\ 551 (URB)->transfer_buffer=TRANSFER_BUFFER;\ 552 (URB)->transfer_buffer_length=BUFFER_LENGTH;\ 553 (URB)->complete=COMPLETE;\ 554 (URB)->context=CONTEXT;\ 555 } while (0) 556 557/** 558 * FILL_BULK_URB - macro to help initialize a bulk urb 559 * @URB: pointer to the urb to initialize. 560 * @DEV: pointer to the struct usb_device for this urb. 561 * @PIPE: the endpoint pipe 562 * @TRANSFER_BUFFER: pointer to the transfer buffer 563 * @BUFFER_LENGTH: length of the transfer buffer 564 * @COMPLETE: pointer to the usb_complete_t function 565 * @CONTEXT: what to set the urb context to. 566 * 567 * Initializes a bulk urb with the proper information needed to submit it 568 * to a device. This macro is depreciated, the usb_fill_bulk_urb() 569 * function should be used instead. 570 */ 571#define FILL_BULK_URB(URB,DEV,PIPE,TRANSFER_BUFFER,BUFFER_LENGTH,COMPLETE,CONTEXT) \ 572 do {\ 573 spin_lock_init(&(URB)->lock);\ 574 (URB)->dev=DEV;\ 575 (URB)->pipe=PIPE;\ 576 (URB)->transfer_buffer=TRANSFER_BUFFER;\ 577 (URB)->transfer_buffer_length=BUFFER_LENGTH;\ 578 (URB)->complete=COMPLETE;\ 579 (URB)->context=CONTEXT;\ 580 } while (0) 581 582/** 583 * FILL_INT_URB - macro to help initialize a interrupt urb 584 * @URB: pointer to the urb to initialize. 585 * @DEV: pointer to the struct usb_device for this urb. 586 * @PIPE: the endpoint pipe 587 * @TRANSFER_BUFFER: pointer to the transfer buffer 588 * @BUFFER_LENGTH: length of the transfer buffer 589 * @COMPLETE: pointer to the usb_complete_t function 590 * @CONTEXT: what to set the urb context to. 591 * @INTERVAL: what to set the urb interval to. 592 * 593 * Initializes a interrupt urb with the proper information needed to submit 594 * it to a device. This macro is depreciated, the usb_fill_int_urb() 595 * function should be used instead. 596 */ 597#define FILL_INT_URB(URB,DEV,PIPE,TRANSFER_BUFFER,BUFFER_LENGTH,COMPLETE,CONTEXT,INTERVAL) \ 598 do {\ 599 spin_lock_init(&(URB)->lock);\ 600 (URB)->dev=DEV;\ 601 (URB)->pipe=PIPE;\ 602 (URB)->transfer_buffer=TRANSFER_BUFFER;\ 603 (URB)->transfer_buffer_length=BUFFER_LENGTH;\ 604 (URB)->complete=COMPLETE;\ 605 (URB)->context=CONTEXT;\ 606 (URB)->interval=INTERVAL;\ 607 (URB)->start_frame=-1;\ 608 } while (0) 609 610#define FILL_CONTROL_URB_TO(a,aa,b,c,d,e,f,g,h) \ 611 do {\ 612 spin_lock_init(&(a)->lock);\ 613 (a)->dev=aa;\ 614 (a)->pipe=b;\ 615 (a)->setup_packet=c;\ 616 (a)->transfer_buffer=d;\ 617 (a)->transfer_buffer_length=e;\ 618 (a)->complete=f;\ 619 (a)->context=g;\ 620 (a)->timeout=h;\ 621 } while (0) 622 623#define FILL_BULK_URB_TO(a,aa,b,c,d,e,f,g) \ 624 do {\ 625 spin_lock_init(&(a)->lock);\ 626 (a)->dev=aa;\ 627 (a)->pipe=b;\ 628 (a)->transfer_buffer=c;\ 629 (a)->transfer_buffer_length=d;\ 630 (a)->complete=e;\ 631 (a)->context=f;\ 632 (a)->timeout=g;\ 633 } while (0) 634 635/** 636 * usb_fill_control_urb - initializes a control urb 637 * @urb: pointer to the urb to initialize. 638 * @dev: pointer to the struct usb_device for this urb. 639 * @pipe: the endpoint pipe 640 * @setup_packet: pointer to the setup_packet buffer 641 * @transfer_buffer: pointer to the transfer buffer 642 * @buffer_length: length of the transfer buffer 643 * @complete: pointer to the usb_complete_t function 644 * @context: what to set the urb context to. 645 * 646 * Initializes a control urb with the proper information needed to submit 647 * it to a device. 648 */ 649static inline void usb_fill_control_urb (struct urb *urb, 650 struct usb_device *dev, 651 unsigned int pipe, 652 unsigned char *setup_packet, 653 void *transfer_buffer, 654 int buffer_length, 655 usb_complete_t complete, 656 void *context) 657{ 658 spin_lock_init(&urb->lock); 659 urb->dev = dev; 660 urb->pipe = pipe; 661 urb->setup_packet = setup_packet; 662 urb->transfer_buffer = transfer_buffer; 663 urb->transfer_buffer_length = buffer_length; 664 urb->complete = complete; 665 urb->context = context; 666} 667 668/** 669 * usb_fill_bulk_urb - macro to help initialize a bulk urb 670 * @urb: pointer to the urb to initialize. 671 * @dev: pointer to the struct usb_device for this urb. 672 * @pipe: the endpoint pipe 673 * @transfer_buffer: pointer to the transfer buffer 674 * @buffer_length: length of the transfer buffer 675 * @complete: pointer to the usb_complete_t function 676 * @context: what to set the urb context to. 677 * 678 * Initializes a bulk urb with the proper information needed to submit it 679 * to a device. 680 */ 681static inline void usb_fill_bulk_urb (struct urb *urb, 682 struct usb_device *dev, 683 unsigned int pipe, 684 void *transfer_buffer, 685 int buffer_length, 686 usb_complete_t complete, 687 void *context) 688 689{ 690 spin_lock_init(&urb->lock); 691 urb->dev = dev; 692 urb->pipe = pipe; 693 urb->transfer_buffer = transfer_buffer; 694 urb->transfer_buffer_length = buffer_length; 695 urb->complete = complete; 696 urb->context = context; 697} 698 699/** 700 * usb_fill_int_urb - macro to help initialize a interrupt urb 701 * @urb: pointer to the urb to initialize. 702 * @dev: pointer to the struct usb_device for this urb. 703 * @pipe: the endpoint pipe 704 * @transfer_buffer: pointer to the transfer buffer 705 * @buffer_length: length of the transfer buffer 706 * @complete: pointer to the usb_complete_t function 707 * @context: what to set the urb context to. 708 * @interval: what to set the urb interval to. 709 * 710 * Initializes a interrupt urb with the proper information needed to submit 711 * it to a device. 712 */ 713static inline void usb_fill_int_urb (struct urb *urb, 714 struct usb_device *dev, 715 unsigned int pipe, 716 void *transfer_buffer, 717 int buffer_length, 718 usb_complete_t complete, 719 void *context, 720 int interval) 721{ 722 spin_lock_init(&urb->lock); 723 urb->dev = dev; 724 urb->pipe = pipe; 725 urb->transfer_buffer = transfer_buffer; 726 urb->transfer_buffer_length = buffer_length; 727 urb->complete = complete; 728 urb->context = context; 729 urb->interval = interval; 730 urb->start_frame = -1; 731} 732 733struct urb *usb_alloc_urb(int iso_packets); 734void usb_free_urb (struct urb *urb); 735int usb_submit_urb(struct urb *urb); 736int usb_unlink_urb(struct urb *urb); 737int usb_internal_control_msg(struct usb_device *usb_dev, unsigned int pipe, struct usb_ctrlrequest *cmd, void *data, int len, int timeout); 738int usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe, void *data, int len, int *actual_length, int timeout); 739 740/*-------------------------------------------------------------------* 741 * SYNCHRONOUS CALL SUPPORT * 742 *-------------------------------------------------------------------*/ 743 744struct usb_api_data 745{ 746 wait_queue_head_t wqh; 747 int done; 748 /* void* stuff; */ /* Possible extension later. */ 749}; 750 751/* -------------------------------------------------------------------------- */ 752 753struct usb_operations { 754 int (*allocate)(struct usb_device *); 755 int (*deallocate)(struct usb_device *); 756 int (*get_frame_number) (struct usb_device *usb_dev); 757 int (*submit_urb) (struct urb* purb); 758 int (*unlink_urb) (struct urb* purb); 759}; 760 761#define DEVNUM_ROUND_ROBIN /***** OPTION *****/ 762 763/* 764 * Allocated per bus we have 765 */ 766struct usb_bus { 767 int busnum; /* Bus number (in order of reg) */ 768 char *bus_name; /* stable id (PCI slot_name etc) */ 769 770#ifdef DEVNUM_ROUND_ROBIN 771 int devnum_next; /* Next open device number in round-robin allocation */ 772#endif /* DEVNUM_ROUND_ROBIN */ 773 774 struct usb_devmap devmap; /* Device map */ 775 struct usb_operations *op; /* Operations (specific to the HC) */ 776 struct usb_device *root_hub; /* Root hub */ 777 struct list_head bus_list; 778 void *hcpriv; /* Host Controller private data */ 779 780 int bandwidth_allocated; /* on this Host Controller; */ 781 /* applies to Int. and Isoc. pipes; */ 782 /* measured in microseconds/frame; */ 783 /* range is 0..900, where 900 = */ 784 /* 90% of a 1-millisecond frame */ 785 int bandwidth_int_reqs; /* number of Interrupt requesters */ 786 int bandwidth_isoc_reqs; /* number of Isoc. requesters */ 787 788 /* usbdevfs inode list */ 789 struct list_head inodes; 790 791 atomic_t refcnt; 792}; 793 794/* 795 * As of USB 2.0, full/low speed devices are segregated into trees. 796 * One type grows from USB 1.1 host controllers (OHCI, UHCI etc). 797 * The other type grows from high speed hubs when they connect to 798 * full/low speed devices using "Transaction Translators" (TTs). 799 * 800 * TTs should only be known to the hub driver, and high speed bus 801 * drivers (only EHCI for now). They affect periodic scheduling and 802 * sometimes control/bulk error recovery. 803 */ 804struct usb_tt { 805 struct usb_device *hub; /* upstream highspeed hub */ 806 int multi; /* true means one TT per port */ 807}; 808 809 810/* This is arbitrary. 811 * From USB 2.0 spec Table 11-13, offset 7, a hub can 812 * have up to 255 ports. The most yet reported is 10. 813 */ 814#define USB_MAXCHILDREN (16) 815 816struct usb_device { 817 int devnum; /* Address on USB bus */ 818 char devpath [16]; /* Use in messages: /port/port/... */ 819 820 enum { 821 USB_SPEED_UNKNOWN = 0, /* enumerating */ 822 USB_SPEED_LOW, USB_SPEED_FULL, /* usb 1.1 */ 823 USB_SPEED_HIGH /* usb 2.0 */ 824 } speed; 825 826 struct usb_tt *tt; /* low/full speed dev, highspeed hub */ 827 int ttport; /* device port on that tt hub */ 828 829 atomic_t refcnt; /* Reference count */ 830 struct semaphore serialize; 831 832 unsigned int toggle[2]; /* one bit for each endpoint ([0] = IN, [1] = OUT) */ 833 unsigned int halted[2]; /* endpoint halts; one bit per endpoint # & direction; */ 834 /* [0] = IN, [1] = OUT */ 835 int epmaxpacketin[16]; /* INput endpoint specific maximums */ 836 int epmaxpacketout[16]; /* OUTput endpoint specific maximums */ 837 838 struct usb_device *parent; 839 struct usb_bus *bus; /* Bus we're part of */ 840 841 struct usb_device_descriptor descriptor;/* Descriptor */ 842 struct usb_config_descriptor *config; /* All of the configs */ 843 struct usb_config_descriptor *actconfig;/* the active configuration */ 844 845 char **rawdescriptors; /* Raw descriptors for each config */ 846 847 int have_langid; /* whether string_langid is valid yet */ 848 int string_langid; /* language ID for strings */ 849 850 void *hcpriv; /* Host Controller private data */ 851 852 /* usbdevfs inode list */ 853 struct list_head inodes; 854 struct list_head filelist; 855 856 /* 857 * Child devices - these can be either new devices 858 * (if this is a hub device), or different instances 859 * of this same device. 860 * 861 * Each instance needs its own set of data structures. 862 */ 863 864 int maxchild; /* Number of ports if hub */ 865 struct usb_device *children[USB_MAXCHILDREN]; 866}; 867 868extern struct usb_interface *usb_ifnum_to_if(struct usb_device *dev, unsigned ifnum); 869extern struct usb_endpoint_descriptor *usb_epnum_to_ep_desc(struct usb_device *dev, unsigned epnum); 870 871extern int usb_register(struct usb_driver *); 872extern void usb_deregister(struct usb_driver *); 873extern void usb_scan_devices(void); 874 875/* used these for multi-interface device registration */ 876extern void usb_driver_claim_interface(struct usb_driver *driver, struct usb_interface *iface, void* priv); 877extern int usb_interface_claimed(struct usb_interface *iface); 878extern void usb_driver_release_interface(struct usb_driver *driver, struct usb_interface *iface); 879const struct usb_device_id *usb_match_id(struct usb_device *dev, 880 struct usb_interface *interface, 881 const struct usb_device_id *id); 882 883extern struct usb_bus *usb_alloc_bus(struct usb_operations *); 884extern void usb_free_bus(struct usb_bus *); 885extern void usb_register_bus(struct usb_bus *); 886extern void usb_deregister_bus(struct usb_bus *); 887 888extern struct usb_device *usb_alloc_dev(struct usb_device *parent, struct usb_bus *); 889extern void usb_free_dev(struct usb_device *); 890extern void usb_inc_dev_use(struct usb_device *); 891#define usb_dec_dev_use usb_free_dev 892 893extern int usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request, __u8 requesttype, __u16 value, __u16 index, void *data, __u16 size, int timeout); 894 895extern int usb_root_hub_string(int id, int serial, char *type, __u8 *data, int len); 896extern void usb_connect(struct usb_device *dev); 897extern void usb_disconnect(struct usb_device **); 898 899extern void usb_destroy_configuration(struct usb_device *dev); 900 901int usb_get_current_frame_number (struct usb_device *usb_dev); 902 903 904/** 905 * usb_make_path - returns stable device path in the usb tree 906 * @dev: the device whose path is being constructed 907 * @buf: where to put the string 908 * @size: how big is "buf"? 909 * 910 * Returns length of the string (> 0) or negative if size was too small. 911 * 912 * This identifier is intended to be "stable", reflecting physical paths in 913 * hardware such as physical bus addresses for host controllers or ports on 914 * USB hubs. That makes it stay the same until systems are physically 915 * reconfigured, by re-cabling a tree of USB devices or by moving USB host 916 * controllers. Adding and removing devices, including virtual root hubs 917 * in host controller driver modules, does not change these path identifers; 918 * neither does rebooting or re-enumerating. These are more useful identifiers 919 * than changeable ("unstable") ones like bus numbers or device addresses. 920 * (The stability of the id depends on stability of the bus_name associated 921 * with the bus the device uses; that is normally stable.) 922 * 923 * With a partial exception for devices connected to USB 2.0 root hubs, these 924 * identifiers are also predictable. So long as the device tree isn't changed, 925 * plugging any USB device into a given hub port always gives it the same path. 926 * Because of the use of "companion" controllers, devices connected to ports on 927 * USB 2.0 root hubs (EHCI host controllers) will get one path ID if they are 928 * high speed, and a different one if they are full or low speed. 929 */ 930static inline int usb_make_path (struct usb_device *dev, char *buf, size_t size) 931{ 932 int actual; 933 actual = snprintf (buf, size, "usb-%s-%s", 934 dev->bus->bus_name, dev->devpath); 935 return (actual >= size) ? -1 : actual; 936} 937 938 939/* 940 * Calling this entity a "pipe" is glorifying it. A USB pipe 941 * is something embarrassingly simple: it basically consists 942 * of the following information: 943 * - device number (7 bits) 944 * - endpoint number (4 bits) 945 * - current Data0/1 state (1 bit) 946 * - direction (1 bit) 947 * - speed (1 bit) 948 * - max packet size (2 bits: 8, 16, 32 or 64) [Historical; now gone.] 949 * - pipe type (2 bits: control, interrupt, bulk, isochronous) 950 * 951 * That's 18 bits. Really. Nothing more. And the USB people have 952 * documented these eighteen bits as some kind of glorious 953 * virtual data structure. 954 * 955 * Let's not fall in that trap. We'll just encode it as a simple 956 * unsigned int. The encoding is: 957 * 958 * - max size: bits 0-1 (00 = 8, 01 = 16, 10 = 32, 11 = 64) [Historical; now gone.] 959 * - direction: bit 7 (0 = Host-to-Device [Out], 1 = Device-to-Host [In]) 960 * - device: bits 8-14 961 * - endpoint: bits 15-18 962 * - Data0/1: bit 19 963 * - speed: bit 26 (0 = Full, 1 = Low Speed) 964 * - pipe type: bits 30-31 (00 = isochronous, 01 = interrupt, 10 = control, 11 = bulk) 965 * 966 * Why? Because it's arbitrary, and whatever encoding we select is really 967 * up to us. This one happens to share a lot of bit positions with the UHCI 968 * specification, so that much of the uhci driver can just mask the bits 969 * appropriately. 970 * 971 * NOTE: there's no encoding (yet?) for a "high speed" endpoint; treat them 972 * like full speed devices. 973 */ 974 975#define PIPE_ISOCHRONOUS 0 976#define PIPE_INTERRUPT 1 977#define PIPE_CONTROL 2 978#define PIPE_BULK 3 979 980#define usb_maxpacket(dev, pipe, out) (out \ 981 ? (dev)->epmaxpacketout[usb_pipeendpoint(pipe)] \ 982 : (dev)->epmaxpacketin [usb_pipeendpoint(pipe)] ) 983#define usb_packetid(pipe) (((pipe) & USB_DIR_IN) ? USB_PID_IN : USB_PID_OUT) 984 985#define usb_pipeout(pipe) ((((pipe) >> 7) & 1) ^ 1) 986#define usb_pipein(pipe) (((pipe) >> 7) & 1) 987#define usb_pipedevice(pipe) (((pipe) >> 8) & 0x7f) 988#define usb_pipe_endpdev(pipe) (((pipe) >> 8) & 0x7ff) 989#define usb_pipeendpoint(pipe) (((pipe) >> 15) & 0xf) 990#define usb_pipedata(pipe) (((pipe) >> 19) & 1) 991#define usb_pipeslow(pipe) (((pipe) >> 26) & 1) 992#define usb_pipetype(pipe) (((pipe) >> 30) & 3) 993#define usb_pipeisoc(pipe) (usb_pipetype((pipe)) == PIPE_ISOCHRONOUS) 994#define usb_pipeint(pipe) (usb_pipetype((pipe)) == PIPE_INTERRUPT) 995#define usb_pipecontrol(pipe) (usb_pipetype((pipe)) == PIPE_CONTROL) 996#define usb_pipebulk(pipe) (usb_pipetype((pipe)) == PIPE_BULK) 997 998#define PIPE_DEVEP_MASK 0x0007ff00 999 1000/* The D0/D1 toggle bits */ 1001#define usb_gettoggle(dev, ep, out) (((dev)->toggle[out] >> ep) & 1) 1002#define usb_dotoggle(dev, ep, out) ((dev)->toggle[out] ^= (1 << ep)) 1003#define usb_settoggle(dev, ep, out, bit) ((dev)->toggle[out] = ((dev)->toggle[out] & ~(1 << ep)) | ((bit) << ep)) 1004 1005/* Endpoint halt control/status */ 1006#define usb_endpoint_out(ep_dir) (((ep_dir >> 7) & 1) ^ 1) 1007#define usb_endpoint_halt(dev, ep, out) ((dev)->halted[out] |= (1 << (ep))) 1008#define usb_endpoint_running(dev, ep, out) ((dev)->halted[out] &= ~(1 << (ep))) 1009#define usb_endpoint_halted(dev, ep, out) ((dev)->halted[out] & (1 << (ep))) 1010 1011static inline unsigned int __create_pipe(struct usb_device *dev, unsigned int endpoint) 1012{ 1013 return (dev->devnum << 8) | (endpoint << 15) | 1014 ((dev->speed == USB_SPEED_LOW) << 26); 1015} 1016 1017static inline unsigned int __default_pipe(struct usb_device *dev) 1018{ 1019 return ((dev->speed == USB_SPEED_LOW) << 26); 1020} 1021 1022/* Create various pipes... */ 1023#define usb_sndctrlpipe(dev,endpoint) ((PIPE_CONTROL << 30) | __create_pipe(dev,endpoint)) 1024#define usb_rcvctrlpipe(dev,endpoint) ((PIPE_CONTROL << 30) | __create_pipe(dev,endpoint) | USB_DIR_IN) 1025#define usb_sndisocpipe(dev,endpoint) ((PIPE_ISOCHRONOUS << 30) | __create_pipe(dev,endpoint)) 1026#define usb_rcvisocpipe(dev,endpoint) ((PIPE_ISOCHRONOUS << 30) | __create_pipe(dev,endpoint) | USB_DIR_IN) 1027#define usb_sndbulkpipe(dev,endpoint) ((PIPE_BULK << 30) | __create_pipe(dev,endpoint)) 1028#define usb_rcvbulkpipe(dev,endpoint) ((PIPE_BULK << 30) | __create_pipe(dev,endpoint) | USB_DIR_IN) 1029#define usb_sndintpipe(dev,endpoint) ((PIPE_INTERRUPT << 30) | __create_pipe(dev,endpoint)) 1030#define usb_rcvintpipe(dev,endpoint) ((PIPE_INTERRUPT << 30) | __create_pipe(dev,endpoint) | USB_DIR_IN) 1031#define usb_snddefctrl(dev) ((PIPE_CONTROL << 30) | __default_pipe(dev)) 1032#define usb_rcvdefctrl(dev) ((PIPE_CONTROL << 30) | __default_pipe(dev) | USB_DIR_IN) 1033 1034/* 1035 * Send and receive control messages.. 1036 */ 1037int usb_new_device(struct usb_device *dev); 1038int usb_reset_device(struct usb_device *dev); 1039int usb_set_address(struct usb_device *dev); 1040int usb_get_descriptor(struct usb_device *dev, unsigned char desctype, 1041 unsigned char descindex, void *buf, int size); 1042int usb_get_class_descriptor(struct usb_device *dev, int ifnum, unsigned char desctype, 1043 unsigned char descindex, void *buf, int size); 1044int usb_get_device_descriptor(struct usb_device *dev); 1045int __usb_get_extra_descriptor(char *buffer, unsigned size, unsigned char type, void **ptr); 1046int usb_get_status(struct usb_device *dev, int type, int target, void *data); 1047int usb_get_configuration(struct usb_device *dev); 1048int usb_get_protocol(struct usb_device *dev, int ifnum); 1049int usb_set_protocol(struct usb_device *dev, int ifnum, int protocol); 1050int usb_set_interface(struct usb_device *dev, int ifnum, int alternate); 1051int usb_set_idle(struct usb_device *dev, int ifnum, int duration, int report_id); 1052int usb_set_configuration(struct usb_device *dev, int configuration); 1053int usb_get_report(struct usb_device *dev, int ifnum, unsigned char type, 1054 unsigned char id, void *buf, int size); 1055int usb_set_report(struct usb_device *dev, int ifnum, unsigned char type, 1056 unsigned char id, void *buf, int size); 1057int usb_string(struct usb_device *dev, int index, char *buf, size_t size); 1058int usb_clear_halt(struct usb_device *dev, int pipe); 1059void usb_set_maxpacket(struct usb_device *dev); 1060 1061#define usb_get_extra_descriptor(ifpoint,type,ptr)\ 1062 __usb_get_extra_descriptor((ifpoint)->extra,(ifpoint)->extralen,type,(void**)ptr) 1063 1064/* 1065 * Debugging helpers.. 1066 */ 1067void usb_show_device_descriptor(struct usb_device_descriptor *); 1068void usb_show_config_descriptor(struct usb_config_descriptor *); 1069void usb_show_interface_descriptor(struct usb_interface_descriptor *); 1070void usb_show_endpoint_descriptor(struct usb_endpoint_descriptor *); 1071void usb_show_device(struct usb_device *); 1072void usb_show_string(struct usb_device *dev, char *id, int index); 1073 1074#ifdef DEBUG 1075#define dbg(format, arg...) printk(KERN_DEBUG __FILE__ ": " format "\n" , ## arg) 1076#else 1077#define dbg(format, arg...) do {} while (0) 1078#endif 1079#define err(format, arg...) printk(KERN_ERR __FILE__ ": " format "\n" , ## arg) 1080#define info(format, arg...) printk(KERN_INFO __FILE__ ": " format "\n" , ## arg) 1081#define warn(format, arg...) printk(KERN_WARNING __FILE__ ": " format "\n" , ## arg) 1082 1083 1084/* 1085 * bus and driver list 1086 */ 1087 1088extern struct list_head usb_driver_list; 1089extern struct list_head usb_bus_list; 1090extern struct semaphore usb_bus_list_lock; 1091 1092/* 1093 * USB device fs stuff 1094 */ 1095 1096#ifdef CONFIG_USB_DEVICEFS 1097 1098/* 1099 * these are expected to be called from the USB core/hub thread 1100 * with the kernel lock held 1101 */ 1102extern void usbdevfs_add_bus(struct usb_bus *bus); 1103extern void usbdevfs_remove_bus(struct usb_bus *bus); 1104extern void usbdevfs_add_device(struct usb_device *dev); 1105extern void usbdevfs_remove_device(struct usb_device *dev); 1106 1107extern int usbdevfs_init(void); 1108extern void usbdevfs_cleanup(void); 1109 1110#else /* CONFIG_USB_DEVICEFS */ 1111 1112static inline void usbdevfs_add_bus(struct usb_bus *bus) {} 1113static inline void usbdevfs_remove_bus(struct usb_bus *bus) {} 1114static inline void usbdevfs_add_device(struct usb_device *dev) {} 1115static inline void usbdevfs_remove_device(struct usb_device *dev) {} 1116 1117static inline int usbdevfs_init(void) { return 0; } 1118static inline void usbdevfs_cleanup(void) { } 1119 1120#endif /* CONFIG_USB_DEVICEFS */ 1121 1122#endif /* __KERNEL__ */ 1123 1124#endif 1125