/* NOTE: these two are _only_ in audio endpoints. */ /* use USB_DT_ENDPOINT*_SIZE in bLength, not sizeof. */ __u8 bRefresh; __u8 bSynchAddress; } __attribute__ ((packed));
structusb_interface { structusb_host_interface *altsetting;// 一个包含所有可用于该接口的“设置”的数组 structusb_host_interface *cur_altsetting;/* the currently active alternate setting */ unsigned num_altsetting; /* number of alternate settings */
/* If there is an interface association descriptor then it will list * the associated interfaces */ structusb_interface_assoc_descriptor *intf_assoc; int minor; /* minor number this interface is bound to */ // 下面这些字段驱动程序一般无需关心 enumusb_interface_conditioncondition;/* state of binding */ unsigned sysfs_files_created:1; /* the sysfs attributes exist */ unsigned ep_devs_created:1; /* endpoint "devices" exist */ unsigned unregistering:1; /* unregistration is in progress */ unsigned needs_remote_wakeup:1; /* driver requires remote wakeup */ unsigned needs_altsetting0:1; /* switch to altsetting 0 is pending */ unsigned needs_binding:1; /* needs delayed unbind/rebind */ unsigned resetting_device:1; /* true: bandwidth alloc after reset */ unsigned authorized:1; /* used for interface authorization */
structdevicedev;/* interface specific device info */ structdevice *usb_dev; atomic_t pm_usage_cnt; /* usage counter for autosuspend */ structwork_structreset_ws;/* for resets in atomic context */ };
// 数据传输接口 intusb_bulk_msg( struct usb_device *usb_dev, // 目标USB设备指针 unsignedint pipe, // endpoint "pipe" to send the message to void *data, // pointer to the data to send int len, // length in bytes of the data to send int *actual_length, // 指针入参式返回值,说明传输了的实际大小 int timeout // jiffies为单位的超时时长,0值则一直等待数据传输完成 ); // 和usb_bulk_msg类似,不过是用于发送控制信息的 intusb_control_msg( struct usb_device *dev, // pointer to the usb device to send the message to unsignedint pipe, // endpoint "pipe" to send the message to __u8 request, // USB message request value __u8 requesttype, // USB message request type value __u16 value, // USB message value __u16 index, // USB message index value void *data, // pointer to the data to send __u16 size, // length in bytes of the data to send int timeout // jiffies为单位的超时时长,0值则一直等待数据传输完成 );