1STRUCT USB_DRIVER(9) Host-Side Data Types and Macro STRUCT USB_DRIVER(9)
2
3
4
6 struct_usb_driver - identifies USB interface driver to usbcore
7
9 struct usb_driver {
10 const char * name;
11 int (* probe) (struct usb_interface *intf,const struct usb_device_id *id);
12 void (* disconnect) (struct usb_interface *intf);
13 int (* ioctl) (struct usb_interface *intf, unsigned int code,void *buf);
14 int (* suspend) (struct usb_interface *intf, pm_message_t message);
15 int (* resume) (struct usb_interface *intf);
16 int (* reset_resume) (struct usb_interface *intf);
17 int (* pre_reset) (struct usb_interface *intf);
18 int (* post_reset) (struct usb_interface *intf);
19 const struct usb_device_id * id_table;
20 struct usb_dynids dynids;
21 struct usbdrv_wrap drvwrap;
22 unsigned int no_dynamic_id:1;
23 unsigned int supports_autosuspend:1;
24 unsigned int soft_unbind:1;
25 #ifndef __GENKSYMS__
26 unsigned int disable_hub_initiated_lpm:1;
27 #endif
28 };
29
31 name
32 The driver name should be unique among USB drivers, and should
33 normally be the same as the module name.
34
35 probe
36 Called to see if the driver is willing to manage a particular
37 interface on a device. If it is, probe returns zero and uses
38 usb_set_intfdata to associate driver-specific data with the
39 interface. It may also use usb_set_interface to specify the
40 appropriate altsetting. If unwilling to manage the interface,
41 return -ENODEV, if genuine IO errors occured, an appropriate
42 negative errno value.
43
44 disconnect
45 Called when the interface is no longer accessible, usually because
46 its device has been (or is being) disconnected or the driver module
47 is being unloaded.
48
49 ioctl
50 Used for drivers that want to talk to userspace through the “usbfs”
51 filesystem. This lets devices provide ways to expose information to
52 user space regardless of where they do (or don´t) show up otherwise
53 in the filesystem.
54
55 suspend
56 Called when the device is going to be suspended by the system.
57
58 resume
59 Called when the device is being resumed by the system.
60
61 reset_resume
62 Called when the suspended device has been reset instead of being
63 resumed.
64
65 pre_reset
66 Called by usb_reset_device when the device is about to be reset.
67
68 post_reset
69 Called by usb_reset_device after the device has been reset
70
71 id_table
72 USB drivers use ID table to support hotplugging. Export this with
73 MODULE_DEVICE_TABLE(usb,...). This must be set or your driver´s
74 probe function will never get called.
75
76 dynids
77 used internally to hold the list of dynamically added device ids
78 for this driver.
79
80 drvwrap
81 Driver-model core structure wrapper.
82
83 no_dynamic_id
84 if set to 1, the USB core will not allow dynamic ids to be added to
85 this driver by preventing the sysfs file from being created.
86
87 supports_autosuspend
88 if set to 0, the USB core will not allow autosuspend for interfaces
89 bound to this driver.
90
91 soft_unbind
92 if set to 1, the USB core will not kill URBs and disable endpoints
93 before calling the driver´s disconnect method.
94
95 disable_hub_initiated_lpm
96 if set to 0, the USB core will not allow hubs to initiate lower
97 power link state transitions when an idle timeout occurs.
98 Device-initiated USB 3.0 link PM will still be allowed.
99
101 USB interface drivers must provide a name, probe and disconnect
102 methods, and an id_table. Other driver fields are optional.
103
104 The id_table is used in hotplugging. It holds a set of descriptors, and
105 specialized data may be associated with each entry. That table is used
106 by both user and kernel mode hotplugging support.
107
108 The probe and disconnect methods are called in a context where they can
109 sleep, but they should avoid abusing the privilege. Most work to
110 connect to a device should be done when the device is opened, and
111 undone at the last close. The disconnect code needs to address
112 concurrency issues with respect to open and close methods, as well as
113 forcing all pending I/O requests to complete (by unlinking them as
114 necessary, and blocking until the unlinks complete).
115
117Kernel Hackers Manual 2.6. June 2019 STRUCT USB_DRIVER(9)