usb.h
来自「此工具是arm-linux-GCC交叉编译工具(cross-3.4.4)」· C头文件 代码 · 共 1,156 行 · 第 1/4 页
H
1,156 行
struct class_device *class_dev; /* class device for this bus */ struct kref kref; /* handles reference counting this bus */ void (*release)(struct usb_bus *bus); /* function to destroy this bus's memory */#if defined(CONFIG_USB_MON) struct mon_bus *mon_bus; /* non-null when associated */ int monitored; /* non-zero when monitored */#endif};/* -------------------------------------------------------------------------- *//* This is arbitrary. * From USB 2.0 spec Table 11-13, offset 7, a hub can * have up to 255 ports. The most yet reported is 10. */#define USB_MAXCHILDREN (16)struct usb_tt;/* * struct usb_device - kernel's representation of a USB device * * FIXME: Write the kerneldoc! * * Usbcore drivers should not set usbdev->state directly. Instead use * usb_set_device_state(). */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];};#define to_usb_device(d) container_of(d, struct usb_device, dev)extern struct usb_device *usb_get_dev(struct usb_device *dev);extern void usb_put_dev(struct usb_device *dev);extern void usb_lock_device(struct usb_device *udev);extern int usb_trylock_device(struct usb_device *udev);extern int usb_lock_device_for_reset(struct usb_device *udev, struct usb_interface *iface);extern void usb_unlock_device(struct usb_device *udev);/* USB port reset for device reinitialization */extern int usb_reset_device(struct usb_device *dev);extern struct usb_device *usb_find_device(u16 vendor_id, u16 product_id);/*-------------------------------------------------------------------------*//* for drivers using iso endpoints */extern int usb_get_current_frame_number (struct usb_device *usb_dev);/* used these for multi-interface device registration */extern int usb_driver_claim_interface(struct usb_driver *driver, struct usb_interface *iface, void* priv);/** * usb_interface_claimed - returns true iff an interface is claimed * @iface: the interface being checked * * Returns true (nonzero) iff the interface is claimed, else false (zero). * Callers must own the driver model's usb bus readlock. So driver * probe() entries don't need extra locking, but other call contexts * may need to explicitly claim that lock. * */static inline int usb_interface_claimed(struct usb_interface *iface) { return (iface->dev.driver != NULL);}extern void usb_driver_release_interface(struct usb_driver *driver, struct usb_interface *iface);const struct usb_device_id *usb_match_id(struct usb_interface *interface, const struct usb_device_id *id);extern struct usb_interface *usb_find_interface(struct usb_driver *drv, int minor);extern struct usb_interface *usb_ifnum_to_if(struct usb_device *dev, unsigned ifnum);extern struct usb_host_interface *usb_altnum_to_altsetting( struct usb_interface *intf, unsigned int altnum);/** * usb_make_path - returns stable device path in the usb tree * @dev: the device whose path is being constructed * @buf: where to put the string * @size: how big is "buf"? * * Returns length of the string (> 0) or negative if size was too small. * * This identifier is intended to be "stable", reflecting physical paths in * hardware such as physical bus addresses for host controllers or ports on * USB hubs. That makes it stay the same until systems are physically * reconfigured, by re-cabling a tree of USB devices or by moving USB host * controllers. Adding and removing devices, including virtual root hubs * in host controller driver modules, does not change these path identifers; * neither does rebooting or re-enumerating. These are more useful identifiers * than changeable ("unstable") ones like bus numbers or device addresses. * * With a partial exception for devices connected to USB 2.0 root hubs, these * identifiers are also predictable. So long as the device tree isn't changed, * plugging any USB device into a given hub port always gives it the same path. * Because of the use of "companion" controllers, devices connected to ports on * USB 2.0 root hubs (EHCI host controllers) will get one path ID if they are * high speed, and a different one if they are full or low speed. */static inline int usb_make_path (struct usb_device *dev, char *buf, size_t size){ int actual; actual = snprintf (buf, size, "usb-%s-%s", dev->bus->bus_name, dev->devpath); return (actual >= (int)size) ? -1 : actual;}/*-------------------------------------------------------------------------*/#define USB_DEVICE_ID_MATCH_DEVICE (USB_DEVICE_ID_MATCH_VENDOR | USB_DEVICE_ID_MATCH_PRODUCT)#define USB_DEVICE_ID_MATCH_DEV_RANGE (USB_DEVICE_ID_MATCH_DEV_LO | USB_DEVICE_ID_MATCH_DEV_HI)#define USB_DEVICE_ID_MATCH_DEVICE_AND_VERSION (USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_DEV_RANGE)#define USB_DEVICE_ID_MATCH_DEV_INFO \ (USB_DEVICE_ID_MATCH_DEV_CLASS | USB_DEVICE_ID_MATCH_DEV_SUBCLASS | USB_DEVICE_ID_MATCH_DEV_PROTOCOL)#define USB_DEVICE_ID_MATCH_INT_INFO \ (USB_DEVICE_ID_MATCH_INT_CLASS | USB_DEVICE_ID_MATCH_INT_SUBCLASS | USB_DEVICE_ID_MATCH_INT_PROTOCOL)/** * USB_DEVICE - macro used to describe a specific usb device * @vend: the 16 bit USB Vendor ID * @prod: the 16 bit USB Product ID * * This macro is used to create a struct usb_device_id that matches a * specific device. */#define USB_DEVICE(vend,prod) \ .match_flags = USB_DEVICE_ID_MATCH_DEVICE, .idVendor = (vend), .idProduct = (prod)/** * USB_DEVICE_VER - macro used to describe a specific usb device with a version range * @vend: the 16 bit USB Vendor ID * @prod: the 16 bit USB Product ID * @lo: the bcdDevice_lo value * @hi: the bcdDevice_hi value * * This macro is used to create a struct usb_device_id that matches a * specific device, with a version range. */#define USB_DEVICE_VER(vend,prod,lo,hi) \ .match_flags = USB_DEVICE_ID_MATCH_DEVICE_AND_VERSION, .idVendor = (vend), .idProduct = (prod), .bcdDevice_lo = (lo), .bcdDevice_hi = (hi)/** * USB_DEVICE_INFO - macro used to describe a class of usb devices * @cl: bDeviceClass value * @sc: bDeviceSubClass value * @pr: bDeviceProtocol value * * This macro is used to create a struct usb_device_id that matches a * specific class of devices. */#define USB_DEVICE_INFO(cl,sc,pr) \ .match_flags = USB_DEVICE_ID_MATCH_DEV_INFO, .bDeviceClass = (cl), .bDeviceSubClass = (sc), .bDeviceProtocol = (pr)/** * USB_INTERFACE_INFO - macro used to describe a class of usb interfaces * @cl: bInterfaceClass value * @sc: bInterfaceSubClass value * @pr: bInterfaceProtocol value * * This macro is used to create a struct usb_device_id that matches a * specific class of interfaces. */#define USB_INTERFACE_INFO(cl,sc,pr) \ .match_flags = USB_DEVICE_ID_MATCH_INT_INFO, .bInterfaceClass = (cl), .bInterfaceSubClass = (sc), .bInterfaceProtocol = (pr)/* -------------------------------------------------------------------------- *//** * struct usb_driver - identifies USB driver to usbcore * @owner: Pointer to the module owner of this driver; initialize * it using THIS_MODULE. * @name: The driver name should be unique among USB drivers, * and should normally be the same as the module name. * @probe: Called to see if the driver is willing to manage a particular * interface on a device. If it is, probe returns zero and uses * dev_set_drvdata() to associate driver-specific data with the * interface. It may also use usb_set_interface() to specify the * appropriate altsetting. If unwilling to manage the interface, * return a negative errno value. * @disconnect: Called when the interface is no longer accessible, usually * because its device has been (or is being) disconnected or the * driver module is being unloaded. * @ioctl: Used for drivers that want to talk to userspace through * the "usbfs" filesystem. This lets devices provide ways to * expose information to user space regardless of where they * do (or don't) show up otherwise in the filesystem. * @suspend: Called when the device is going to be suspended by the system. * @resume: Called when the device is being resumed by the system. * @id_table: USB drivers use ID table to support hotplugging. * Export this with MODULE_DEVICE_TABLE(usb,...). This must be set * or your driver's probe function will never get called. * @driver: the driver model core driver structure. * * USB drivers must provide a name, probe() and disconnect() methods, * and an id_table. Other driver fields are optional. * * The id_table is used in hotplugging. It holds a set of descriptors, * and specialized data may be associated with each entry. That table * is used by both user and kernel mode hotplugging support. * * The probe() and disconnect() methods are called in a context where * they can sleep, but they should avoid abusing the privilege. Most * work to connect to a device should be done when the device is opened, * and undone at the last close. The disconnect code needs to address * concurrency issues with respect to open() and close() methods, as * well as forcing all pending I/O requests to complete (by unlinking * them as necessary, and blocking until the unlinks complete). */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;};#define to_usb_driver(d) container_of(d, struct usb_driver, driver)extern struct bus_type usb_bus_type;/** * struct usb_class_driver - identifies a USB driver that wants to use the USB major number * @name: devfs name for this driver. Will also be used by the driver * class code to create a usb class device. * @fops: pointer to the struct file_operations of this driver. * @mode: the mode for the devfs file to be created for this driver.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?