Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Functions | Variables
hcd.c File Reference
#include <linux/bcd.h>
#include <linux/module.h>
#include <linux/version.h>
#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/completion.h>
#include <linux/utsname.h>
#include <linux/mm.h>
#include <asm/io.h>
#include <linux/device.h>
#include <linux/dma-mapping.h>
#include <linux/mutex.h>
#include <asm/irq.h>
#include <asm/byteorder.h>
#include <asm/unaligned.h>
#include <linux/platform_device.h>
#include <linux/workqueue.h>
#include <linux/usb.h>
#include <linux/usb/hcd.h>
#include "usb.h"

Go to the source code of this file.

Data Structures

struct  usb_busmap
 

Macros

#define USB_MAXBUS   64
 
#define KERNEL_REL   bin2bcd(((LINUX_VERSION_CODE >> 16) & 0x0ff))
 
#define KERNEL_VER   bin2bcd(((LINUX_VERSION_CODE >> 8) & 0x0ff))
 

Functions

 EXPORT_SYMBOL_GPL (usb_hcds_loaded)
 
 LIST_HEAD (usb_bus_list)
 
 EXPORT_SYMBOL_GPL (usb_bus_list)
 
 DEFINE_MUTEX (usb_bus_list_lock)
 
 EXPORT_SYMBOL_GPL (usb_bus_list_lock)
 
 DECLARE_WAIT_QUEUE_HEAD (usb_kill_urb_queue)
 
 module_param (authorized_default, int, S_IRUGO|S_IWUSR)
 
 MODULE_PARM_DESC (authorized_default,"Default USB device authorization: 0 is not authorized, 1 is ""authorized, -1 is authorized except for wireless USB (default, ""old behaviour")
 
void usb_hcd_poll_rh_status (struct usb_hcd *hcd)
 
 EXPORT_SYMBOL_GPL (usb_hcd_poll_rh_status)
 
long usb_calc_bus_time (int speed, int is_input, int isoc, int bytecount)
 
 EXPORT_SYMBOL_GPL (usb_calc_bus_time)
 
int usb_hcd_link_urb_to_ep (struct usb_hcd *hcd, struct urb *urb)
 
 EXPORT_SYMBOL_GPL (usb_hcd_link_urb_to_ep)
 
int usb_hcd_check_unlink_urb (struct usb_hcd *hcd, struct urb *urb, int status)
 
 EXPORT_SYMBOL_GPL (usb_hcd_check_unlink_urb)
 
void usb_hcd_unlink_urb_from_ep (struct usb_hcd *hcd, struct urb *urb)
 
 EXPORT_SYMBOL_GPL (usb_hcd_unlink_urb_from_ep)
 
void usb_hcd_unmap_urb_setup_for_dma (struct usb_hcd *hcd, struct urb *urb)
 
 EXPORT_SYMBOL_GPL (usb_hcd_unmap_urb_setup_for_dma)
 
void usb_hcd_unmap_urb_for_dma (struct usb_hcd *hcd, struct urb *urb)
 
 EXPORT_SYMBOL_GPL (usb_hcd_unmap_urb_for_dma)
 
int usb_hcd_map_urb_for_dma (struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flags)
 
 EXPORT_SYMBOL_GPL (usb_hcd_map_urb_for_dma)
 
int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
 
int usb_hcd_unlink_urb (struct urb *urb, int status)
 
void usb_hcd_giveback_urb (struct usb_hcd *hcd, struct urb *urb, int status)
 
 EXPORT_SYMBOL_GPL (usb_hcd_giveback_urb)
 
void usb_hcd_flush_endpoint (struct usb_device *udev, struct usb_host_endpoint *ep)
 
int usb_hcd_alloc_bandwidth (struct usb_device *udev, struct usb_host_config *new_config, struct usb_host_interface *cur_alt, struct usb_host_interface *new_alt)
 
void usb_hcd_disable_endpoint (struct usb_device *udev, struct usb_host_endpoint *ep)
 
void usb_hcd_reset_endpoint (struct usb_device *udev, struct usb_host_endpoint *ep)
 
int usb_alloc_streams (struct usb_interface *interface, struct usb_host_endpoint **eps, unsigned int num_eps, unsigned int num_streams, gfp_t mem_flags)
 
 EXPORT_SYMBOL_GPL (usb_alloc_streams)
 
void usb_free_streams (struct usb_interface *interface, struct usb_host_endpoint **eps, unsigned int num_eps, gfp_t mem_flags)
 
 EXPORT_SYMBOL_GPL (usb_free_streams)
 
void usb_hcd_synchronize_unlinks (struct usb_device *udev)
 
int usb_hcd_get_frame_number (struct usb_device *udev)
 
irqreturn_t usb_hcd_irq (int irq, void *__hcd)
 
 EXPORT_SYMBOL_GPL (usb_hcd_irq)
 
void usb_hc_died (struct usb_hcd *hcd)
 
 EXPORT_SYMBOL_GPL (usb_hc_died)
 
struct usb_hcd * usb_create_shared_hcd (const struct hc_driver *driver, struct device *dev, const char *bus_name, struct usb_hcd *primary_hcd)
 
 EXPORT_SYMBOL_GPL (usb_create_shared_hcd)
 
struct usb_hcd * usb_create_hcd (const struct hc_driver *driver, struct device *dev, const char *bus_name)
 
 EXPORT_SYMBOL_GPL (usb_create_hcd)
 
struct usb_hcd * usb_get_hcd (struct usb_hcd *hcd)
 
 EXPORT_SYMBOL_GPL (usb_get_hcd)
 
void usb_put_hcd (struct usb_hcd *hcd)
 
 EXPORT_SYMBOL_GPL (usb_put_hcd)
 
int usb_hcd_is_primary_hcd (struct usb_hcd *hcd)
 
 EXPORT_SYMBOL_GPL (usb_hcd_is_primary_hcd)
 
int usb_add_hcd (struct usb_hcd *hcd, unsigned int irqnum, unsigned long irqflags)
 
 EXPORT_SYMBOL_GPL (usb_add_hcd)
 
void usb_remove_hcd (struct usb_hcd *hcd)
 
 EXPORT_SYMBOL_GPL (usb_remove_hcd)
 
void usb_hcd_platform_shutdown (struct platform_device *dev)
 
 EXPORT_SYMBOL_GPL (usb_hcd_platform_shutdown)
 

Variables

unsigned long usb_hcds_loaded
 

Macro Definition Documentation

#define KERNEL_REL   bin2bcd(((LINUX_VERSION_CODE >> 16) & 0x0ff))

Definition at line 127 of file hcd.c.

#define KERNEL_VER   bin2bcd(((LINUX_VERSION_CODE >> 8) & 0x0ff))

Definition at line 128 of file hcd.c.

#define USB_MAXBUS   64

Definition at line 93 of file hcd.c.

Function Documentation

DECLARE_WAIT_QUEUE_HEAD ( usb_kill_urb_queue  )
DEFINE_MUTEX ( usb_bus_list_lock  )
EXPORT_SYMBOL_GPL ( usb_hcds_loaded  )
EXPORT_SYMBOL_GPL ( usb_bus_list  )
EXPORT_SYMBOL_GPL ( usb_bus_list_lock  )
EXPORT_SYMBOL_GPL ( usb_hcd_poll_rh_status  )
EXPORT_SYMBOL_GPL ( usb_calc_bus_time  )
EXPORT_SYMBOL_GPL ( usb_hcd_link_urb_to_ep  )
EXPORT_SYMBOL_GPL ( usb_hcd_check_unlink_urb  )
EXPORT_SYMBOL_GPL ( usb_hcd_unlink_urb_from_ep  )
EXPORT_SYMBOL_GPL ( usb_hcd_unmap_urb_setup_for_dma  )
EXPORT_SYMBOL_GPL ( usb_hcd_unmap_urb_for_dma  )
EXPORT_SYMBOL_GPL ( usb_hcd_map_urb_for_dma  )
EXPORT_SYMBOL_GPL ( usb_hcd_giveback_urb  )
EXPORT_SYMBOL_GPL ( usb_alloc_streams  )
EXPORT_SYMBOL_GPL ( usb_free_streams  )
EXPORT_SYMBOL_GPL ( usb_hcd_irq  )
EXPORT_SYMBOL_GPL ( usb_hc_died  )
EXPORT_SYMBOL_GPL ( usb_create_shared_hcd  )
EXPORT_SYMBOL_GPL ( usb_create_hcd  )
EXPORT_SYMBOL_GPL ( usb_get_hcd  )
EXPORT_SYMBOL_GPL ( usb_put_hcd  )
EXPORT_SYMBOL_GPL ( usb_hcd_is_primary_hcd  )
EXPORT_SYMBOL_GPL ( usb_add_hcd  )
EXPORT_SYMBOL_GPL ( usb_remove_hcd  )
EXPORT_SYMBOL_GPL ( usb_hcd_platform_shutdown  )
LIST_HEAD ( usb_bus_list  )
module_param ( authorized_default  ,
int  ,
S_IRUGO S_IWUSR 
)
MODULE_PARM_DESC ( authorized_default  ,
"Default USB device authorization: 0 is not  authorized,
1 is""  authorized 
)
int usb_add_hcd ( struct usb_hcd *  hcd,
unsigned int  irqnum,
unsigned long  irqflags 
)

usb_add_hcd - finish generic HCD structure initialization and register : the usb_hcd structure to initialize : Interrupt line to allocate : Interrupt type flags

