USB驱动中的几个关键数据结构

来源:互联网 发布:淘宝刚开店卖什么 编辑:程序博客网 时间:2024/04/28 16:19

usb_driver:描述USB驱动程序的数据结构 ----驱动

struct usb_driver {
     struct module *owner;

     const char *name;

     int (*probe) (struct usb_interface *intf, const struct usb_device_id *id);

     void (*disconnect) (struct usb_interface *intf);

     int (*ioctl) (struct usb_interface *intf, unsigned int code, void *buf);

     int (*suspend) (struct usb_interface *intf, pm_message_t message);
     int (*resume) (struct usb_interface *intf);

     const struct usb_device_id *id_table;

     struct device_driver driver;//(这个是基本的数据结构,具体驱动的数据结构以其为核心进行了包装)
};

struct usb_device:描述USB设备的数据结构  ----设备

struct usb_device {
     int  devnum;  /* Address on USB bus */
     char  devpath [16]; /* Use in messages: /port/port/... */
     enum usb_device_state state; /* configured, not attached, etc */
     enum usb_device_speed speed; /* high/full/low (or error) */
     
     struct usb_tt *tt;   /* low/full speed dev, highspeed hub */
     int  ttport;  /* device port on that tt hub */
     
     struct semaphore serialize;
     
     unsigned int toggle[2];  /* one bit for each endpoint ([0] = IN, [1] = OUT) */
     
     struct usb_device *parent; /* our hub, unless we're the root */
     struct usb_bus *bus;  /* Bus we're part of */
     struct usb_host_endpoint ep0;
     
     struct device dev;  /* Generic device interface */
     
     struct usb_device_descriptor descriptor;/* Descriptor */
     struct usb_host_config *config; /* All of the configs */
     
     struct usb_host_config *actconfig;/* the active configuration */
     struct usb_host_endpoint *ep_in[16];
     struct usb_host_endpoint *ep_out[16];
     
     char **rawdescriptors;  /* Raw descriptors for each config */
     
     int have_langid;  /* whether string_langid is valid yet */
     int string_langid;  /* language ID for strings */
     
     char *product;
     char *manufacturer;
     char *serial;   /* static strings from the device */
     struct list_head filelist;
     struct class_device *class_dev;
     struct dentry *usbfs_dentry; /* usbfs dentry entry for the device */
     
     /*
      * Child devices - these can be either new devices
      * (if this is a hub device), or different instances
      * of this same device.
      *
      * Each instance needs its own set of data structures.
      */
     
     int maxchild;   /* Number of ports if hub */
     struct usb_device *children[USB_MAXCHILDREN];
};

原创粉丝点击