usb设备---usb_device

本文介绍了USB设备在内核中的表示——struct usb_device,包括设备号、设备状态、速度、端点、字符串描述符等关键字段,并讨论了其在USB设备管理中的作用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

usb_device 结构体描述如下:
    /**
     * struct usb_device - kernel's representation of a USB device
     * @devnum: device number; address on a USB bus
     * @devpath: device ID string for use in messages (e.g., /port/...)
     * @route: tree topology hex string for use with xHCI
     * @state: device state: configured, not attached, etc.
     * @speed: device speed: high/full/low (or error)
     * @tt: Transaction Translator info; used with low/full speed dev, highspeed hub
     * @ttport: device port on that tt hub
     * @toggle: one bit for each endpoint, with ([0] = IN, [1] = OUT) endpoints
     * @parent: our hub, unless we're the root
     * @bus: bus we're part of
     * @ep0: endpoint 0 data (default control pipe)
     * @dev: generic device interface
     * @descriptor: USB device descriptor
     * @config: all of the device's configs
     * @actconfig: the active configuration
     * @ep_in: array of IN endpoints
     * @ep_out: array of OUT endpoints
     * @rawdescriptors: raw descriptors for each config
     * @bus_mA: Current available from the bus
     * @portnum: parent port number (origin 1)
     * @level: number of USB hub ancestors
     * @can_submit: URBs may be submitted
     * @persist_enabled: USB_PERSIST enabled for this device
     * @have_langid: whether string_langid is valid
     * @authorized: policy has said we can use it;
     *    (user space) policy determines if we authorize this device to be
     *    used or not. By default, wired USB devices are authorized.
     *    WUSB devices are not, until we authorize them from user space.
     *    FIXME -- complete doc
     * @authenticated: Crypto authentication passed
     * @wusb: device is Wireless USB
     * @string_langid: language ID for strings
     * @product: iProduct string, if present (static)
     * @manufacturer: iManufacturer string, if present (static)
     * @serial: iSerialNumber string, if present (static)
     * @filelist: usbfs files that are open to this device
     * @usb_classdev: USB class device that was created for usbfs device
     *    access from userspace
     * @usbfs_dentry: usbfs dentry entry for the device
     * @maxchild: number of ports if hub
     * @children: child devices - USB devices that are attached to this hub
     * @quirks: quirks of the whole device
     * @urbnum: number of URBs submitted for the whole device
     * @active_duration: total time device is not suspended
     * @last_busy: time of last use
     * @autosuspend_delay: in jiffies
     * @connect_time: time device was first connected
     * @do_remote_wakeup: remote wakeup should be enabled
     * @reset_resume: needs reset instead of resume
     * @wusb_dev: if this is a Wireless USB device, link to the WUSB
     *    specific data for the device.
     * @slot_id: Slot ID assigned by xHCI
     *
     * Notes:
     * Usbcore drivers should not set usbdev->state directly. Instead use
     * usb_set_device_state().
     */
    struct usb_device {
        int        devnum;
        char        devpath[16];
        u32        route;
        enum usb_device_state    state;
        enum usb_device_speed    speed;
        struct usb_tt    *tt;
        int        ttport;
        unsigned int toggle[2];
        struct usb_device *parent;
        struct usb_bus *bus;
        struct usb_host_endpoint ep0;
        struct device dev;
        struct usb_device_descriptor descriptor;
        struct usb_host_config *config;
        struct usb_host_config *actconfig;
        struct usb_host_endpoint *ep_in[16];
        struct usb_host_endpoint *ep_out[16];
        char **rawdescriptors;
        unsigned short bus_mA;
        u8 portnum;
        u8 level;
        unsigned can_submit:1;
        unsigned persist_enabled:1;
        unsigned have_langid:1;
        unsigned authorized:1;
        unsigned authenticated:1;
        unsigned wusb:1;
        int string_langid;
        /* static strings from the device */
        char *product;
        char *manufacturer;
        char *serial;
        struct list_head filelist;
    #ifdef CONFIG_USB_DEVICE_CLASS
        struct device *usb_classdev;
    #endif
    #ifdef CONFIG_USB_DEVICEFS
        struct dentry *usbfs_dentry;
    #endif
        int maxchild;
        struct usb_device *children[USB_MAXCHILDREN];
        u32 quirks;
        atomic_t urbnum;
        unsigned long active_duration;
    #ifdef CONFIG_PM
        unsigned long last_busy;
        int autosuspend_delay;
        unsigned long connect_time;
        unsigned do_remote_wakeup:1;
        unsigned reset_resume:1;
    #endif
        struct wusb_dev *wusb_dev;
        int slot_id;
    };
    #define    to_usb_device(d) container_of(d, struct usb_device, dev)




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值