Finish the remaining parts of generic HCD initialization: allocate the buffers of consistent memory, register the bus, request the IRQ line, and call the driver's reset() and start() routines.

Definition at line 2402 of file hcd.c.

int usb_alloc_streams ( struct usb_interface interface,
struct usb_host_endpoint **  eps,
unsigned int  num_eps,
unsigned int  num_streams,
gfp_t  mem_flags 
)

Definition at line 1888 of file hcd.c.

long usb_calc_bus_time ( int  speed,
int  is_input,
int  isoc,
int  bytecount 
)

usb_calc_bus_time - approximate periodic transaction time in nanoseconds : from dev->speed; USB_SPEED_{LOW,FULL,HIGH} : true iff the transaction sends data to the host : true for isochronous transactions, false for interrupt ones : how many bytes in the transaction.

Returns approximate bus time in nanoseconds for a periodic transaction. See USB 2.0 spec section 5.11.3; only periodic transfers need to be scheduled in software, this function is only used for such scheduling.

Definition at line 1042 of file hcd.c.

struct usb_hcd* usb_create_hcd ( const struct hc_driver *  driver,
struct device dev,
const char bus_name 
)
read

usb_create_hcd - create and initialize an HCD structure : HC driver that will use this hcd : device for this HC, stored in hcd->self.controller : value to store in hcd->self.bus_name Context: !in_interrupt()

Allocate a struct usb_hcd, with extra space at the end for the HC driver's private data. Initialize the generic members of the hcd structure.

If memory is unavailable, returns NULL.

Definition at line 2301 of file hcd.c.

struct usb_hcd* usb_create_shared_hcd ( const struct hc_driver *  driver,
struct device dev,
const char bus_name,
struct usb_hcd *  primary_hcd 
)
read

usb_create_shared_hcd - create and initialize an HCD structure : HC driver that will use this hcd : device for this HC, stored in hcd->self.controller : value to store in hcd->self.bus_name : a pointer to the usb_hcd structure that is sharing the PCI device. Only allocate certain resources for the primary HCD Context: !in_interrupt()

Allocate a struct usb_hcd, with extra space at the end for the HC driver's private data. Initialize the generic members of the hcd structure.

If memory is unavailable, returns NULL.

Definition at line 2237 of file hcd.c.

void usb_free_streams ( struct usb_interface interface,
struct usb_host_endpoint **  eps,
unsigned int  num_eps,
gfp_t  mem_flags 
)

Definition at line 1923 of file hcd.c.

struct usb_hcd* usb_get_hcd ( struct usb_hcd *  hcd)
read

Definition at line 2329 of file hcd.c.

void usb_hc_died ( struct usb_hcd *  hcd)

usb_hc_died - report abnormal shutdown of a host controller (bus glue) : pointer to the HCD representing the controller

This is called by bus glue to report a USB host controller that died while operations may still have been pending. It's called automatically by the PCI glue, so only glue for non-PCI busses should need to call it.

Only call this function with the primary HCD.

Definition at line 2187 of file hcd.c.

int usb_hcd_alloc_bandwidth ( struct usb_device *  udev,
struct usb_host_config *  new_config,
struct usb_host_interface *  cur_alt,
struct usb_host_interface *  new_alt 
)

usb_hcd_alloc_bandwidth - check whether a new bandwidth setting exceeds the bus bandwidth : target &usb_device : new configuration to install : the current alternate interface setting : alternate interface setting that is being installed

To change configurations, pass in the new configuration in new_config, and pass NULL for cur_alt and new_alt.

To reset a device's configuration (put the device in the ADDRESSED state), pass in NULL for new_config, cur_alt, and new_alt.

To change alternate interface settings, pass in NULL for new_config, pass in the current alternate interface setting in cur_alt, and pass in the new alternate interface setting in new_alt.

Returns an error if the requested bandwidth change exceeds the bus bandwidth or host controller internal resources.

Definition at line 1717 of file hcd.c.

int usb_hcd_check_unlink_urb ( struct usb_hcd *  hcd,
struct urb urb,
int  status 
)

usb_hcd_check_unlink_urb - check whether an URB may be unlinked : host controller to which was submitted : URB being checked for unlinkability : error code to store in if the unlink succeeds

Host controller drivers should call this routine in their dequeue() method. The HCD's private spinlock must be held and interrupts must be disabled. The actions carried out here are required for making sure than an unlink is valid.

Returns 0 for no error, otherwise a negative error code (in which case the dequeue() method must fail). The possible error codes are:

-EIDRM: was not submitted or has already completed. The completion function may not have been called yet.

-EBUSY: has already been unlinked.

Definition at line 1159 of file hcd.c.

void usb_hcd_disable_endpoint ( struct usb_device *  udev,
struct usb_host_endpoint *  ep 
)

