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 (* unlocked_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 disable_hub_initiated_lpm:1;
25 unsigned int soft_unbind:1;
26 };
27
29 name
30 The driver name should be unique among USB drivers, and should
31 normally be the same as the module name.
32
33 probe
34 Called to see if the driver is willing to manage a particular
35 interface on a device. If it is, probe returns zero and uses
36 usb_set_intfdata to associate driver-specific data with the
37 interface. It may also use usb_set_interface to specify the
38 appropriate altsetting. If unwilling to manage the interface,
39 return -ENODEV, if genuine IO errors occurred, an appropriate
40 negative errno value.
41
42 disconnect
43 Called when the interface is no longer accessible, usually because
44 its device has been (or is being) disconnected or the driver module
45 is being unloaded.
46
47 unlocked_ioctl
48 Used for drivers that want to talk to userspace through the “usbfs”
49 filesystem. This lets devices provide ways to expose information to
50 user space regardless of where they do (or don't) show up otherwise
51 in the filesystem.
52
53 suspend
54 Called when the device is going to be suspended by the system
55 either from system sleep or runtime suspend context. The return
56 value will be ignored in system sleep context, so do NOT try to
57 continue using the device if suspend fails in this case. Instead,
58 let the resume or reset-resume routine recover from the failure.
59
60 resume
61 Called when the device is being resumed by the system.
62
63 reset_resume
64 Called when the suspended device has been reset instead of being
65 resumed.
66
67 pre_reset
68 Called by usb_reset_device when the device is about to be reset.
69 This routine must not return until the driver has no active URBs
70 for the device, and no more URBs may be submitted until the
71 post_reset method is called.
72
73 post_reset
74 Called by usb_reset_device after the device has been reset
75
76 id_table
77 USB drivers use ID table to support hotplugging. Export this with
78 MODULE_DEVICE_TABLE(usb,...). This must be set or your driver's
79 probe function will never get called.
80
81 dynids
82 used internally to hold the list of dynamically added device ids
83 for this driver.
84
85 drvwrap
86 Driver-model core structure wrapper.
87
88 no_dynamic_id
89 if set to 1, the USB core will not allow dynamic ids to be added to
90 this driver by preventing the sysfs file from being created.
91
92 supports_autosuspend
93 if set to 0, the USB core will not allow autosuspend for interfaces
94 bound to this driver.
95
96 disable_hub_initiated_lpm
97 if set to 1, the USB core will not allow hubs to initiate lower
98 power link state transitions when an idle timeout occurs.
99 Device-initiated USB 3.0 link PM will still be allowed.
100
101 soft_unbind
102 if set to 1, the USB core will not kill URBs and disable endpoints
103 before calling the driver's disconnect method.
104
106 USB interface drivers must provide a name, probe and disconnect
107 methods, and an id_table. Other driver fields are optional.
108
109 The id_table is used in hotplugging. It holds a set of descriptors, and
110 specialized data may be associated with each entry. That table is used
111 by both user and kernel mode hotplugging support.
112
113 The probe and disconnect methods are called in a context where they can
114 sleep, but they should avoid abusing the privilege. Most work to
115 connect to a device should be done when the device is opened, and
116 undone at the last close. The disconnect code needs to address
117 concurrency issues with respect to open and close methods, as well as
118 forcing all pending I/O requests to complete (by unlinking them as
119 necessary, and blocking until the unlinks complete).
120
122Kernel Hackers Manual 3.10 June 2019 STRUCT USB_DRIVER(9)