Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

usb/hotplug.txt: convert to ReST and add to driver-api book

This document describe some USB core features. Add it to the
driver-api book.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>

authored by

Mauro Carvalho Chehab and committed by
Jonathan Corbet
76f650f0 360a7b5f

+37 -30
+1
Documentation/driver-api/usb/index.rst
··· 11 11 callbacks 12 12 dma 13 13 power-management 14 + hotplug 14 15 error-codes 15 16 writing_usb_driver 16 17 writing_musb_glue_layer
+36 -30
Documentation/usb/hotplug.txt Documentation/driver-api/usb/hotplug.rst
··· 1 - LINUX HOTPLUGGING 1 + USB hotplugging 2 + ~~~~~~~~~~~~~~~ 3 + 4 + Linux Hotplugging 5 + ================= 6 + 2 7 3 8 In hotpluggable busses like USB (and Cardbus PCI), end-users plug devices 4 9 into the bus with power on. In most cases, users expect the devices to become ··· 35 30 that is currently available only when the drivers are dynamically linked, 36 31 you get the best hotplugging when you configure a highly modular system. 37 32 33 + Kernel Hotplug Helper (``/sbin/hotplug``) 34 + ========================================= 38 35 39 - KERNEL HOTPLUG HELPER (/sbin/hotplug) 40 - 41 - There is a kernel parameter: /proc/sys/kernel/hotplug, which normally 42 - holds the pathname "/sbin/hotplug". That parameter names a program 36 + There is a kernel parameter: ``/proc/sys/kernel/hotplug``, which normally 37 + holds the pathname ``/sbin/hotplug``. That parameter names a program 43 38 which the kernel may invoke at various times. 44 39 45 40 The /sbin/hotplug program can be invoked by any subsystem as part of its ··· 56 51 Mailing list information is also available at that site. 57 52 58 53 59 - -------------------------------------------------------------------------- 54 + USB Policy Agent 55 + ================ 60 56 61 - 62 - USB POLICY AGENT 63 - 64 - The USB subsystem currently invokes /sbin/hotplug when USB devices 57 + The USB subsystem currently invokes ``/sbin/hotplug`` when USB devices 65 58 are added or removed from system. The invocation is done by the kernel 66 59 hub workqueue [hub_wq], or else as part of root hub initialization 67 60 (done by init, modprobe, kapmd, etc). Its single command line parameter 68 61 is the string "usb", and it passes these environment variables: 69 62 70 - ACTION ... "add", "remove" 71 - PRODUCT ... USB vendor, product, and version codes (hex) 72 - TYPE ... device class codes (decimal) 73 - INTERFACE ... interface 0 class codes (decimal) 63 + ========== ============================================ 64 + ACTION ``add``, ``remove`` 65 + PRODUCT USB vendor, product, and version codes (hex) 66 + TYPE device class codes (decimal) 67 + INTERFACE interface 0 class codes (decimal) 68 + ========== ============================================ 74 69 75 70 If "usbdevfs" is configured, DEVICE and DEVFS are also passed. DEVICE is 76 71 the pathname of the device, and is useful for devices with multiple and/or 77 72 alternate interfaces that complicate driver selection. By design, USB 78 - hotplugging is independent of "usbdevfs": you can do most essential parts 73 + hotplugging is independent of ``usbdevfs``: you can do most essential parts 79 74 of USB device setup without using that filesystem, and without running a 80 75 user mode daemon to detect changes in system configuration. 81 76 ··· 84 79 leverage USB module-init-tools support. Later agents might unload drivers. 85 80 86 81 87 - USB MODUTILS SUPPORT 82 + USB Modutils Support 83 + ==================== 88 84 89 - Current versions of module-init-tools will create a "modules.usbmap" file 90 - which contains the entries from each driver's MODULE_DEVICE_TABLE. Such 85 + Current versions of module-init-tools will create a ``modules.usbmap`` file 86 + which contains the entries from each driver's ``MODULE_DEVICE_TABLE``. Such 91 87 files can be used by various user mode policy agents to make sure all the 92 88 right driver modules get loaded, either at boot time or later. 93 89 94 - See <linux/usb.h> for full information about such table entries; or look 90 + See ``linux/usb.h`` for full information about such table entries; or look 95 91 at existing drivers. Each table entry describes one or more criteria to 96 92 be used when matching a driver to a device or class of devices. The 97 93 specific criteria are identified by bits set in "match_flags", paired 98 94 with field values. You can construct the criteria directly, or with 99 - macros such as these, and use driver_info to store more information. 95 + macros such as these, and use driver_info to store more information:: 100 96 101 97 USB_DEVICE (vendorId, productId) 102 98 ... matching devices with specified vendor and product ids ··· 109 103 ... matching specified device class info 110 104 111 105 A short example, for a driver that supports several specific USB devices 112 - and their quirks, might have a MODULE_DEVICE_TABLE like this: 106 + and their quirks, might have a MODULE_DEVICE_TABLE like this:: 113 107 114 108 static const struct usb_device_id mydriver_id_table[] = { 115 109 { USB_DEVICE (0x9999, 0xaaaa), driver_info: QUIRK_X }, ··· 122 116 Most USB device drivers should pass these tables to the USB subsystem as 123 117 well as to the module management subsystem. Not all, though: some driver 124 118 frameworks connect using interfaces layered over USB, and so they won't 125 - need such a "struct usb_driver". 119 + need such a struct :c:type:`usb_driver`. 126 120 127 121 Drivers that connect directly to the USB subsystem should be declared 128 - something like this: 122 + something like this:: 129 123 130 124 static struct usb_driver mydriver = { 131 125 .name = "mydriver", ··· 144 138 145 139 When the USB subsystem knows about a driver's device ID table, it's used when 146 140 choosing drivers to probe(). The thread doing new device processing checks 147 - drivers' device ID entries from the MODULE_DEVICE_TABLE against interface and 148 - device descriptors for the device. It will only call probe() if there is a 149 - match, and the third argument to probe() will be the entry that matched. 141 + drivers' device ID entries from the ``MODULE_DEVICE_TABLE`` against interface 142 + and device descriptors for the device. It will only call ``probe()`` if there 143 + is a match, and the third argument to ``probe()`` will be the entry that 144 + matched. 150 145 151 - If you don't provide an id_table for your driver, then your driver may get 152 - probed for each new device; the third parameter to probe() will be null. 153 - 154 - 146 + If you don't provide an ``id_table`` for your driver, then your driver may get 147 + probed for each new device; the third parameter to ``probe()`` will be 148 + ``NULL``.