drivers/usb/musb/musb_core.c
Source file repositories/reference/linux-study-clean/drivers/usb/musb/musb_core.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/usb/musb/musb_core.c- Extension
.c- Size
- 80247 bytes
- Lines
- 2956
- Domain
- Driver Families
- Bucket
- drivers/usb
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/kernel.hlinux/sched.hlinux/slab.hlinux/list.hlinux/kobject.hlinux/prefetch.hlinux/platform_device.hlinux/string_choices.hlinux/io.hlinux/iopoll.hlinux/dma-mapping.hlinux/usb.hlinux/usb/of.hmusb_core.hmusb_trace.h
Detected Declarations
struct musb_pending_workfunction musb_get_modefunction musb_ulpi_readfunction musb_ulpi_writefunction musb_default_fifo_offsetfunction musb_flat_ep_selectfunction musb_indexed_ep_selectfunction musb_indexed_ep_offsetfunction musb_default_busctl_offsetfunction musb_default_readbfunction musb_default_writebfunction musb_default_readwfunction musb_default_writewfunction musb_default_get_togglefunction musb_default_set_togglefunction musb_default_write_fifofunction musb_default_read_fifofunction musb_readlfunction musb_writelfunction musb_read_fifofunction musb_write_fifofunction musb_read_devctlfunction musb_set_hostfunction musb_set_peripheralfunction musb_load_testpacketfunction musb_otg_timer_funcfunction musb_hnp_stopfunction musb_handle_intr_resumefunction musb_handle_intr_sessreqfunction musb_handle_intr_vbuserrfunction duefunction musb_handle_intr_suspendfunction musb_handle_intr_connectfunction musb_handle_intr_disconnectfunction musb_handle_intr_resetfunction musb_stage0_irqfunction wrapsfunction musb_disable_interruptsfunction musb_enable_interruptsfunction startfunction musb_get_statefunction musb_stopfunction fifo_setupfunction ep_config_from_tablefunction ep_config_from_hwfunction musb_core_initfunction sourcesfunction for_each_set_bit
Annotated Snippet
struct musb_pending_work {
int (*callback)(struct musb *musb, void *data);
void *data;
struct list_head node;
};
#ifdef CONFIG_PM
/*
* Called from musb_runtime_resume(), musb_resume(), and
* musb_queue_resume_work(). Callers must take musb->lock.
*/
static int musb_run_resume_work(struct musb *musb)
{
struct musb_pending_work *w, *_w;
unsigned long flags;
int error = 0;
spin_lock_irqsave(&musb->list_lock, flags);
list_for_each_entry_safe(w, _w, &musb->pending_list, node) {
if (w->callback) {
error = w->callback(musb, w->data);
if (error < 0) {
dev_err(musb->controller,
"resume callback %p failed: %i\n",
w->callback, error);
}
}
list_del(&w->node);
devm_kfree(musb->controller, w);
}
spin_unlock_irqrestore(&musb->list_lock, flags);
return error;
}
#endif
/*
* Called to run work if device is active or else queue the work to happen
* on resume. Caller must take musb->lock and must hold an RPM reference.
*
* Note that we cowardly refuse queuing work after musb PM runtime
* resume is done calling musb_run_resume_work() and return -EINPROGRESS
* instead.
*/
int musb_queue_resume_work(struct musb *musb,
int (*callback)(struct musb *musb, void *data),
void *data)
{
struct musb_pending_work *w;
unsigned long flags;
bool is_suspended;
int error;
if (WARN_ON(!callback))
return -EINVAL;
spin_lock_irqsave(&musb->list_lock, flags);
is_suspended = musb->is_runtime_suspended;
if (is_suspended) {
w = devm_kzalloc(musb->controller, sizeof(*w), GFP_ATOMIC);
if (!w) {
error = -ENOMEM;
goto out_unlock;
}
w->callback = callback;
w->data = data;
list_add_tail(&w->node, &musb->pending_list);
error = 0;
}
out_unlock:
spin_unlock_irqrestore(&musb->list_lock, flags);
if (!is_suspended)
error = callback(musb, data);
return error;
}
EXPORT_SYMBOL_GPL(musb_queue_resume_work);
static void musb_deassert_reset(struct work_struct *work)
{
struct musb *musb;
unsigned long flags;
musb = container_of(work, struct musb, deassert_reset_work.work);
Annotation
- Immediate include surface: `linux/module.h`, `linux/kernel.h`, `linux/sched.h`, `linux/slab.h`, `linux/list.h`, `linux/kobject.h`, `linux/prefetch.h`, `linux/platform_device.h`.
- Detected declarations: `struct musb_pending_work`, `function musb_get_mode`, `function musb_ulpi_read`, `function musb_ulpi_write`, `function musb_default_fifo_offset`, `function musb_flat_ep_select`, `function musb_indexed_ep_select`, `function musb_indexed_ep_offset`, `function musb_default_busctl_offset`, `function musb_default_readb`.
- Atlas domain: Driver Families / drivers/usb.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.