Linux Kernel
3.7.1
|
#include <linux/kernel.h>
#include <linux/errno.h>
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/completion.h>
#include <linux/sched.h>
#include <linux/list.h>
#include <linux/slab.h>
#include <linux/ioctl.h>
#include <linux/usb.h>
#include <linux/usbdevice_fs.h>
#include <linux/usb/hcd.h>
#include <linux/usb/otg.h>
#include <linux/usb/quirks.h>
#include <linux/kthread.h>
#include <linux/mutex.h>
#include <linux/freezer.h>
#include <linux/random.h>
#include <asm/uaccess.h>
#include <asm/byteorder.h>
#include "usb.h"
Go to the source code of this file.
Data Structures | |
struct | usb_port |
struct | usb_hub |
Macros | |
#define | HUB_DEBOUNCE_TIMEOUT 1500 |
#define | HUB_DEBOUNCE_STEP 25 |
#define | HUB_DEBOUNCE_STABLE 100 |
#define | to_usb_port(_dev) container_of(_dev, struct usb_port, dev) |
#define | LED_CYCLE_PERIOD ((2*HZ)/3) |
#define | USB_STS_TIMEOUT 1000 |
#define | USB_STS_RETRIES 5 |
#define | PORT_RESET_TRIES 5 |
#define | SET_ADDRESS_TRIES 2 |
#define | GET_DESCRIPTOR_TRIES 2 |
#define | SET_CONFIG_TRIES (2 * (use_both_schemes + 1)) |
#define | USE_NEW_SCHEME(i) ((i) / 2 == (int)old_scheme_first) |
#define | HUB_ROOT_RESET_TIME 50 /* times are in msec */ |
#define | HUB_SHORT_RESET_TIME 10 |
#define | HUB_BH_RESET_TIME 50 |
#define | HUB_LONG_RESET_TIME 200 |
#define | HUB_RESET_TIMEOUT 500 |
#define | hub_suspend NULL |
#define | hub_resume NULL |
#define | hub_reset_resume NULL |
#define | usb_sndaddr0pipe() (PIPE_CONTROL << 30) |
#define | usb_rcvaddr0pipe() ((PIPE_CONTROL << 30) | USB_DIR_IN) |
#define | GET_DESCRIPTOR_BUFSIZE 64 |
Enumerations | |
enum | hub_activation_type { HUB_INIT, HUB_INIT2, HUB_INIT3, HUB_POST_RESET, HUB_RESUME, HUB_RESET_RESUME } |
enum | hub_quiescing_type { HUB_DISCONNECT, HUB_PRE_RESET, HUB_SUSPEND } |
Variables | |
struct device_type | usb_port_device_type |
#define GET_DESCRIPTOR_BUFSIZE 64 |
#define to_usb_port | ( | _dev | ) | container_of(_dev, struct usb_port, dev) |
#define usb_rcvaddr0pipe | ( | ) | ((PIPE_CONTROL << 30) | USB_DIR_IN) |
enum hub_activation_type |
enum hub_quiescing_type |
DECLARE_RWSEM | ( | ehci_cf_port_reset_rwsem | ) |
EXPORT_SYMBOL_GPL | ( | ehci_cf_port_reset_rwsem | ) |
EXPORT_SYMBOL_GPL | ( | usb_wakeup_notification | ) |
EXPORT_SYMBOL_GPL | ( | usb_hub_clear_tt_buffer | ) |
EXPORT_SYMBOL_GPL | ( | usb_set_device_state | ) |
EXPORT_SYMBOL_GPL | ( | usb_disable_lpm | ) |
EXPORT_SYMBOL_GPL | ( | usb_enable_lpm | ) |
EXPORT_SYMBOL_GPL | ( | usb_unlocked_disable_lpm | ) |
EXPORT_SYMBOL_GPL | ( | usb_unlocked_enable_lpm | ) |
EXPORT_SYMBOL_GPL | ( | usb_disable_ltm | ) |
EXPORT_SYMBOL_GPL | ( | usb_enable_ltm | ) |
EXPORT_SYMBOL_GPL | ( | usb_ep0_reinit | ) |
EXPORT_SYMBOL_GPL | ( | usb_reset_device | ) |
EXPORT_SYMBOL_GPL | ( | usb_queue_reset_device | ) |
EXPORT_SYMBOL_GPL | ( | usb_hub_find_child | ) |
MODULE_DEVICE_TABLE | ( | usb | , |
hub_id_table | |||
) |
MODULE_PARM_DESC | ( | blinkenlights | , |
"true to cycle leds on hubs" | |||
) |
MODULE_PARM_DESC | ( | initial_descriptor_timeout | , |
"initial 64-byte descriptor request timeout in milliseconds ""(default 5000 - 5.0 seconds)" | |||
) |
MODULE_PARM_DESC | ( | use_both_schemes | , |
"try the other device initialization scheme if the ""first one fails" | |||
) |
usb_deauthorize_device - deauthorize a device (usbcore-internal) : USB device
Move the USB device to a very basic state where interfaces are disabled and the device is in fact unconfigured and unusable.
We share a lock (that we have) with device_del(), so we need to defer its call.
usb_disconnect - disconnect a device (usbcore-internal) : pointer to device being disconnected Context: !in_interrupt ()
Something got disconnected. Get rid of it and all of its children.
If *pdev is a normal device then the parent hub must already be locked. If *pdev is a root hub then this routine will acquire the usb_bus_list_lock on behalf of the caller.
Only hub drivers (including virtual root hub drivers for host controllers) should ever call this.
This call is synchronous, and may not be used in an interrupt context.
usb_hub_clear_tt_buffer - clear control/bulk TT state in high speed hub : an URB associated with the failed or incomplete split transaction
High speed HCDs use this to tell the hub driver that some split control or bulk transaction failed in a way that requires clearing internal state of a transaction translator. This is normally detected (and reported) from interrupt context.
It may not be possible for that hub to handle additional full (or low) speed transactions until that state is fully cleared out.
usb_hub_find_child - Get the pointer of child device attached to the port which is specified by . : USB device belonging to the usb hub : port num to indicate which port the child device is attached to.
USB drivers call this function to get hub's child device pointer.
Return NULL if input param is invalid and child's usb_device pointer if non-NULL.
usb_new_device - perform initial device setup (usbcore-internal) : newly addressed device (in ADDRESS state)
This is called with devices which have been detected but not fully enumerated. The device descriptor is available, but not descriptors for any device configuration. The caller must have locked either the parent hub (if udev is a normal device) or else the usb_bus_list_lock (if udev is a root hub). The parent's pointer to udev has already been installed, but udev is not yet visible through sysfs or other filesystem code.
It will return if the device is configured properly or not. Zero if the interface was registered with the driver core; else a negative errno value.
This call is synchronous, and may not be used in an interrupt context.
Only the hub driver or root-hub registrar should ever call this.
void usb_queue_reset_device | ( | struct usb_interface * | iface | ) |
usb_queue_reset_device - Reset a USB device from an atomic context : USB interface belonging to the device to reset
This function can be used to reset a USB device from an atomic context, where usb_reset_device() won't work (as it blocks).
Doing a reset via this method is functionally equivalent to calling usb_reset_device(), except for the fact that it is delayed to a workqueue. This means that any drivers bound to other interfaces might be unbound, as well as users from usbfs in user space.
Corner cases:
There is no no need to lock/unlock the as schedule_work() does its own.
NOTE: We don't do any reference count tracking because it is not needed. The lifecycle of the work_struct is tied to the usb_interface. Before destroying the interface we cancel the work_struct, so the fact that work_struct is queued and or running means the interface (and thus, the device) exist and are referenced.
usb_remove_device - disable a device's port on its parent hub : device to be disabled and removed Context: locked, must be able to sleep.
After 's port has been disabled, khubd is notified and it will see that the device has been disconnected. When the device is physically unplugged and something is plugged in, the events will be received and processed normally.
usb_reset_device - warn interface drivers and perform a USB port reset : device to reset (not in SUSPENDED or NOTATTACHED state)
Warns all drivers bound to registered interfaces (using their pre_reset method), performs the port reset, and then lets the drivers know that the reset is over (using their post_reset method).
Return value is the same as for usb_reset_and_verify_device().
The caller must own the device lock. For example, it's safe to use this from a driver probe() routine after downloading new firmware. For calls that might not occur during probe(), drivers should lock the device using usb_lock_device_for_reset().
If an interface is currently being probed or disconnected, we assume its driver knows how to handle resets. For all other interfaces, if the driver doesn't have pre_reset and post_reset methods then we attempt to unbind it and rebind afterward.
void usb_set_device_state | ( | struct usb_device * | udev, |
enum usb_device_state | new_state | ||
) |
usb_set_device_state - change a device's current state (usbcore, hcds) : pointer to device whose state should be changed : new state value to be stored
udev->state is not fully protected by the device lock. Although most transitions are made only while holding the lock, the state can can change to USB_STATE_NOTATTACHED at almost any time. This is so that devices can be marked as disconnected as soon as possible, without having to wait for any semaphores to be released. As a result, all changes to any device's state must be protected by the device_state_lock spinlock.
Once a device has been added to the device tree, all changes to its state should be made using this routine. The state should not be set directly.
If udev->state is already USB_STATE_NOTATTACHED then no change is made. Otherwise udev->state is set to new_state, and if new_state is USB_STATE_NOTATTACHED then all of udev's descendants' states are also set to USB_STATE_NOTATTACHED.
struct device_type usb_port_device_type |