Linux Kernel
3.7.1
|
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/string.h>
#include <linux/bitops.h>
#include <linux/slab.h>
#include <linux/interrupt.h>
#include <linux/kmod.h>
#include <linux/init.h>
#include <linux/spinlock.h>
#include <linux/errno.h>
#include <linux/usb.h>
#include <linux/usb/hcd.h>
#include <linux/mutex.h>
#include <linux/workqueue.h>
#include <linux/debugfs.h>
#include <asm/io.h>
#include <linux/scatterlist.h>
#include <linux/mm.h>
#include <linux/dma-mapping.h>
#include "usb.h"
Go to the source code of this file.
Data Structures | |
struct | find_interface_arg |
Macros | |
#define | usb_autosuspend_delay 0 |
Variables | |
const char * | usbcore_name = "usbcore" |
struct device_type | usb_device_type |
struct dentry * | usb_debug_root |
core_param | ( | nousb | , |
nousb | , | ||
bool | , | ||
0444 | |||
) |
usb_buffer_map - create DMA mapping(s) for an urb : urb whose transfer_buffer/setup_packet will be mapped
Return value is either null (indicating no buffer could be mapped), or the parameter. URB_NO_TRANSFER_DMA_MAP is added to urb->transfer_flags if the operation succeeds. If the device is connected to this system through a non-DMA controller, this operation always succeeds.
This call would normally be used for an urb which is reused, perhaps as the target of a large periodic transfer, with usb_buffer_dmasync() calls to synchronize memory and dma state.
Reverse the effect of this call with usb_buffer_unmap(). usb_buffer_unmap - free DMA mapping(s) for an urb : urb whose transfer_buffer will be unmapped
Reverses the effect of usb_buffer_map().
EXPORT_SYMBOL_GPL | ( | usb_find_alt_setting | ) |
EXPORT_SYMBOL_GPL | ( | usb_ifnum_to_if | ) |
EXPORT_SYMBOL_GPL | ( | usb_altnum_to_altsetting | ) |
EXPORT_SYMBOL_GPL | ( | usb_find_interface | ) |
EXPORT_SYMBOL_GPL | ( | usb_get_dev | ) |
EXPORT_SYMBOL_GPL | ( | usb_put_dev | ) |
EXPORT_SYMBOL_GPL | ( | usb_get_intf | ) |
EXPORT_SYMBOL_GPL | ( | usb_put_intf | ) |
EXPORT_SYMBOL_GPL | ( | usb_lock_device_for_reset | ) |
EXPORT_SYMBOL_GPL | ( | usb_get_current_frame_number | ) |
EXPORT_SYMBOL_GPL | ( | __usb_get_extra_descriptor | ) |
EXPORT_SYMBOL_GPL | ( | usb_alloc_coherent | ) |
EXPORT_SYMBOL_GPL | ( | usb_free_coherent | ) |
EXPORT_SYMBOL_GPL | ( | usb_disabled | ) |
EXPORT_SYMBOL_GPL | ( | usb_debug_root | ) |
module_exit | ( | usb_exit | ) |
MODULE_LICENSE | ( | "GPL" | ) |
subsys_initcall | ( | usb_init | ) |
void* usb_alloc_coherent | ( | struct usb_device * | dev, |
size_t | size, | ||
gfp_t | mem_flags, | ||
dma_addr_t * | dma | ||
) |
usb_alloc_coherent - allocate dma-consistent buffer for URB_NO_xxx_DMA_MAP : device the buffer will be used with : requested buffer size : affect whether allocation may block : used to return DMA address of buffer
Return value is either null (indicating no buffer could be allocated), or the cpu-space pointer to a buffer that may be used to perform DMA to the specified device. Such cpu-space buffers are returned along with the DMA address (through the pointer provided).
These buffers are used with URB_NO_xxx_DMA_MAP set in urb->transfer_flags to avoid behaviors like using "DMA bounce buffers", or thrashing IOMMU hardware during URB completion/resubmit. The implementation varies between platforms, depending on details of how DMA will work to this device. Using these buffers also eliminates cacheline sharing problems on architectures where CPU caches are not DMA-coherent. On systems without bus-snooping caches, these buffers are uncached.
When the buffer is no longer used, free it with usb_free_coherent().
|
read |
usb_alloc_dev - usb device constructor (usbcore-internal) : hub to which device is connected; null to allocate a root hub : bus used to access the device : one-based index of port; ignored for root hubs Context: !in_interrupt()
Only hub drivers (including virtual root hub drivers for host controllers) should ever call this.
This call may not be used in a non-sleeping context.
|
read |
usb_altnum_to_altsetting - get the altsetting structure with a given alternate setting number. : the interface containing the altsetting in question : the desired alternate setting number
This searches the altsetting array of the specified interface for an entry with the correct bAlternateSetting value and returns a pointer to that entry, or null.
Note that altsettings need not be stored sequentially by number, so it would be incorrect to assume that the first altsetting entry in the array corresponds to altsetting zero. This routine helps device drivers avoid such mistakes.
Don't call this function unless you are bound to the intf interface or you have locked the device!
|
read |
usb_find_alt_setting() - Given a configuration, find the alternate setting for the given interface. : the configuration to search (not necessarily the current config). : interface number to search in : alternate interface setting number to search for.
Search the configuration's interface cache for the given alt setting.
|
read |
usb_find_interface - find usb_interface pointer for driver and device : the driver whose current configuration is considered : the minor number of the desired device
This walks the bus device list and returns a pointer to the interface with the matching minor and driver. Note, this only works for devices that share the USB major number.
void usb_free_coherent | ( | struct usb_device * | dev, |
size_t | size, | ||
void * | addr, | ||
dma_addr_t | dma | ||
) |
usb_free_coherent - free memory allocated with usb_alloc_coherent() : device the buffer was used with : requested buffer size : CPU address of buffer : DMA address of buffer
This reclaims an I/O buffer, letting it be reused. The memory must have been allocated using usb_alloc_coherent(), and the parameters must match those provided in that allocation request.
usb_get_current_frame_number - return current bus frame number : the device whose bus is being queried
Returns the current frame number for the USB host controller used with the given USB device. This can be used when scheduling isochronous requests.
Note that different kinds of host controller have different "scheduling horizons". While one type might support scheduling only 32 frames into the future, others could support scheduling up to 1024 frames into the future.
usb_get_dev - increments the reference count of the usb device structure : the device being referenced
Each live reference to a device should be refcounted.
Drivers for USB interfaces should normally record such references in their probe() methods, when they bind to an interface, and release them by calling usb_put_dev(), in their disconnect() methods.
A pointer to the device with the incremented reference counter is returned.
|
read |
usb_get_intf - increments the reference count of the usb interface structure : the interface being referenced
Each live reference to a interface must be refcounted.
Drivers for USB interfaces should normally record such references in their probe() methods, when they bind to an interface, and release them by calling usb_put_intf(), in their disconnect() methods.
A pointer to the interface with the incremented reference counter is returned.
|
read |
usb_ifnum_to_if - get the interface object with a given interface number : the device whose current configuration is considered : the desired interface
This walks the device descriptor for the currently active configuration and returns a pointer to the interface with that particular interface number, or null.
Note that configuration descriptors are not required to assign interface numbers sequentially, so that it would be incorrect to assume that the first interface in that descriptor corresponds to interface zero. This routine helps device drivers avoid such mistakes. However, you should make sure that you do the right thing with any alternate settings available for this interfaces.
Don't call this function unless you are bound to one of the interfaces on this device or you have locked the device!
int usb_lock_device_for_reset | ( | struct usb_device * | udev, |
const struct usb_interface * | iface | ||
) |
usb_lock_device_for_reset - cautiously acquire the lock for a usb device structure : device that's being locked : interface bound to the driver making the request (optional)
Attempts to acquire the device lock, but fails if the device is NOTATTACHED or SUSPENDED, or if iface is specified and the interface is neither BINDING nor BOUND. Rather than sleeping to wait for the lock, the routine polls repeatedly. This is to prevent deadlock with disconnect; in some drivers (such as usb-storage) the disconnect() or suspend() method will block waiting for a device reset to complete.
Returns a negative error code for failure, otherwise 0.
void usb_put_intf | ( | struct usb_interface * | intf | ) |
struct device_type usb_device_type |