Commit 41631d36 authored by Ahmed S. Darwish's avatar Ahmed S. Darwish Committed by Greg Kroah-Hartman
Browse files

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: default avatarAhmed S. Darwish <a.darwish@linutronix.de>
Signed-off-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Acked-by: default avatarAlan Stern <stern@rowland.harvard.edu>
Cc: linux-usb@vger.kernel.org
Link: https://lore.kernel.org/r/20201019101110.851821025@linutronix.de


Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent cce86615
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -51,7 +51,8 @@ void __init usb_init_pool_max(void)
/**
 * hcd_buffer_create - initialize buffer pools
 * @hcd: the bus whose buffer pools are to be initialized
 * Context: !in_interrupt()
 *
 * Context: task context, might sleep
 *
 * Call this as part of initializing a host controller that uses the dma
 * memory allocators.  It initializes some pools of dma-coherent memory that
@@ -88,7 +89,8 @@ int hcd_buffer_create(struct usb_hcd *hcd)
/**
 * hcd_buffer_destroy - deallocate buffer pools
 * @hcd: the bus whose buffer pools are to be destroyed
 * Context: !in_interrupt()
 *
 * Context: task context, might sleep
 *
 * This frees the buffer pools created by hcd_buffer_create().
 */
+4 −2
Original line number Diff line number Diff line
@@ -160,7 +160,8 @@ static void ehci_wait_for_companions(struct pci_dev *pdev, struct usb_hcd *hcd,
 * @dev: USB Host Controller being probed
 * @id: pci hotplug id connecting controller to HCD framework
 * @driver: USB HC driver handle
 * Context: !in_interrupt()
 *
 * Context: task context, might sleep
 *
 * Allocates basic PCI resources for this USB host controller, and
 * then invokes the start() method for the HCD associated with it
@@ -304,7 +305,8 @@ EXPORT_SYMBOL_GPL(usb_hcd_pci_probe);
/**
 * usb_hcd_pci_remove - shutdown processing for PCI-based HCDs
 * @dev: USB Host Controller being removed
 * Context: !in_interrupt()
 *
 * Context: task context, might sleep
 *
 * Reverses the effect of usb_hcd_pci_probe(), first invoking
 * the HCD's stop() method.  It is always called from a thread
+17 −9
Original line number Diff line number Diff line
@@ -747,8 +747,7 @@ static int rh_call_control (struct usb_hcd *hcd, struct urb *urb)
 * driver requests it; otherwise the driver is responsible for
 * calling usb_hcd_poll_rh_status() when an event occurs.
 *
 * Completions are called in_interrupt(), but they may or may not
 * be in_irq().
 * Completion handler may not sleep. See usb_hcd_giveback_urb() for details.
 */
void usb_hcd_poll_rh_status(struct usb_hcd *hcd)
{
@@ -904,7 +903,8 @@ static void usb_bus_init (struct usb_bus *bus)
/**
 * usb_register_bus - registers the USB host controller with the usb core
 * @bus: pointer to the bus to register
 * Context: !in_interrupt()
 *
 * Context: task context, might sleep.
 *
 * Assigns a bus number, and links the controller into usbcore data
 * structures so that it can be seen by scanning the bus list.
@@ -939,7 +939,8 @@ static int usb_register_bus(struct usb_bus *bus)
/**
 * usb_deregister_bus - deregisters the USB host controller
 * @bus: pointer to the bus to deregister
 * Context: !in_interrupt()
 *
 * Context: task context, might sleep.
 *
 * Recycles the bus number, and unlinks the controller from usbcore data
 * structures so that it won't be seen by scanning the bus list.
@@ -1691,7 +1692,11 @@ static void usb_giveback_urb_bh(struct tasklet_struct *t)
 * @hcd: host controller returning the URB
 * @urb: urb being returned to the USB device driver.
 * @status: completion status code for the URB.
 * Context: in_interrupt()
 *
 * Context: atomic. The completion callback is invoked in caller's context.
 * For HCDs with HCD_BH flag set, the completion callback is invoked in tasklet
 * context (except for URBs submitted to the root hub which always complete in
 * caller's context).
 *
 * This hands the URB from HCD to its USB device driver, using its
 * completion function.  The HCD has freed all per-urb resources
@@ -2268,7 +2273,7 @@ EXPORT_SYMBOL_GPL(usb_hcd_resume_root_hub);
 * usb_bus_start_enum - start immediate enumeration (for OTG)
 * @bus: the bus (must use hcd framework)
 * @port_num: 1-based number of port; usually bus->otg_port
 * Context: in_interrupt()
 * Context: atomic
 *
 * Starts enumeration, with an immediate reset followed later by
 * hub_wq identifying and possibly configuring the device.
@@ -2474,7 +2479,8 @@ EXPORT_SYMBOL_GPL(__usb_create_hcd);
 * @bus_name: value to store in hcd->self.bus_name
 * @primary_hcd: a pointer to the usb_hcd structure that is sharing the
 *              PCI device.  Only allocate certain resources for the primary HCD
 * Context: !in_interrupt()
 *
 * Context: task context, might sleep.
 *
 * Allocate a struct usb_hcd, with extra space at the end for the
 * HC driver's private data.  Initialize the generic members of the
@@ -2496,7 +2502,8 @@ EXPORT_SYMBOL_GPL(usb_create_shared_hcd);
 * @driver: HC driver that will use this hcd
 * @dev: device for this HC, stored in hcd->self.controller
 * @bus_name: value to store in hcd->self.bus_name
 * Context: !in_interrupt()
 *
 * Context: task context, might sleep.
 *
 * Allocate a struct usb_hcd, with extra space at the end for the
 * HC driver's private data.  Initialize the generic members of the
@@ -2830,7 +2837,8 @@ EXPORT_SYMBOL_GPL(usb_add_hcd);
/**
 * usb_remove_hcd - shutdown processing for generic HCDs
 * @hcd: the usb_hcd structure to remove
 * Context: !in_interrupt()
 *
 * Context: task context, might sleep.
 *
 * Disconnects the root hub, then reverses the effects of usb_add_hcd(),
 * invoking the HCD's stop() method.
+2 −1
Original line number Diff line number Diff line
@@ -2171,7 +2171,8 @@ static void hub_disconnect_children(struct usb_device *udev)
/**
 * usb_disconnect - disconnect a device (usbcore-internal)
 * @pdev: pointer to device being disconnected
 * Context: !in_interrupt ()
 *
 * Context: task context, might sleep
 *
 * Something got disconnected. Get rid of it and all of its children.
 *
+22 −13
Original line number Diff line number Diff line
@@ -119,7 +119,7 @@ static int usb_internal_control_msg(struct usb_device *usb_dev,
 * @timeout: time in msecs to wait for the message to complete before timing
 *	out (if 0 the wait is forever)
 *
 * Context: !in_interrupt ()
 * Context: task context, might sleep.
 *
 * This function sends a simple control message to a specified endpoint and
 * waits for the message to complete, or timeout.
@@ -310,7 +310,7 @@ EXPORT_SYMBOL_GPL(usb_control_msg_recv);
 * @timeout: time in msecs to wait for the message to complete before
 *	timing out (if 0 the wait is forever)
 *
 * Context: !in_interrupt ()
 * Context: task context, might sleep.
 *
 * This function sends a simple interrupt message to a specified endpoint and
 * waits for the message to complete, or timeout.
@@ -343,7 +343,7 @@ EXPORT_SYMBOL_GPL(usb_interrupt_msg);
 * @timeout: time in msecs to wait for the message to complete before
 *	timing out (if 0 the wait is forever)
 *
 * Context: !in_interrupt ()
 * Context: task context, might sleep.
 *
 * This function sends a simple bulk message to a specified endpoint
 * and waits for the message to complete, or timeout.
@@ -610,7 +610,8 @@ EXPORT_SYMBOL_GPL(usb_sg_init);
 * usb_sg_wait - synchronously execute scatter/gather request
 * @io: request block handle, as initialized with usb_sg_init().
 * 	some fields become accessible when this call returns.
 * Context: !in_interrupt ()
 *
 * Context: task context, might sleep.
 *
 * This function blocks until the specified I/O operation completes.  It
 * leverages the grouping of the related I/O requests to get good transfer
@@ -764,7 +765,8 @@ EXPORT_SYMBOL_GPL(usb_sg_cancel);
 * @index: the number of the descriptor
 * @buf: where to put the descriptor
 * @size: how big is "buf"?
 * Context: !in_interrupt ()
 *
 * Context: task context, might sleep.
 *
 * Gets a USB descriptor.  Convenience functions exist to simplify
 * getting some types of descriptors.  Use
@@ -812,7 +814,8 @@ EXPORT_SYMBOL_GPL(usb_get_descriptor);
 * @index: the number of the descriptor
 * @buf: where to put the string
 * @size: how big is "buf"?
 * Context: !in_interrupt ()
 *
 * Context: task context, might sleep.
 *
 * Retrieves a string, encoded using UTF-16LE (Unicode, 16 bits per character,
 * in little-endian byte order).
@@ -947,7 +950,8 @@ static int usb_get_langid(struct usb_device *dev, unsigned char *tbuf)
 * @index: the number of the descriptor
 * @buf: where to put the string
 * @size: how big is "buf"?
 * Context: !in_interrupt ()
 *
 * Context: task context, might sleep.
 *
 * This converts the UTF-16LE encoded strings returned by devices, from
 * usb_get_string_descriptor(), to null-terminated UTF-8 encoded ones
@@ -1036,7 +1040,8 @@ char *usb_cache_string(struct usb_device *udev, int index)
 * usb_get_device_descriptor - (re)reads the device descriptor (usbcore)
 * @dev: the device whose device descriptor is being updated
 * @size: how much of the descriptor to read
 * Context: !in_interrupt ()
 *
 * Context: task context, might sleep.
 *
 * Updates the copy of the device descriptor stored in the device structure,
 * which dedicates space for this purpose.
@@ -1071,7 +1076,7 @@ int usb_get_device_descriptor(struct usb_device *dev, unsigned int size)
/*
 * usb_set_isoch_delay - informs the device of the packet transmit delay
 * @dev: the device whose delay is to be informed
 * Context: !in_interrupt()
 * Context: task context, might sleep
 *
 * Since this is an optional request, we don't bother if it fails.
 */
@@ -1100,7 +1105,8 @@ int usb_set_isoch_delay(struct usb_device *dev)
 * @type: USB_STATUS_TYPE_*; for standard or PTM status types
 * @target: zero (for device), else interface or endpoint number
 * @data: pointer to two bytes of bitmap data
 * Context: !in_interrupt ()
 *
 * Context: task context, might sleep.
 *
 * Returns device, interface, or endpoint status.  Normally only of
 * interest to see if the device is self powered, or has enabled the
@@ -1177,7 +1183,8 @@ EXPORT_SYMBOL_GPL(usb_get_status);
 * usb_clear_halt - tells device to clear endpoint halt/stall condition
 * @dev: device whose endpoint is halted
 * @pipe: endpoint "pipe" being cleared
 * Context: !in_interrupt ()
 *
 * Context: task context, might sleep.
 *
 * This is used to clear halt conditions for bulk and interrupt endpoints,
 * as reported by URB completion status.  Endpoints that are halted are
@@ -1481,7 +1488,8 @@ void usb_enable_interface(struct usb_device *dev,
 * @dev: the device whose interface is being updated
 * @interface: the interface being updated
 * @alternate: the setting being chosen.
 * Context: !in_interrupt ()
 *
 * Context: task context, might sleep.
 *
 * This is used to enable data transfers on interfaces that may not
 * be enabled by default.  Not all devices support such configurability.
@@ -1902,7 +1910,8 @@ static void __usb_queue_reset_device(struct work_struct *ws)
 * usb_set_configuration - Makes a particular device setting be current
 * @dev: the device whose configuration is being updated
 * @configuration: the configuration being chosen.
 * Context: !in_interrupt(), caller owns the device lock
 *
 * Context: task context, might sleep. Caller holds device lock.
 *
 * This is used to enable non-default device modes.  Not all devices
 * use this kind of configurability; many devices only have one
Loading