Definition at line 1839 of file hcd.c.

void usb_hcd_flush_endpoint ( struct usb_device *  udev,
struct usb_host_endpoint *  ep 
)

Definition at line 1625 of file hcd.c.

int usb_hcd_get_frame_number ( struct usb_device *  udev)

Definition at line 1959 of file hcd.c.

void usb_hcd_giveback_urb ( struct usb_hcd *  hcd,
struct urb urb,
int  status 
)

usb_hcd_giveback_urb - return URB from HCD to device driver : host controller returning the URB : urb being returned to the USB device driver. : completion status code for the URB. Context: in_interrupt()

This hands the URB from HCD to its USB device driver, using its completion function. The HCD has freed all per-urb resources (and is done using urb->hcpriv). It also released all HCD locks; the device driver won't cause problems if it frees, modifies, or resubmits this URB.

If was unlinked, the value of will be overridden by ->unlinked. Erroneous short transfers are detected in case the HCD hasn't checked for them.

Definition at line 1595 of file hcd.c.

irqreturn_t usb_hcd_irq ( int  irq,
void __hcd 
)

usb_hcd_irq - hook IRQs to HCD framework (bus glue) : the IRQ being raised : pointer to the HCD whose IRQ is being signaled

If the controller isn't HALTed, calls the driver's irq handler. Checks whether the controller is now dead.

Definition at line 2151 of file hcd.c.

int usb_hcd_is_primary_hcd ( struct usb_hcd *  hcd)

Definition at line 2344 of file hcd.c.

int usb_hcd_link_urb_to_ep ( struct usb_hcd *  hcd,
struct urb urb 
)

usb_hcd_link_urb_to_ep - add an URB to its endpoint queue : host controller to which was submitted : URB being submitted

Host controller drivers should call this routine in their enqueue() method. The HCD's private spinlock must be held and interrupts must be disabled. The actions carried out here are required for URB submission, as well as for endpoint shutdown and for usb_kill_urb.

Returns 0 for no error, otherwise a negative error code (in which case the enqueue() method must fail). If no error occurs but enqueue() fails anyway, it must call usb_hcd_unlink_urb_from_ep() before releasing the private spinlock and returning.

Definition at line 1101 of file hcd.c.

int usb_hcd_map_urb_for_dma ( struct usb_hcd *  hcd,
struct urb urb,
gfp_t  mem_flags 
)

Definition at line 1356 of file hcd.c.

void usb_hcd_platform_shutdown ( struct platform_device dev)

Definition at line 2614 of file hcd.c.

void usb_hcd_poll_rh_status ( struct usb_hcd *  hcd)

Definition at line 690 of file hcd.c.

void usb_hcd_reset_endpoint ( struct usb_device *  udev,
struct usb_host_endpoint *  ep 
)

usb_hcd_reset_endpoint - reset host endpoint state : USB device. : the endpoint to reset.

Resets any host endpoint state such as the toggle bit, sequence number and current window.

Definition at line 1858 of file hcd.c.

int usb_hcd_submit_urb ( struct urb urb,
gfp_t  mem_flags 
)

Definition at line 1470 of file hcd.c.

void usb_hcd_synchronize_unlinks ( struct usb_device *  udev)

Definition at line 1950 of file hcd.c.

int usb_hcd_unlink_urb ( struct urb urb,
int  status 
)

Definition at line 1545 of file hcd.c.

void usb_hcd_unlink_urb_from_ep ( struct usb_hcd *  hcd,
struct urb urb 
)

usb_hcd_unlink_urb_from_ep - remove an URB from its endpoint queue : host controller to which was submitted : URB being unlinked

Host controller drivers should call this routine before calling usb_hcd_giveback_urb(). The HCD's private spinlock must be held and interrupts must be disabled. The actions carried out here are required for URB completion.

Definition at line 1192 of file hcd.c.

void usb_hcd_unmap_urb_for_dma ( struct usb_hcd *  hcd,
struct urb urb 
)

Definition at line 1312 of file hcd.c.

void usb_hcd_unmap_urb_setup_for_dma ( struct usb_hcd *  hcd,
struct urb urb 
)

Definition at line 1285 of file hcd.c.

void usb_put_hcd ( struct usb_hcd *  hcd)

Definition at line 2337 of file hcd.c.

void usb_remove_hcd ( struct usb_hcd *  hcd)

usb_remove_hcd - shutdown processing for generic HCDs : the usb_hcd structure to remove Context: !in_interrupt()

Disconnects the root hub, then reverses the effects of usb_add_hcd(), invoking the HCD's stop() method.

Definition at line 2560 of file hcd.c.

Variable Documentation

unsigned long usb_hcds_loaded

Definition at line 85 of file hcd.c.