您的位置:首页 > 运维架构 > Linux

Linux usb_device usb_bus usb_driver的三角关系-USB Device

2016-11-16 00:00 260 查看

一、USB Device


1. struct device:

The Basic Device Structure, generic device interface(所有设备的抽象)
-struct bus_type *bus; /* type of bus device is on */
-struct device_driver *driver; /* which driver has allocated this device */

2. struct usb_device:

kernel's representation of a USB device (它包含struct device,USB设备)

-struct device dev; /* generic device interface */

-struct usb_device_descriptor descriptor; /* USB device descriptor */
- struct usb_bus *bus; /* bus we're part of */
-struct usb_host_endpoint ep0; /* endpoint 0 data (default control pipe) */

-struct usb_host_config *config; /* all of the device's configs */
-struct usb_host_config *actconfig; /* the active configuration */
-struct usb_host_endpoint *ep_in[16]; /* array of IN endpoints */
-struct usb_host_endpoint *ep_out[16]; /* array of OUT endpoints */

3. struct usb_host_config

representation of a device's configuration

/* array of pointers to usb_interface structures, one for each interface in the configuration. These pointers are valid only while the the configuration is active.*/

-struct usb_interface *interface[USB_MAXINTERFACES];

/* array of pointers to usb_interface_cache structures, one for each interface in the configuration. These structures exist for the entirelife of the device. Interface information availableeven when this isnot activeconfiguration */

-struct usb_interface_cache *intf_cache[USB_MAXINTERFACES];

4. struct usb_interface

what usb device drivers talk to

/* array of alternate settings for this interface, stored in no particular order. one for each alternate setting that may be selected. Each one includes a set of endpoint configurations. */
-struct usb_host_interface *altsetting;
-struct usb_host_interface *cur_altsetting; /* the currently

5. struct usb_host_interface
host-side wrapper for one interface setting's parsed descriptors
-struct usb_interface_descriptor desc;
/* array of desc.bNumEndpoint endpoints associated with this interface setting. these will be in no particular order.*/
-struct usb_host_endpoint *endpoint;

6. struct usb_host_endpoint

host-side endpoint descriptor and queue

/* descriptor for this endpoint, e.g.: wMaxPacketSize */

-struct usb_endpoint_descriptor desc;

/*urbs queued to this endpoint; maintained by usbcore*/
-struct list_head urb_list;

/* for use by HCD; typically holds hardware dma queue head (QH) */
-void *hcpriv;

/* ep_device for sysfs info*/

-struct ep_device *ep_dev;

7. usb_alloc_dev

usb device constructor (usbcore-internal)
struct usb_device *usb_alloc_dev(struct usb_device *parent, struct usb_bus *bus, unsigned port1)

@parent: hub to which device is connected; null to allocate a root hub
@bus : bus used to access the device
@port1: one-based index of port; ignored for root hubs
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: