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

usb: core: Replace in_interrupt() in comments

The usage of in_interrupt() in drivers is phased out for various reasons.

Various comments use !in_interrupt() to describe calling context for
functions which might sleep. That's wrong because the calling context has
to be preemptible task context, which is not what !in_interrupt()
describes.

Replace !in_interrupt() with more accurate plain text descriptions.

The comment for usb_hcd_poll_rh_status() is misleading as this function is
called from all kinds of contexts including preemptible task
context. Remove it as there is obviously no restriction.

Signed-off-by: Ahmed S. Darwish <a.darwish@linutronix.de>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Cc: linux-usb@vger.kernel.org
Link: https://lore.kernel.org/r/20201019101110.851821025@linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Ahmed S. Darwish and committed by
Greg Kroah-Hartman
41631d36 cce86615

+51 -29
+4 -2
drivers/usb/core/buffer.c
··· 51 51 /** 52 52 * hcd_buffer_create - initialize buffer pools 53 53 * @hcd: the bus whose buffer pools are to be initialized 54 - * Context: !in_interrupt() 54 + * 55 + * Context: task context, might sleep 55 56 * 56 57 * Call this as part of initializing a host controller that uses the dma 57 58 * memory allocators. It initializes some pools of dma-coherent memory that ··· 89 88 /** 90 89 * hcd_buffer_destroy - deallocate buffer pools 91 90 * @hcd: the bus whose buffer pools are to be destroyed 92 - * Context: !in_interrupt() 91 + * 92 + * Context: task context, might sleep 93 93 * 94 94 * This frees the buffer pools created by hcd_buffer_create(). 95 95 */
+4 -2
drivers/usb/core/hcd-pci.c
··· 160 160 * @dev: USB Host Controller being probed 161 161 * @id: pci hotplug id connecting controller to HCD framework 162 162 * @driver: USB HC driver handle 163 - * Context: !in_interrupt() 163 + * 164 + * Context: task context, might sleep 164 165 * 165 166 * Allocates basic PCI resources for this USB host controller, and 166 167 * then invokes the start() method for the HCD associated with it ··· 305 304 /** 306 305 * usb_hcd_pci_remove - shutdown processing for PCI-based HCDs 307 306 * @dev: USB Host Controller being removed 308 - * Context: !in_interrupt() 307 + * 308 + * Context: task context, might sleep 309 309 * 310 310 * Reverses the effect of usb_hcd_pci_probe(), first invoking 311 311 * the HCD's stop() method. It is always called from a thread
+17 -9
drivers/usb/core/hcd.c
··· 747 747 * driver requests it; otherwise the driver is responsible for 748 748 * calling usb_hcd_poll_rh_status() when an event occurs. 749 749 * 750 - * Completions are called in_interrupt(), but they may or may not 751 - * be in_irq(). 750 + * Completion handler may not sleep. See usb_hcd_giveback_urb() for details. 752 751 */ 753 752 void usb_hcd_poll_rh_status(struct usb_hcd *hcd) 754 753 { ··· 903 904 /** 904 905 * usb_register_bus - registers the USB host controller with the usb core 905 906 * @bus: pointer to the bus to register 906 - * Context: !in_interrupt() 907 + * 908 + * Context: task context, might sleep. 907 909 * 908 910 * Assigns a bus number, and links the controller into usbcore data 909 911 * structures so that it can be seen by scanning the bus list. ··· 939 939 /** 940 940 * usb_deregister_bus - deregisters the USB host controller 941 941 * @bus: pointer to the bus to deregister 942 - * Context: !in_interrupt() 942 + * 943 + * Context: task context, might sleep. 943 944 * 944 945 * Recycles the bus number, and unlinks the controller from usbcore data 945 946 * structures so that it won't be seen by scanning the bus list. ··· 1692 1691 * @hcd: host controller returning the URB 1693 1692 * @urb: urb being returned to the USB device driver. 1694 1693 * @status: completion status code for the URB. 1695 - * Context: in_interrupt() 1694 + * 1695 + * Context: atomic. The completion callback is invoked in caller's context. 1696 + * For HCDs with HCD_BH flag set, the completion callback is invoked in tasklet 1697 + * context (except for URBs submitted to the root hub which always complete in 1698 + * caller's context). 1696 1699 * 1697 1700 * This hands the URB from HCD to its USB device driver, using its 1698 1701 * completion function. The HCD has freed all per-urb resources ··· 2273 2268 * usb_bus_start_enum - start immediate enumeration (for OTG) 2274 2269 * @bus: the bus (must use hcd framework) 2275 2270 * @port_num: 1-based number of port; usually bus->otg_port 2276 - * Context: in_interrupt() 2271 + * Context: atomic 2277 2272 * 2278 2273 * Starts enumeration, with an immediate reset followed later by 2279 2274 * hub_wq identifying and possibly configuring the device. ··· 2479 2474 * @bus_name: value to store in hcd->self.bus_name 2480 2475 * @primary_hcd: a pointer to the usb_hcd structure that is sharing the 2481 2476 * PCI device. Only allocate certain resources for the primary HCD 2482 - * Context: !in_interrupt() 2477 + * 2478 + * Context: task context, might sleep. 2483 2479 * 2484 2480 * Allocate a struct usb_hcd, with extra space at the end for the 2485 2481 * HC driver's private data. Initialize the generic members of the ··· 2502 2496 * @driver: HC driver that will use this hcd 2503 2497 * @dev: device for this HC, stored in hcd->self.controller 2504 2498 * @bus_name: value to store in hcd->self.bus_name 2505 - * Context: !in_interrupt() 2499 + * 2500 + * Context: task context, might sleep. 2506 2501 * 2507 2502 * Allocate a struct usb_hcd, with extra space at the end for the 2508 2503 * HC driver's private data. Initialize the generic members of the ··· 2837 2830 /** 2838 2831 * usb_remove_hcd - shutdown processing for generic HCDs 2839 2832 * @hcd: the usb_hcd structure to remove 2840 - * Context: !in_interrupt() 2833 + * 2834 + * Context: task context, might sleep. 2841 2835 * 2842 2836 * Disconnects the root hub, then reverses the effects of usb_add_hcd(), 2843 2837 * invoking the HCD's stop() method.
+2 -1
drivers/usb/core/hub.c
··· 2171 2171 /** 2172 2172 * usb_disconnect - disconnect a device (usbcore-internal) 2173 2173 * @pdev: pointer to device being disconnected 2174 - * Context: !in_interrupt () 2174 + * 2175 + * Context: task context, might sleep 2175 2176 * 2176 2177 * Something got disconnected. Get rid of it and all of its children. 2177 2178 *
+22 -13
drivers/usb/core/message.c
··· 119 119 * @timeout: time in msecs to wait for the message to complete before timing 120 120 * out (if 0 the wait is forever) 121 121 * 122 - * Context: !in_interrupt () 122 + * Context: task context, might sleep. 123 123 * 124 124 * This function sends a simple control message to a specified endpoint and 125 125 * waits for the message to complete, or timeout. ··· 310 310 * @timeout: time in msecs to wait for the message to complete before 311 311 * timing out (if 0 the wait is forever) 312 312 * 313 - * Context: !in_interrupt () 313 + * Context: task context, might sleep. 314 314 * 315 315 * This function sends a simple interrupt message to a specified endpoint and 316 316 * waits for the message to complete, or timeout. ··· 343 343 * @timeout: time in msecs to wait for the message to complete before 344 344 * timing out (if 0 the wait is forever) 345 345 * 346 - * Context: !in_interrupt () 346 + * Context: task context, might sleep. 347 347 * 348 348 * This function sends a simple bulk message to a specified endpoint 349 349 * and waits for the message to complete, or timeout. ··· 610 610 * usb_sg_wait - synchronously execute scatter/gather request 611 611 * @io: request block handle, as initialized with usb_sg_init(). 612 612 * some fields become accessible when this call returns. 613 - * Context: !in_interrupt () 613 + * 614 + * Context: task context, might sleep. 614 615 * 615 616 * This function blocks until the specified I/O operation completes. It 616 617 * leverages the grouping of the related I/O requests to get good transfer ··· 765 764 * @index: the number of the descriptor 766 765 * @buf: where to put the descriptor 767 766 * @size: how big is "buf"? 768 - * Context: !in_interrupt () 767 + * 768 + * Context: task context, might sleep. 769 769 * 770 770 * Gets a USB descriptor. Convenience functions exist to simplify 771 771 * getting some types of descriptors. Use ··· 814 812 * @index: the number of the descriptor 815 813 * @buf: where to put the string 816 814 * @size: how big is "buf"? 817 - * Context: !in_interrupt () 815 + * 816 + * Context: task context, might sleep. 818 817 * 819 818 * Retrieves a string, encoded using UTF-16LE (Unicode, 16 bits per character, 820 819 * in little-endian byte order). ··· 950 947 * @index: the number of the descriptor 951 948 * @buf: where to put the string 952 949 * @size: how big is "buf"? 953 - * Context: !in_interrupt () 950 + * 951 + * Context: task context, might sleep. 954 952 * 955 953 * This converts the UTF-16LE encoded strings returned by devices, from 956 954 * usb_get_string_descriptor(), to null-terminated UTF-8 encoded ones ··· 1040 1036 * usb_get_device_descriptor - (re)reads the device descriptor (usbcore) 1041 1037 * @dev: the device whose device descriptor is being updated 1042 1038 * @size: how much of the descriptor to read 1043 - * Context: !in_interrupt () 1039 + * 1040 + * Context: task context, might sleep. 1044 1041 * 1045 1042 * Updates the copy of the device descriptor stored in the device structure, 1046 1043 * which dedicates space for this purpose. ··· 1076 1071 /* 1077 1072 * usb_set_isoch_delay - informs the device of the packet transmit delay 1078 1073 * @dev: the device whose delay is to be informed 1079 - * Context: !in_interrupt() 1074 + * Context: task context, might sleep 1080 1075 * 1081 1076 * Since this is an optional request, we don't bother if it fails. 1082 1077 */ ··· 1105 1100 * @type: USB_STATUS_TYPE_*; for standard or PTM status types 1106 1101 * @target: zero (for device), else interface or endpoint number 1107 1102 * @data: pointer to two bytes of bitmap data 1108 - * Context: !in_interrupt () 1103 + * 1104 + * Context: task context, might sleep. 1109 1105 * 1110 1106 * Returns device, interface, or endpoint status. Normally only of 1111 1107 * interest to see if the device is self powered, or has enabled the ··· 1183 1177 * usb_clear_halt - tells device to clear endpoint halt/stall condition 1184 1178 * @dev: device whose endpoint is halted 1185 1179 * @pipe: endpoint "pipe" being cleared 1186 - * Context: !in_interrupt () 1180 + * 1181 + * Context: task context, might sleep. 1187 1182 * 1188 1183 * This is used to clear halt conditions for bulk and interrupt endpoints, 1189 1184 * as reported by URB completion status. Endpoints that are halted are ··· 1488 1481 * @dev: the device whose interface is being updated 1489 1482 * @interface: the interface being updated 1490 1483 * @alternate: the setting being chosen. 1491 - * Context: !in_interrupt () 1484 + * 1485 + * Context: task context, might sleep. 1492 1486 * 1493 1487 * This is used to enable data transfers on interfaces that may not 1494 1488 * be enabled by default. Not all devices support such configurability. ··· 1910 1902 * usb_set_configuration - Makes a particular device setting be current 1911 1903 * @dev: the device whose configuration is being updated 1912 1904 * @configuration: the configuration being chosen. 1913 - * Context: !in_interrupt(), caller owns the device lock 1905 + * 1906 + * Context: task context, might sleep. Caller holds device lock. 1914 1907 * 1915 1908 * This is used to enable non-default device modes. Not all devices 1916 1909 * use this kind of configurability; many devices only have one
+2 -2
drivers/usb/core/usb.c
··· 28 28 #include <linux/string.h> 29 29 #include <linux/bitops.h> 30 30 #include <linux/slab.h> 31 - #include <linux/interrupt.h> /* for in_interrupt() */ 32 31 #include <linux/kmod.h> 33 32 #include <linux/init.h> 34 33 #include <linux/spinlock.h> ··· 560 561 * @parent: hub to which device is connected; null to allocate a root hub 561 562 * @bus: bus used to access the device 562 563 * @port1: one-based index of port; ignored for root hubs 563 - * Context: !in_interrupt() 564 + * 565 + * Context: task context, might sleep. 564 566 * 565 567 * Only hub drivers (including virtual root hub drivers for host 566 568 * controllers) should ever call this.