4 * (C) Copyright Linus Torvalds 1999
5 * (C) Copyright Johannes Erdfelt 1999-2001
6 * (C) Copyright Andreas Gal 1999
7 * (C) Copyright Gregory P. Smith 1999
8 * (C) Copyright Deti Fliegl 1999 (new USB architecture)
9 * (C) Copyright Randy Dunlap 2000
10 * (C) Copyright David Brownell 2000-2001 (kernel hotplug, usb_device_id,
12 * (C) Copyright Yggdrasil Computing, Inc. 2000
13 * (usb_device_id matching changes by Adam J. Richter)
14 * (C) Copyright Greg Kroah-Hartman 2002-2003
16 * NOTE! This is not actually a driver at all, rather this is
17 * just a collection of helper routines that implement the
18 * generic USB things that the real drivers can use..
20 * Think of this as a "USB library" rather than anything else.
21 * It should be considered a slave, with no callbacks. Callbacks
26 #include <linux/config.h>
28 #ifdef CONFIG_USB_DEBUG
34 #include <linux/module.h>
35 #include <linux/string.h>
36 #include <linux/bitops.h>
37 #include <linux/slab.h>
38 #include <linux/interrupt.h> /* for in_interrupt() */
39 #include <linux/kmod.h>
40 #include <linux/init.h>
41 #include <linux/spinlock.h>
42 #include <linux/errno.h>
43 #include <linux/smp_lock.h>
44 #include <linux/usb.h>
47 #include <asm/scatterlist.h>
49 #include <linux/dma-mapping.h>
53 #include "../miniport/usb_wrapper.h"
57 extern int usb_hub_init(void);
58 extern void usb_hub_cleanup(void);
59 extern int usb_major_init(void);
60 extern void usb_major_cleanup(void);
63 int nousb
; /* Disable USB when built into kernel image */
64 /* Not honored on modular build */
67 static int generic_probe (struct device
*dev
)
71 static int generic_remove (struct device
*dev
)
76 static struct device_driver usb_generic_driver
= {
79 .probe
= generic_probe
,
80 .remove
= generic_remove
,
83 static int usb_generic_driver_data
;
85 /* needs to be called with BKL held */
86 int usb_device_probe(struct device
*dev
)
88 struct usb_interface
* intf
= to_usb_interface(dev
);
89 struct usb_driver
* driver
= to_usb_driver(dev
->driver
);
90 const struct usb_device_id
*id
;
93 dev_dbg(dev
, "%s\n", __FUNCTION__
);
97 /* driver claim() doesn't yet affect dev->driver... */
101 id
= usb_match_id (intf
, driver
->id_table
);
103 dev_dbg (dev
, "%s - got id\n", __FUNCTION__
);
104 down (&driver
->serialize
);
105 error
= driver
->probe (intf
, id
);
106 up (&driver
->serialize
);
109 intf
->driver
= driver
;
114 int usb_device_remove(struct device
*dev
)
116 struct usb_interface
*intf
;
117 struct usb_driver
*driver
;
119 intf
= list_entry(dev
,struct usb_interface
,dev
);
120 driver
= to_usb_driver(dev
->driver
);
122 down(&driver
->serialize
);
124 if (intf
->driver
&& intf
->driver
->disconnect
)
125 intf
->driver
->disconnect(intf
);
127 /* if driver->disconnect didn't release the interface */
129 usb_driver_release_interface(driver
, intf
);
131 up(&driver
->serialize
);
137 * usb_register - register a USB driver
138 * @new_driver: USB operations for the driver
140 * Registers a USB driver with the USB core. The list of unattached
141 * interfaces will be rescanned whenever a new driver is added, allowing
142 * the new driver to attach to any recognized devices.
143 * Returns a negative error code on failure and 0 on success.
145 * NOTE: if you want your driver to use the USB major number, you must call
146 * usb_register_dev() to enable that functionality. This function no longer
147 * takes care of that.
149 int usb_register(struct usb_driver
*new_driver
)
156 new_driver
->driver
.name
= (char *)new_driver
->name
;
157 new_driver
->driver
.bus
= &usb_bus_type
;
158 new_driver
->driver
.probe
= usb_device_probe
;
159 new_driver
->driver
.remove
= usb_device_remove
;
161 init_MUTEX(&new_driver
->serialize
);
163 retval
= driver_register(&new_driver
->driver
);
166 info("registered new driver %s", new_driver
->name
);
167 usbfs_update_special();
169 err("problem %d when registering driver %s",
170 retval
, new_driver
->name
);
177 * usb_deregister - unregister a USB driver
178 * @driver: USB operations of the driver to unregister
179 * Context: !in_interrupt (), must be called with BKL held
181 * Unlinks the specified driver from the internal USB driver list.
183 * NOTE: If you called usb_register_dev(), you still need to call
184 * usb_deregister_dev() to clean up your driver's allocated minor numbers,
185 * this * call will no longer do it for you.
187 void usb_deregister(struct usb_driver
*driver
)
189 info("deregistering driver %s", driver
->name
);
191 driver_unregister (&driver
->driver
);
193 usbfs_update_special();
197 * usb_ifnum_to_if - get the interface object with a given interface number (usbcore-internal)
198 * @dev: the device whose current configuration is considered
199 * @ifnum: the desired interface
201 * This walks the device descriptor for the currently active configuration
202 * and returns a pointer to the interface with that particular interface
205 * Note that configuration descriptors are not required to assign interface
206 * numbers sequentially, so that it would be incorrect to assume that
207 * the first interface in that descriptor corresponds to interface zero.
208 * This routine helps device drivers avoid such mistakes.
209 * However, you should make sure that you do the right thing with any
210 * alternate settings available for this interfaces.
212 struct usb_interface
*usb_ifnum_to_if(struct usb_device
*dev
, unsigned ifnum
)
216 for (i
= 0; i
< dev
->actconfig
->desc
.bNumInterfaces
; i
++)
217 if (dev
->actconfig
->interface
[i
].altsetting
[0]
218 .desc
.bInterfaceNumber
== ifnum
)
219 return &dev
->actconfig
->interface
[i
];
225 * usb_epnum_to_ep_desc - get the endpoint object with a given endpoint number
226 * @dev: the device whose current configuration is considered
227 * @epnum: the desired endpoint
229 * This walks the device descriptor for the currently active configuration,
230 * and returns a pointer to the endpoint with that particular endpoint
233 * Note that interface descriptors are not required to assign endpont
234 * numbers sequentially, so that it would be incorrect to assume that
235 * the first endpoint in that descriptor corresponds to interface zero.
236 * This routine helps device drivers avoid such mistakes.
238 struct usb_endpoint_descriptor
*
239 usb_epnum_to_ep_desc(struct usb_device
*dev
, unsigned epnum
)
243 for (i
= 0; i
< dev
->actconfig
->desc
.bNumInterfaces
; i
++)
244 for (j
= 0; j
< dev
->actconfig
->interface
[i
].num_altsetting
; j
++)
245 for (k
= 0; k
< dev
->actconfig
->interface
[i
]
246 .altsetting
[j
].desc
.bNumEndpoints
; k
++)
247 if (epnum
== dev
->actconfig
->interface
[i
]
248 .altsetting
[j
].endpoint
[k
]
249 .desc
.bEndpointAddress
)
250 return &dev
->actconfig
->interface
[i
]
251 .altsetting
[j
].endpoint
[k
]
258 * usb_driver_claim_interface - bind a driver to an interface
259 * @driver: the driver to be bound
260 * @iface: the interface to which it will be bound
261 * @priv: driver data associated with that interface
263 * This is used by usb device drivers that need to claim more than one
264 * interface on a device when probing (audio and acm are current examples).
265 * No device driver should directly modify internal usb_interface or
266 * usb_device structure members.
268 * Few drivers should need to use this routine, since the most natural
269 * way to bind to an interface is to return the private data from
270 * the driver's probe() method. Any driver that does use this must
271 * first be sure that no other driver has claimed the interface, by
272 * checking with usb_interface_claimed().
274 void usb_driver_claim_interface(struct usb_driver
*driver
, struct usb_interface
*iface
, void* priv
)
276 if (!iface
|| !driver
)
279 // FIXME change API to report an error in this case
281 err ("%s driver booted %s off interface %p",
282 driver
->name
, iface
->driver
->name
, iface
);
285 dbg("%s driver claimed interface %p", driver
->name
, iface
);
287 iface
->driver
= driver
;
288 usb_set_intfdata(iface
, priv
);
292 * usb_interface_claimed - returns true iff an interface is claimed
293 * @iface: the interface being checked
295 * This should be used by drivers to check other interfaces to see if
296 * they are available or not. If another driver has claimed the interface,
297 * they may not claim it. Otherwise it's OK to claim it using
298 * usb_driver_claim_interface().
300 * Returns true (nonzero) iff the interface is claimed, else false (zero).
302 int usb_interface_claimed(struct usb_interface
*iface
)
307 return (iface
->driver
!= NULL
);
308 } /* usb_interface_claimed() */
311 * usb_driver_release_interface - unbind a driver from an interface
312 * @driver: the driver to be unbound
313 * @iface: the interface from which it will be unbound
315 * This should be used by drivers to release their claimed interfaces.
316 * It is normally called in their disconnect() methods, and only for
317 * drivers that bound to more than one interface in their probe().
319 * When the USB subsystem disconnect()s a driver from some interface,
320 * it automatically invokes this method for that interface. That
321 * means that even drivers that used usb_driver_claim_interface()
322 * usually won't need to call this.
324 void usb_driver_release_interface(struct usb_driver
*driver
, struct usb_interface
*iface
)
326 /* this should never happen, don't release something that's not ours */
327 if (!iface
|| iface
->driver
!= driver
)
330 iface
->driver
= NULL
;
331 usb_set_intfdata(iface
, NULL
);
335 * usb_match_id - find first usb_device_id matching device or interface
336 * @interface: the interface of interest
337 * @id: array of usb_device_id structures, terminated by zero entry
339 * usb_match_id searches an array of usb_device_id's and returns
340 * the first one matching the device or interface, or null.
341 * This is used when binding (or rebinding) a driver to an interface.
342 * Most USB device drivers will use this indirectly, through the usb core,
343 * but some layered driver frameworks use it directly.
344 * These device tables are exported with MODULE_DEVICE_TABLE, through
345 * modutils and "modules.usbmap", to support the driver loading
346 * functionality of USB hotplugging.
350 * The "match_flags" element in a usb_device_id controls which
351 * members are used. If the corresponding bit is set, the
352 * value in the device_id must match its corresponding member
353 * in the device or interface descriptor, or else the device_id
356 * "driver_info" is normally used only by device drivers,
357 * but you can create a wildcard "matches anything" usb_device_id
358 * as a driver's "modules.usbmap" entry if you provide an id with
359 * only a nonzero "driver_info" field. If you do this, the USB device
360 * driver's probe() routine should use additional intelligence to
361 * decide whether to bind to the specified interface.
363 * What Makes Good usb_device_id Tables:
365 * The match algorithm is very simple, so that intelligence in
366 * driver selection must come from smart driver id records.
367 * Unless you have good reasons to use another selection policy,
368 * provide match elements only in related groups, and order match
369 * specifiers from specific to general. Use the macros provided
370 * for that purpose if you can.
372 * The most specific match specifiers use device descriptor
373 * data. These are commonly used with product-specific matches;
374 * the USB_DEVICE macro lets you provide vendor and product IDs,
375 * and you can also match against ranges of product revisions.
376 * These are widely used for devices with application or vendor
377 * specific bDeviceClass values.
379 * Matches based on device class/subclass/protocol specifications
380 * are slightly more general; use the USB_DEVICE_INFO macro, or
381 * its siblings. These are used with single-function devices
382 * where bDeviceClass doesn't specify that each interface has
385 * Matches based on interface class/subclass/protocol are the
386 * most general; they let drivers bind to any interface on a
387 * multiple-function device. Use the USB_INTERFACE_INFO
388 * macro, or its siblings, to match class-per-interface style
389 * devices (as recorded in bDeviceClass).
391 * Within those groups, remember that not all combinations are
392 * meaningful. For example, don't give a product version range
393 * without vendor and product IDs; or specify a protocol without
394 * its associated class and subclass.
396 const struct usb_device_id
*
397 usb_match_id(struct usb_interface
*interface
, const struct usb_device_id
*id
)
399 struct usb_host_interface
*intf
;
400 struct usb_device
*dev
;
401 struct usb_device_id
*save_id
;
406 save_id
= (struct usb_device_id
*)id
;
407 id
= (struct usb_device_id
*)save_id
;
409 /* proc_connectinfo in devio.c may call us with id == NULL. */
413 intf
= &interface
->altsetting
[interface
->act_altsetting
];
414 dev
= interface_to_usbdev(interface
);
416 /* It is important to check that id->driver_info is nonzero,
417 since an entry that is all zeroes except for a nonzero
418 id->driver_info is the way to create an entry that
419 indicates that the driver want to examine every
420 device and interface. */
421 for (; id
->idVendor
|| id
->bDeviceClass
|| id
->bInterfaceClass
||
422 id
->driver_info
; id
++) {
424 if ((id
->match_flags
& USB_DEVICE_ID_MATCH_VENDOR
) &&
425 id
->idVendor
!= dev
->descriptor
.idVendor
)
428 if ((id
->match_flags
& USB_DEVICE_ID_MATCH_PRODUCT
) &&
429 id
->idProduct
!= dev
->descriptor
.idProduct
)
432 /* No need to test id->bcdDevice_lo != 0, since 0 is never
433 greater than any unsigned number. */
434 if ((id
->match_flags
& USB_DEVICE_ID_MATCH_DEV_LO
) &&
435 (id
->bcdDevice_lo
> dev
->descriptor
.bcdDevice
))
438 if ((id
->match_flags
& USB_DEVICE_ID_MATCH_DEV_HI
) &&
439 (id
->bcdDevice_hi
< dev
->descriptor
.bcdDevice
))
442 if ((id
->match_flags
& USB_DEVICE_ID_MATCH_DEV_CLASS
) &&
443 (id
->bDeviceClass
!= dev
->descriptor
.bDeviceClass
))
446 if ((id
->match_flags
& USB_DEVICE_ID_MATCH_DEV_SUBCLASS
) &&
447 (id
->bDeviceSubClass
!= dev
->descriptor
.bDeviceSubClass
))
450 if ((id
->match_flags
& USB_DEVICE_ID_MATCH_DEV_PROTOCOL
) &&
451 (id
->bDeviceProtocol
!= dev
->descriptor
.bDeviceProtocol
))
454 if ((id
->match_flags
& USB_DEVICE_ID_MATCH_INT_CLASS
) &&
455 (id
->bInterfaceClass
!= intf
->desc
.bInterfaceClass
))
458 if ((id
->match_flags
& USB_DEVICE_ID_MATCH_INT_SUBCLASS
) &&
459 (id
->bInterfaceSubClass
!= intf
->desc
.bInterfaceSubClass
))
462 if ((id
->match_flags
& USB_DEVICE_ID_MATCH_INT_PROTOCOL
) &&
463 (id
->bInterfaceProtocol
!= intf
->desc
.bInterfaceProtocol
))
473 * usb_find_interface - find usb_interface pointer for driver and device
474 * @drv: the driver whose current configuration is considered
475 * @minor: the minor number of the desired device
477 * This walks the driver device list and returns a pointer to the interface
478 * with the matching minor. Note, this only works for devices that share the
481 struct usb_interface
*usb_find_interface(struct usb_driver
*drv
, int minor
)
483 struct list_head
*entry
;
485 struct usb_interface
*intf
;
487 list_for_each(entry
, &drv
->driver
.devices
) {
488 dev
= container_of(entry
, struct device
, driver_list
);
490 /* can't look at usb devices, only interfaces */
491 if (dev
->driver
== &usb_generic_driver
)
494 intf
= to_usb_interface(dev
);
495 if (intf
->minor
== -1)
497 if (intf
->minor
== minor
)
501 /* no device found that matches */
505 static int usb_device_match (struct device
*dev
, struct device_driver
*drv
)
507 struct usb_interface
*intf
;
508 struct usb_driver
*usb_drv
;
509 const struct usb_device_id
*id
;
511 /* check for generic driver, which we don't match any device with */
512 if (drv
== &usb_generic_driver
)
515 intf
= to_usb_interface(dev
);
517 usb_drv
= to_usb_driver(drv
);
518 id
= usb_drv
->id_table
;
520 id
= usb_match_id (intf
, usb_drv
->id_table
);
528 #ifdef CONFIG_HOTPLUG
531 * USB hotplugging invokes what /proc/sys/kernel/hotplug says
532 * (normally /sbin/hotplug) when USB devices get added or removed.
534 * This invokes a user mode policy agent, typically helping to load driver
535 * or other modules, configure the device, and more. Drivers can provide
536 * a MODULE_DEVICE_TABLE to help with module loading subtasks.
538 * We're called either from khubd (the typical case) or from root hub
539 * (init, kapmd, modprobe, rmmod, etc), but the agents need to handle
540 * delays in event delivery. Use sysfs (and DEVPATH) to make sure the
541 * device (and this configuration!) are still present.
543 static int usb_hotplug (struct device
*dev
, char **envp
, int num_envp
,
544 char *buffer
, int buffer_size
)
546 struct usb_interface
*intf
;
547 struct usb_device
*usb_dev
;
552 dbg ("%s", __FUNCTION__
);
557 /* Must check driver_data here, as on remove driver is always NULL */
558 if ((dev
->driver
== &usb_generic_driver
) ||
559 (dev
->driver_data
== &usb_generic_driver_data
))
562 intf
= to_usb_interface(dev
);
563 usb_dev
= interface_to_usbdev (intf
);
565 if (usb_dev
->devnum
< 0) {
566 dbg ("device already deleted ??");
570 dbg ("bus already removed?");
576 #ifdef CONFIG_USB_DEVICEFS
577 /* If this is available, userspace programs can directly read
578 * all the device descriptors we don't tell them about. Or
579 * even act as usermode drivers.
581 * FIXME reduce hardwired intelligence here
583 envp
[i
++] = scratch
;
584 length
+= snprintf (scratch
, buffer_size
- length
,
585 "DEVICE=/proc/bus/usb/%03d/%03d",
586 usb_dev
->bus
->busnum
, usb_dev
->devnum
);
587 if ((buffer_size
- length
<= 0) || (i
>= num_envp
))
593 /* per-device configurations are common */
594 envp
[i
++] = scratch
;
595 length
+= snprintf (scratch
, buffer_size
- length
, "PRODUCT=%x/%x/%x",
596 usb_dev
->descriptor
.idVendor
,
597 usb_dev
->descriptor
.idProduct
,
598 usb_dev
->descriptor
.bcdDevice
);
599 if ((buffer_size
- length
<= 0) || (i
>= num_envp
))
604 /* class-based driver binding models */
605 envp
[i
++] = scratch
;
606 length
+= snprintf (scratch
, buffer_size
- length
, "TYPE=%d/%d/%d",
607 usb_dev
->descriptor
.bDeviceClass
,
608 usb_dev
->descriptor
.bDeviceSubClass
,
609 usb_dev
->descriptor
.bDeviceProtocol
);
610 if ((buffer_size
- length
<= 0) || (i
>= num_envp
))
615 if (usb_dev
->descriptor
.bDeviceClass
== 0) {
616 int alt
= intf
->act_altsetting
;
618 /* 2.4 only exposed interface zero. in 2.5, hotplug
619 * agents are called for all interfaces, and can use
620 * $DEVPATH/bInterfaceNumber if necessary.
622 envp
[i
++] = scratch
;
623 length
+= snprintf (scratch
, buffer_size
- length
,
624 "INTERFACE=%d/%d/%d",
625 intf
->altsetting
[alt
].desc
.bInterfaceClass
,
626 intf
->altsetting
[alt
].desc
.bInterfaceSubClass
,
627 intf
->altsetting
[alt
].desc
.bInterfaceProtocol
);
628 if ((buffer_size
- length
<= 0) || (i
>= num_envp
))
641 static int usb_hotplug (struct device
*dev
, char **envp
,
642 int num_envp
, char *buffer
, int buffer_size
)
647 #endif /* CONFIG_HOTPLUG */
650 * usb_alloc_dev - allocate a usb device structure (usbcore-internal)
651 * @parent: hub to which device is connected
652 * @bus: bus used to access the device
653 * Context: !in_interrupt ()
655 * Only hub drivers (including virtual root hub drivers for host
656 * controllers) should ever call this.
658 * This call is synchronous, and may not be used in an interrupt context.
660 struct usb_device STDCALL
*usb_alloc_dev(struct usb_device
*parent
, struct usb_bus
*bus
)
662 struct usb_device
*dev
;
664 dev
= kmalloc(sizeof(*dev
), GFP_KERNEL
);
668 memset(dev
, 0, sizeof(*dev
));
670 device_initialize(&dev
->dev
);
671 dev
->state
= USB_STATE_ATTACHED
;
676 dev
->devpath
[0] = '0';
678 dev
->parent
= parent
;
679 INIT_LIST_HEAD(&dev
->filelist
);
681 init_MUTEX(&dev
->serialize
);
683 if (dev
->bus
->op
->allocate
)
684 dev
->bus
->op
->allocate(dev
);
690 * usb_get_dev - increments the reference count of the usb device structure
691 * @dev: the device being referenced
693 * Each live reference to a device should be refcounted.
695 * Drivers for USB interfaces should normally record such references in
696 * their probe() methods, when they bind to an interface, and release
697 * them by calling usb_put_dev(), in their disconnect() methods.
699 * A pointer to the device with the incremented reference counter is returned.
701 struct usb_device STDCALL
*usb_get_dev (struct usb_device
*dev
)
708 tmp
= get_device(&dev
->dev
);
710 return to_usb_device(tmp
);
716 * usb_put_dev - release a use of the usb device structure
717 * @dev: device that's been disconnected
719 * Must be called when a user of a device is finished with it. When the last
720 * user of the device calls this function, the memory of the device is freed.
722 void STDCALL
usb_put_dev(struct usb_device
*dev
)
725 put_device(&dev
->dev
);
729 * usb_release_dev - free a usb device structure when all users of it are finished.
730 * @dev: device that's been disconnected
732 * Will be called only by the device core when all users of this usb device are
735 static void usb_release_dev(struct device
*dev
)
737 struct usb_device
*udev
;
739 udev
= to_usb_device(dev
);
741 if (udev
->bus
&& udev
->bus
->op
&& udev
->bus
->op
->deallocate
)
742 udev
->bus
->op
->deallocate(udev
);
743 usb_destroy_configuration (udev
);
744 usb_bus_put (udev
->bus
);
749 static struct usb_device
*match_device(struct usb_device
*dev
,
750 u16 vendor_id
, u16 product_id
)
752 struct usb_device
*ret_dev
= NULL
;
755 dbg("looking at vendor %d, product %d",
756 dev
->descriptor
.idVendor
,
757 dev
->descriptor
.idProduct
);
759 /* see if this device matches */
760 if ((dev
->descriptor
.idVendor
== vendor_id
) &&
761 (dev
->descriptor
.idProduct
== product_id
)) {
762 dbg ("found the device!");
763 ret_dev
= usb_get_dev(dev
);
767 /* look through all of the children of this device */
768 for (child
= 0; child
< dev
->maxchild
; ++child
) {
769 if (dev
->children
[child
]) {
770 ret_dev
= match_device(dev
->children
[child
],
771 vendor_id
, product_id
);
781 * usb_find_device - find a specific usb device in the system
782 * @vendor_id: the vendor id of the device to find
783 * @product_id: the product id of the device to find
785 * Returns a pointer to a struct usb_device if such a specified usb
786 * device is present in the system currently. The usage count of the
787 * device will be incremented if a device is found. Make sure to call
788 * usb_put_dev() when the caller is finished with the device.
790 * If a device with the specified vendor and product id is not found,
793 struct usb_device
*usb_find_device(u16 vendor_id
, u16 product_id
)
795 struct list_head
*buslist
;
797 struct usb_device
*dev
= NULL
;
799 down(&usb_bus_list_lock
);
800 for (buslist
= usb_bus_list
.next
;
801 buslist
!= &usb_bus_list
;
802 buslist
= buslist
->next
) {
803 bus
= container_of(buslist
, struct usb_bus
, bus_list
);
804 dev
= match_device(bus
->root_hub
, vendor_id
, product_id
);
809 up(&usb_bus_list_lock
);
814 * usb_get_current_frame_number - return current bus frame number
815 * @dev: the device whose bus is being queried
817 * Returns the current frame number for the USB host controller
818 * used with the given USB device. This can be used when scheduling
819 * isochronous requests.
821 * Note that different kinds of host controller have different
822 * "scheduling horizons". While one type might support scheduling only
823 * 32 frames into the future, others could support scheduling up to
824 * 1024 frames into the future.
826 int usb_get_current_frame_number(struct usb_device
*dev
)
828 return dev
->bus
->op
->get_frame_number (dev
);
831 /*-------------------------------------------------------------------*/
833 * __usb_get_extra_descriptor() finds a descriptor of specific type in the
834 * extra field of the interface and endpoint descriptor structs.
837 int __usb_get_extra_descriptor(char *buffer
, unsigned size
, unsigned char type
, void **ptr
)
839 struct usb_descriptor_header
*header
;
841 while (size
>= sizeof(struct usb_descriptor_header
)) {
842 header
= (struct usb_descriptor_header
*)buffer
;
844 if (header
->bLength
< 2) {
845 err("invalid descriptor length of %d", header
->bLength
);
849 if (header
->bDescriptorType
== type
) {
854 buffer
+= header
->bLength
;
855 size
-= header
->bLength
;
861 * usb_disconnect - disconnect a device (usbcore-internal)
862 * @pdev: pointer to device being disconnected
863 * Context: !in_interrupt ()
865 * Something got disconnected. Get rid of it, and all of its children.
867 * Only hub drivers (including virtual root hub drivers for host
868 * controllers) should ever call this.
870 * This call is synchronous, and may not be used in an interrupt context.
872 void usb_disconnect(struct usb_device
**pdev
)
874 struct usb_device
*dev
= *pdev
;
876 struct usb_operations
*ops
;
882 // pr_debug ("%s nodev\n", __FUNCTION__);
883 DPRINT ("%s nodev\n", __FUNCTION__
);
888 // pr_debug ("%s nobus\n", __FUNCTION__);
889 DPRINT ("%s nobus\n", __FUNCTION__
);
896 /* mark the device as inactive, so any further urb submissions for
897 * this device will fail.
899 dev
->state
= USB_STATE_NOTATTACHED
;
901 dev_info (&dev
->dev
, "USB disconnect, address %d\n", dev
->devnum
);
903 /* Free up all the children before we remove this device */
904 for (i
= 0; i
< USB_MAXCHILDREN
; i
++) {
905 struct usb_device
**child
= dev
->children
+ i
;
907 usb_disconnect(child
);
910 /* disconnect() drivers from interfaces (a key side effect) */
911 dev_dbg (&dev
->dev
, "unregistering interfaces\n");
912 if (dev
->actconfig
) {
913 for (i
= 0; i
< dev
->actconfig
->desc
.bNumInterfaces
; i
++) {
914 struct usb_interface
*interface
;
916 /* remove this interface */
917 interface
= &dev
->actconfig
->interface
[i
];
918 device_unregister(&interface
->dev
);
922 /* deallocate hcd/hardware state */
924 void (*disable
)(struct usb_device
*, int) = ops
->disable
;
926 for (i
= 0; i
< 15; i
++) {
928 disable (dev
, USB_DIR_IN
| i
);
932 dev_dbg (&dev
->dev
, "unregistering device\n");
933 /* Free the device number and remove the /proc/bus/usb entry */
934 if (dev
->devnum
> 0) {
935 clear_bit(dev
->devnum
, dev
->bus
->devmap
.devicemap
);
936 usbfs_remove_device(dev
);
938 device_unregister(&dev
->dev
);
940 /* Decrement the reference count, it'll auto free everything when */
941 /* it hits 0 which could very well be now */
946 * usb_connect - pick device address (usbcore-internal)
947 * @dev: newly detected device (in DEFAULT state)
949 * Picks a device address. It's up to the hub (or root hub) driver
950 * to handle and manage enumeration, starting from the DEFAULT state.
951 * Only hub drivers (including virtual root hub drivers for host
952 * controllers) should ever call this.
954 void STDCALL
usb_connect(struct usb_device
*dev
)
957 // FIXME needs locking for SMP!!
958 /* why? this is called only from the hub thread,
959 * which hopefully doesn't run on multiple CPU's simultaneously 8-)
960 * ... it's also called from modprobe/rmmod/apmd threads as part
961 * of virtual root hub init/reinit. In the init case, the hub code
962 * won't have seen this, but not so for reinit ...
964 dev
->descriptor
.bMaxPacketSize0
= 8; /* Start off at 8 bytes */
966 /* Try to allocate the next devnum beginning at bus->devnum_next. */
967 devnum
= find_next_zero_bit(dev
->bus
->devmap
.devicemap
, 128, dev
->bus
->devnum_next
);
969 devnum
= find_next_zero_bit(dev
->bus
->devmap
.devicemap
, 128, 1);
971 dev
->bus
->devnum_next
= ( devnum
>= 127 ? 1 : devnum
+ 1);
974 set_bit(devnum
, dev
->bus
->devmap
.devicemap
);
975 dev
->devnum
= devnum
;
980 * usb_choose_address - pick device address (usbcore-internal)
981 * @dev: newly detected device (in DEFAULT state)
983 * Picks a device address. It's up to the hub (or root hub) driver
984 * to handle and manage enumeration, starting from the DEFAULT state.
985 * Only hub drivers (but not virtual root hub drivers for host
986 * controllers) should ever call this.
988 void usb_choose_address(struct usb_device
*dev
)
991 // FIXME needs locking for SMP!!
992 /* why? this is called only from the hub thread,
993 * which hopefully doesn't run on multiple CPU's simultaneously 8-)
996 /* Try to allocate the next devnum beginning at bus->devnum_next. */
997 devnum
= find_next_zero_bit(dev
->bus
->devmap
.devicemap
, 128, dev
->bus
->devnum_next
);
999 devnum
= find_next_zero_bit(dev
->bus
->devmap
.devicemap
, 128, 1);
1001 dev
->bus
->devnum_next
= ( devnum
>= 127 ? 1 : devnum
+ 1);
1004 set_bit(devnum
, dev
->bus
->devmap
.devicemap
);
1005 dev
->devnum
= devnum
;
1009 // hub-only!! ... and only exported for reset/reinit path.
1010 // otherwise used internally, for usb_new_device()
1011 int usb_set_address(struct usb_device
*dev
)
1015 if (dev
->devnum
== 0)
1017 if (dev
->state
!= USB_STATE_DEFAULT
&& dev
->state
!= USB_STATE_ADDRESS
)
1019 retval
= usb_control_msg(dev
, usb_snddefctrl(dev
), USB_REQ_SET_ADDRESS
,
1020 0, dev
->devnum
, 0, NULL
, 0, HZ
* USB_CTRL_SET_TIMEOUT
);
1022 dev
->state
= USB_STATE_ADDRESS
;
1027 /* improve on the default device description, if we can ... and
1028 * while we're at it, maybe show the vendor and product strings.
1030 static void set_device_description (struct usb_device
*dev
)
1033 int mfgr
= dev
->descriptor
.iManufacturer
;
1034 int prod
= dev
->descriptor
.iProduct
;
1035 int vendor_id
= dev
->descriptor
.idVendor
;
1036 int product_id
= dev
->descriptor
.idProduct
;
1037 char *mfgr_str
, *prod_str
;
1039 /* set default; keep it if there are no strings, or kmalloc fails */
1040 sprintf (dev
->dev
.name
, "USB device %04x:%04x",
1041 vendor_id
, product_id
);
1043 if (!(buf
= kmalloc(256 * 2, GFP_KERNEL
)))
1046 prod_str
= (char *) buf
;
1047 mfgr_str
= (char *) buf
+ 256;
1049 if (prod
&& usb_string (dev
, prod
, prod_str
, 256) > 0) {
1051 dev_printk (KERN_INFO
, &dev
->dev
, "Product: %s\n", prod_str
);
1057 if (mfgr
&& usb_string (dev
, mfgr
, mfgr_str
, 256) > 0) {
1059 dev_printk (KERN_INFO
, &dev
->dev
, "Manufacturer: %s\n", mfgr_str
);
1065 /* much like pci ... describe as either:
1066 * - both strings: 'product descr (vendor descr)'
1067 * - product only: 'product descr (USB device vvvv:pppp)'
1068 * - vendor only: 'USB device vvvv:pppp (vendor descr)'
1069 * - neither string: 'USB device vvvv:pppp'
1072 if (prod_str
&& mfgr_str
) {
1074 snprintf(dev
->dev
.name
, sizeof dev
->dev
.name
,
1075 "%s (%s)", prod_str
, mfgr_str
);
1076 } else if (prod_str
) {
1077 snprintf(dev
->dev
.name
, sizeof dev
->dev
.name
,
1078 "%s (USB device %04x:%04x)",
1079 prod_str
, vendor_id
, product_id
);
1081 } else if (mfgr_str
) {
1082 snprintf(dev
->dev
.name
, sizeof dev
->dev
.name
,
1083 "USB device %04x:%04x (%s)",
1084 vendor_id
, product_id
, mfgr_str
);
1086 usbprintk("USB connected: %s\n",dev
->dev
.name
);
1091 * By the time we get here, we chose a new device address
1092 * and is in the default state. We need to identify the thing and
1093 * get the ball rolling..
1095 * Returns 0 for success, != 0 for error.
1097 * This call is synchronous, and may not be used in an interrupt context.
1099 * Only hub drivers (including virtual root hub drivers for host
1100 * controllers) should ever call this.
1102 #define NEW_DEVICE_RETRYS 2
1103 #define SET_ADDRESS_RETRYS 20
1104 int usb_new_device(struct usb_device
*dev
, struct device
*parent
)
1111 * Set the driver for the usb device to point to the "generic" driver.
1112 * This prevents the main usb device from being sent to the usb bus
1113 * probe function. Yes, it's a hack, but a nice one :)
1115 * Do it asap, so more driver model stuff (like the device.h message
1116 * utilities) can be used in hcd submit/unlink code paths.
1118 usb_generic_driver
.bus
= &usb_bus_type
;
1119 dev
->dev
.parent
= parent
;
1120 dev
->dev
.driver
= &usb_generic_driver
;
1121 dev
->dev
.bus
= &usb_bus_type
;
1122 dev
->dev
.release
= usb_release_dev
;
1123 dev
->dev
.driver_data
= &usb_generic_driver_data
;
1125 if (dev
->dev
.bus_id
[0] == 0)
1126 sprintf (&dev
->dev
.bus_id
[0], "%d-%s",
1127 dev
->bus
->busnum
, dev
->devpath
);
1129 /* dma masks come from the controller; readonly, except to hcd */
1130 dev
->dev
.dma_mask
= parent
->dma_mask
;
1132 /* USB 2.0 section 5.5.3 talks about ep0 maxpacket ...
1133 * it's fixed size except for full speed devices.
1135 switch (dev
->speed
) {
1136 case USB_SPEED_HIGH
: /* fixed at 64 */
1139 case USB_SPEED_FULL
: /* 8, 16, 32, or 64 */
1140 /* to determine the ep0 maxpacket size, read the first 8
1141 * bytes from the device descriptor to get bMaxPacketSize0;
1142 * then correct our initial (small) guess.
1145 case USB_SPEED_LOW
: /* fixed at 8 */
1151 dev
->epmaxpacketin
[0] = i
;
1152 dev
->epmaxpacketout
[0] = i
;
1154 for (i
= 0; i
< NEW_DEVICE_RETRYS
; ++i
) {
1156 for (j
= 0; j
< SET_ADDRESS_RETRYS
; ++j
) {
1157 err
= usb_set_address(dev
);
1163 dev_err(&dev
->dev
, "USB device not accepting new address=%d (error=%d)\n",
1168 wait_ms(10); /* Let the SET_ADDRESS settle */
1170 /* high and low speed devices don't need this... */
1171 err
= usb_get_descriptor(dev
, USB_DT_DEVICE
, 0, &dev
->descriptor
, 8);
1178 dev_err(&dev
->dev
, "device descriptor read/8, error %d\n", err
);
1181 if (dev
->speed
== USB_SPEED_FULL
) {
1182 //usb_disable_endpoint(dev, 0);
1183 usb_endpoint_running(dev
, 0, 1);
1184 usb_endpoint_running(dev
, 0, 0);
1185 dev
->epmaxpacketin
[0] = dev
->descriptor
.bMaxPacketSize0
;
1186 dev
->epmaxpacketout
[0] = dev
->descriptor
.bMaxPacketSize0
;
1189 /* USB device state == addressed ... still not usable */
1191 err
= usb_get_device_descriptor(dev
);
1192 if (err
< (signed)sizeof(dev
->descriptor
)) {
1193 dev_err(&dev
->dev
, "device descriptor read/all, error %d\n", err
);
1197 err
= usb_get_configuration(dev
);
1199 dev_err(&dev
->dev
, "can't read configurations, error %d\n",
1204 /* we set the default configuration here */
1205 err
= usb_set_configuration(dev
, dev
->config
[0].desc
.bConfigurationValue
);
1207 dev_err(&dev
->dev
, "failed to set device %d default configuration (error=%d)\n",
1212 /* USB device state == configured ... tell the world! */
1214 dev_dbg(&dev
->dev
, "new device strings: Mfr=%d, Product=%d, SerialNumber=%d\n",
1215 dev
->descriptor
.iManufacturer
, dev
->descriptor
.iProduct
, dev
->descriptor
.iSerialNumber
);
1216 set_device_description (dev
);
1219 if (dev
->descriptor
.iSerialNumber
)
1220 usb_show_string(dev
, "SerialNumber", dev
->descriptor
.iSerialNumber
);
1222 /* put into sysfs, with device and config specific files */
1223 err
= device_add (&dev
->dev
);
1226 usb_create_driverfs_dev_files (dev
);
1228 /* Register all of the interfaces for this device with the driver core.
1229 * Remember, interfaces get bound to drivers, not devices. */
1230 for (i
= 0; i
< dev
->actconfig
->desc
.bNumInterfaces
; i
++) {
1231 struct usb_interface
*interface
= &dev
->actconfig
->interface
[i
];
1232 struct usb_interface_descriptor
*desc
;
1234 desc
= &interface
->altsetting
[interface
->act_altsetting
].desc
;
1235 interface
->dev
.parent
= &dev
->dev
;
1236 interface
->dev
.driver
= NULL
;
1237 interface
->dev
.bus
= &usb_bus_type
;
1238 interface
->dev
.dma_mask
= parent
->dma_mask
;
1239 sprintf (&interface
->dev
.bus_id
[0], "%d-%s:%d",
1240 dev
->bus
->busnum
, dev
->devpath
,
1241 desc
->bInterfaceNumber
);
1242 if (!desc
->iInterface
1243 || usb_string (dev
, desc
->iInterface
,
1244 interface
->dev
.name
,
1245 sizeof interface
->dev
.name
) <= 0) {
1246 /* typically devices won't bother with interface
1247 * descriptions; this is the normal case. an
1248 * interface's driver might describe it better.
1249 * (also: iInterface is per-altsetting ...)
1251 sprintf (&interface
->dev
.name
[0],
1252 "usb-%s-%s interface %d",
1253 dev
->bus
->bus_name
, dev
->devpath
,
1254 desc
->bInterfaceNumber
);
1255 DPRINT1(".........................usb_new_device: %s\n", interface
->dev
.name
);
1257 dev_dbg (&dev
->dev
, "%s - registering interface %s\n", __FUNCTION__
, interface
->dev
.bus_id
);
1258 device_add (&interface
->dev
);
1259 usb_create_driverfs_intf_files (interface
);
1261 /* add a /proc/bus/usb entry */
1262 usbfs_add_device(dev
);
1266 dev
->state
= USB_STATE_DEFAULT
;
1267 clear_bit(dev
->devnum
, dev
->bus
->devmap
.devicemap
);
1273 * usb_buffer_alloc - allocate dma-consistent buffer for URB_NO_DMA_MAP
1274 * @dev: device the buffer will be used with
1275 * @size: requested buffer size
1276 * @mem_flags: affect whether allocation may block
1277 * @dma: used to return DMA address of buffer
1279 * Return value is either null (indicating no buffer could be allocated), or
1280 * the cpu-space pointer to a buffer that may be used to perform DMA to the
1281 * specified device. Such cpu-space buffers are returned along with the DMA
1282 * address (through the pointer provided).
1284 * These buffers are used with URB_NO_DMA_MAP set in urb->transfer_flags to
1285 * avoid behaviors like using "DMA bounce buffers", or tying down I/O mapping
1286 * hardware for long idle periods. The implementation varies between
1287 * platforms, depending on details of how DMA will work to this device.
1288 * Using these buffers also helps prevent cacheline sharing problems on
1289 * architectures where CPU caches are not DMA-coherent.
1291 * When the buffer is no longer used, free it with usb_buffer_free().
1293 void *usb_buffer_alloc (
1294 struct usb_device
*dev
,
1300 if (!dev
|| !dev
->bus
|| !dev
->bus
->op
|| !dev
->bus
->op
->buffer_alloc
)
1302 return dev
->bus
->op
->buffer_alloc (dev
->bus
, size
, mem_flags
, dma
);
1306 * usb_buffer_free - free memory allocated with usb_buffer_alloc()
1307 * @dev: device the buffer was used with
1308 * @size: requested buffer size
1309 * @addr: CPU address of buffer
1310 * @dma: DMA address of buffer
1312 * This reclaims an I/O buffer, letting it be reused. The memory must have
1313 * been allocated using usb_buffer_alloc(), and the parameters must match
1314 * those provided in that allocation request.
1316 void usb_buffer_free (
1317 struct usb_device
*dev
,
1323 if (!dev
|| !dev
->bus
|| !dev
->bus
->op
|| !dev
->bus
->op
->buffer_free
)
1325 dev
->bus
->op
->buffer_free (dev
->bus
, size
, addr
, dma
);
1329 * usb_buffer_map - create DMA mapping(s) for an urb
1330 * @urb: urb whose transfer_buffer will be mapped
1332 * Return value is either null (indicating no buffer could be mapped), or
1333 * the parameter. URB_NO_DMA_MAP is added to urb->transfer_flags if the
1334 * operation succeeds. If the device is connected to this system through
1335 * a non-DMA controller, this operation always succeeds.
1337 * This call would normally be used for an urb which is reused, perhaps
1338 * as the target of a large periodic transfer, with usb_buffer_dmasync()
1339 * calls to synchronize memory and dma state. It may not be used for
1342 * Reverse the effect of this call with usb_buffer_unmap().
1344 struct urb
*usb_buffer_map (struct urb
*urb
)
1346 struct usb_bus
*bus
;
1347 struct device
*controller
;
1350 || usb_pipecontrol (urb
->pipe
)
1352 || !(bus
= urb
->dev
->bus
)
1353 || !(controller
= bus
->controller
))
1356 if (controller
->dma_mask
) {
1357 urb
->transfer_dma
= dma_map_single (controller
,
1358 urb
->transfer_buffer
, urb
->transfer_buffer_length
,
1359 usb_pipein (urb
->pipe
)
1360 ? DMA_FROM_DEVICE
: DMA_TO_DEVICE
);
1361 // FIXME generic api broken like pci, can't report errors
1362 // if (urb->transfer_dma == DMA_ADDR_INVALID) return 0;
1364 urb
->transfer_dma
= ~0;
1365 urb
->transfer_flags
|= URB_NO_DMA_MAP
;
1370 * usb_buffer_dmasync - synchronize DMA and CPU view of buffer(s)
1371 * @urb: urb whose transfer_buffer will be synchronized
1373 void usb_buffer_dmasync (struct urb
*urb
)
1375 struct usb_bus
*bus
;
1376 struct device
*controller
;
1379 || !(urb
->transfer_flags
& URB_NO_DMA_MAP
)
1381 || !(bus
= urb
->dev
->bus
)
1382 || !(controller
= bus
->controller
))
1385 if (controller
->dma_mask
)
1386 dma_sync_single (controller
,
1387 urb
->transfer_dma
, urb
->transfer_buffer_length
,
1388 usb_pipein (urb
->pipe
)
1389 ? DMA_FROM_DEVICE
: DMA_TO_DEVICE
);
1393 * usb_buffer_unmap - free DMA mapping(s) for an urb
1394 * @urb: urb whose transfer_buffer will be unmapped
1396 * Reverses the effect of usb_buffer_map().
1398 void usb_buffer_unmap (struct urb
*urb
)
1400 struct usb_bus
*bus
;
1401 struct device
*controller
;
1404 || !(urb
->transfer_flags
& URB_NO_DMA_MAP
)
1406 || !(bus
= urb
->dev
->bus
)
1407 || !(controller
= bus
->controller
))
1410 if (controller
->dma_mask
)
1411 dma_unmap_single (controller
,
1412 urb
->transfer_dma
, urb
->transfer_buffer_length
,
1413 usb_pipein (urb
->pipe
)
1414 ? DMA_FROM_DEVICE
: DMA_TO_DEVICE
);
1415 urb
->transfer_flags
&= ~URB_NO_DMA_MAP
;
1419 * usb_buffer_map_sg - create scatterlist DMA mapping(s) for an endpoint
1420 * @dev: device to which the scatterlist will be mapped
1421 * @pipe: endpoint defining the mapping direction
1422 * @sg: the scatterlist to map
1423 * @nents: the number of entries in the scatterlist
1425 * Return value is either < 0 (indicating no buffers could be mapped), or
1426 * the number of DMA mapping array entries in the scatterlist.
1428 * The caller is responsible for placing the resulting DMA addresses from
1429 * the scatterlist into URB transfer buffer pointers, and for setting the
1430 * URB_NO_DMA_MAP transfer flag in each of those URBs.
1432 * Top I/O rates come from queuing URBs, instead of waiting for each one
1433 * to complete before starting the next I/O. This is particularly easy
1434 * to do with scatterlists. Just allocate and submit one URB for each DMA
1435 * mapping entry returned, stopping on the first error or when all succeed.
1436 * Better yet, use the usb_sg_*() calls, which do that (and more) for you.
1438 * This call would normally be used when translating scatterlist requests,
1439 * rather than usb_buffer_map(), since on some hardware (with IOMMUs) it
1440 * may be able to coalesce mappings for improved I/O efficiency.
1442 * Reverse the effect of this call with usb_buffer_unmap_sg().
1444 int usb_buffer_map_sg (struct usb_device
*dev
, unsigned pipe
,
1445 struct scatterlist
*sg
, int nents
)
1447 struct usb_bus
*bus
;
1448 struct device
*controller
;
1451 || usb_pipecontrol (pipe
)
1452 || !(bus
= dev
->bus
)
1453 || !(controller
= bus
->controller
)
1454 || !controller
->dma_mask
)
1457 // FIXME generic api broken like pci, can't report errors
1458 return dma_map_sg (controller
, sg
, nents
,
1459 usb_pipein (pipe
) ? DMA_FROM_DEVICE
: DMA_TO_DEVICE
);
1463 * usb_buffer_dmasync_sg - synchronize DMA and CPU view of scatterlist buffer(s)
1464 * @dev: device to which the scatterlist will be mapped
1465 * @pipe: endpoint defining the mapping direction
1466 * @sg: the scatterlist to synchronize
1467 * @n_hw_ents: the positive return value from usb_buffer_map_sg
1469 * Use this when you are re-using a scatterlist's data buffers for
1470 * another USB request.
1472 void usb_buffer_dmasync_sg (struct usb_device
*dev
, unsigned pipe
,
1473 struct scatterlist
*sg
, int n_hw_ents
)
1475 struct usb_bus
*bus
;
1476 struct device
*controller
;
1479 || !(bus
= dev
->bus
)
1480 || !(controller
= bus
->controller
)
1481 || !controller
->dma_mask
)
1484 dma_sync_sg (controller
, sg
, n_hw_ents
,
1485 usb_pipein (pipe
) ? DMA_FROM_DEVICE
: DMA_TO_DEVICE
);
1489 * usb_buffer_unmap_sg - free DMA mapping(s) for a scatterlist
1490 * @dev: device to which the scatterlist will be mapped
1491 * @pipe: endpoint defining the mapping direction
1492 * @sg: the scatterlist to unmap
1493 * @n_hw_ents: the positive return value from usb_buffer_map_sg
1495 * Reverses the effect of usb_buffer_map_sg().
1497 void usb_buffer_unmap_sg (struct usb_device
*dev
, unsigned pipe
,
1498 struct scatterlist
*sg
, int n_hw_ents
)
1500 struct usb_bus
*bus
;
1501 struct device
*controller
;
1504 || !(bus
= dev
->bus
)
1505 || !(controller
= bus
->controller
)
1506 || !controller
->dma_mask
)
1509 dma_unmap_sg (controller
, sg
, n_hw_ents
,
1510 usb_pipein (pipe
) ? DMA_FROM_DEVICE
: DMA_TO_DEVICE
);
1514 struct bus_type usb_bus_type
= {
1516 .match
= usb_device_match
,
1517 .hotplug
= usb_hotplug
,
1522 static int __init
usb_setup_disable(char *str
)
1528 /* format to disable USB on kernel command line is: nousb */
1529 __setup("nousb", usb_setup_disable
);
1534 * for external read access to <nousb>
1536 int STDCALL
usb_disabled(void)
1544 int STDCALL __init
usb_init(void)
1547 info("USB support disabled\n");
1551 bus_register(&usb_bus_type
);
1556 driver_register(&usb_generic_driver
);
1564 void STDCALL __exit
usb_exit(void)
1566 /* This will matter if shutdown/reboot does exitcalls. */
1570 driver_unregister(&usb_generic_driver
);
1571 usb_major_cleanup();
1574 bus_unregister(&usb_bus_type
);
1577 subsys_initcall(usb_init
);
1578 module_exit(usb_exit
);
1581 * USB may be built into the kernel or be built as modules.
1582 * These symbols are exported for device (or host controller)
1583 * driver modules to use.
1585 EXPORT_SYMBOL(usb_epnum_to_ep_desc
);
1587 EXPORT_SYMBOL(usb_register
);
1588 EXPORT_SYMBOL(usb_deregister
);
1589 EXPORT_SYMBOL(usb_disabled
);
1591 EXPORT_SYMBOL(usb_device_probe
);
1592 EXPORT_SYMBOL(usb_device_remove
);
1594 EXPORT_SYMBOL(usb_alloc_dev
);
1595 EXPORT_SYMBOL(usb_put_dev
);
1596 EXPORT_SYMBOL(usb_get_dev
);
1597 EXPORT_SYMBOL(usb_hub_tt_clear_buffer
);
1599 EXPORT_SYMBOL(usb_driver_claim_interface
);
1600 EXPORT_SYMBOL(usb_interface_claimed
);
1601 EXPORT_SYMBOL(usb_driver_release_interface
);
1602 EXPORT_SYMBOL(usb_match_id
);
1603 EXPORT_SYMBOL(usb_find_interface
);
1604 EXPORT_SYMBOL(usb_ifnum_to_if
);
1606 EXPORT_SYMBOL(usb_new_device
);
1607 EXPORT_SYMBOL(usb_reset_device
);
1608 EXPORT_SYMBOL(usb_connect
);
1609 EXPORT_SYMBOL(usb_disconnect
);
1611 EXPORT_SYMBOL(__usb_get_extra_descriptor
);
1613 EXPORT_SYMBOL(usb_find_device
);
1614 EXPORT_SYMBOL(usb_get_current_frame_number
);
1616 EXPORT_SYMBOL (usb_buffer_alloc
);
1617 EXPORT_SYMBOL (usb_buffer_free
);
1619 EXPORT_SYMBOL (usb_buffer_map
);
1620 EXPORT_SYMBOL (usb_buffer_dmasync
);
1621 EXPORT_SYMBOL (usb_buffer_unmap
);
1623 EXPORT_SYMBOL (usb_buffer_map_sg
);
1624 EXPORT_SYMBOL (usb_buffer_dmasync_sg
);
1625 EXPORT_SYMBOL (usb_buffer_unmap_sg
);
1627 MODULE_LICENSE("GPL");