1<html><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968"><title>struct usb_driver</title><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"><link rel="home" href="index.html" title="The Linux-USB Host Side API"><link rel="up" href="hostside.html" title="Chapter 4. Host-Side Data Types and Macros"><link rel="prev" href="API-struct-usbdrv-wrap.html" title="struct usbdrv_wrap"><link rel="next" href="API-struct-usb-device-driver.html" title="struct usb_device_driver"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center"><span class="phrase">struct usb_driver</span></th></tr><tr><td width="20%" align="left"><a accesskey="p" href="API-struct-usbdrv-wrap.html">Prev</a> </td><th width="60%" align="center">Chapter 4. Host-Side Data Types and Macros</th><td width="20%" align="right"> <a accesskey="n" href="API-struct-usb-device-driver.html">Next</a></td></tr></table><hr></div><div class="refentry"><a name="API-struct-usb-driver"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>struct usb_driver — 2 identifies USB interface driver to usbcore 3 </p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><pre class="programlisting"> 4struct usb_driver { 5 const char * name; 6 int (* probe) (struct usb_interface *intf,const struct usb_device_id *id); 7 void (* disconnect) (struct usb_interface *intf); 8 int (* unlocked_ioctl) (struct usb_interface *intf, unsigned int code,void *buf); 9 int (* suspend) (struct usb_interface *intf, pm_message_t message); 10 int (* resume) (struct usb_interface *intf); 11 int (* reset_resume) (struct usb_interface *intf); 12 int (* pre_reset) (struct usb_interface *intf); 13 int (* post_reset) (struct usb_interface *intf); 14 const struct usb_device_id * id_table; 15 struct usb_dynids dynids; 16 struct usbdrv_wrap drvwrap; 17 unsigned int no_dynamic_id:1; 18 unsigned int supports_autosuspend:1; 19 unsigned int disable_hub_initiated_lpm:1; 20 unsigned int soft_unbind:1; 21}; </pre></div><div class="refsect1"><a name="idp1115766972"></a><h2>Members</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term">name</span></dt><dd><p> 22 The driver name should be unique among USB drivers, 23 and should normally be the same as the module name. 24 </p></dd><dt><span class="term">probe</span></dt><dd><p> 25 Called to see if the driver is willing to manage a particular 26 interface on a device. If it is, probe returns zero and uses 27 <code class="function">usb_set_intfdata</code> to associate driver-specific data with the 28 interface. It may also use <code class="function">usb_set_interface</code> to specify the 29 appropriate altsetting. If unwilling to manage the interface, 30 return -ENODEV, if genuine IO errors occurred, an appropriate 31 negative errno value. 32 </p></dd><dt><span class="term">disconnect</span></dt><dd><p> 33 Called when the interface is no longer accessible, usually 34 because its device has been (or is being) disconnected or the 35 driver module is being unloaded. 36 </p></dd><dt><span class="term">unlocked_ioctl</span></dt><dd><p> 37 Used for drivers that want to talk to userspace through 38 the <span class="quote">“<span class="quote">usbfs</span>”</span> filesystem. This lets devices provide ways to 39 expose information to user space regardless of where they 40 do (or don't) show up otherwise in the filesystem. 41 </p></dd><dt><span class="term">suspend</span></dt><dd><p> 42 Called when the device is going to be suspended by the 43 system either from system sleep or runtime suspend context. The 44 return value will be ignored in system sleep context, so do NOT 45 try to continue using the device if suspend fails in this case. 46 Instead, let the resume or reset-resume routine recover from 47 the failure. 48 </p></dd><dt><span class="term">resume</span></dt><dd><p> 49 Called when the device is being resumed by the system. 50 </p></dd><dt><span class="term">reset_resume</span></dt><dd><p> 51 Called when the suspended device has been reset instead 52 of being resumed. 53 </p></dd><dt><span class="term">pre_reset</span></dt><dd><p> 54 Called by <code class="function">usb_reset_device</code> when the device is about to be 55 reset. This routine must not return until the driver has no active 56 URBs for the device, and no more URBs may be submitted until the 57 post_reset method is called. 58 </p></dd><dt><span class="term">post_reset</span></dt><dd><p> 59 Called by <code class="function">usb_reset_device</code> after the device 60 has been reset 61 </p></dd><dt><span class="term">id_table</span></dt><dd><p> 62 USB drivers use ID table to support hotplugging. 63 Export this with MODULE_DEVICE_TABLE(usb,...). This must be set 64 or your driver's probe function will never get called. 65 </p></dd><dt><span class="term">dynids</span></dt><dd><p> 66 used internally to hold the list of dynamically added device 67 ids for this driver. 68 </p></dd><dt><span class="term">drvwrap</span></dt><dd><p> 69 Driver-model core structure wrapper. 70 </p></dd><dt><span class="term">no_dynamic_id</span></dt><dd><p> 71 if set to 1, the USB core will not allow dynamic ids to be 72 added to this driver by preventing the sysfs file from being created. 73 </p></dd><dt><span class="term">supports_autosuspend</span></dt><dd><p> 74 if set to 0, the USB core will not allow autosuspend 75 for interfaces bound to this driver. 76 </p></dd><dt><span class="term">disable_hub_initiated_lpm</span></dt><dd><p> 77 if set to 1, the USB core will not allow hubs 78 to initiate lower power link state transitions when an idle timeout 79 occurs. Device-initiated USB 3.0 link PM will still be allowed. 80 </p></dd><dt><span class="term">soft_unbind</span></dt><dd><p> 81 if set to 1, the USB core will not kill URBs and disable 82 endpoints before calling the driver's disconnect method. 83 </p></dd></dl></div></div><div class="refsect1"><a name="idp1115781924"></a><h2>Description</h2><p> 84 USB interface drivers must provide a name, <code class="function">probe</code> and <code class="function">disconnect</code> 85 methods, and an id_table. Other driver fields are optional. 86 </p><p> 87 88 The id_table is used in hotplugging. It holds a set of descriptors, 89 and specialized data may be associated with each entry. That table 90 is used by both user and kernel mode hotplugging support. 91 </p><p> 92 93 The <code class="function">probe</code> and <code class="function">disconnect</code> methods are called in a context where 94 they can sleep, but they should avoid abusing the privilege. Most 95 work to connect to a device should be done when the device is opened, 96 and undone at the last close. The disconnect code needs to address 97 concurrency issues with respect to <code class="function">open</code> and <code class="function">close</code> methods, as 98 well as forcing all pending I/O requests to complete (by unlinking 99 them as necessary, and blocking until the unlinks complete). 100</p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="API-struct-usbdrv-wrap.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="hostside.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="API-struct-usb-device-driver.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top"><span class="phrase">struct usbdrv_wrap</span> </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> <span class="phrase">struct usb_device_driver</span></td></tr></table></div></body></html> 101