drivers/usb/mtu3/mtu3_gadget.c
Source file repositories/reference/linux-study-clean/drivers/usb/mtu3/mtu3_gadget.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/usb/mtu3/mtu3_gadget.c- Extension
.c- Size
- 18228 bytes
- Lines
- 773
- Domain
- Driver Families
- Bucket
- drivers/usb
- Inferred role
- Driver Families: implementation source
- Status
- source 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/string_choices.hmtu3.hmtu3_trace.h
Detected Declarations
function Copyrightfunction nukefunction mtu3_ep_enablefunction mtu3_ep_disablefunction mtu3_gadget_ep_enablefunction mtu3_gadget_ep_disablefunction mtu3_free_requestfunction mtu3_gadget_queuefunction mtu3_gadget_dequeuefunction list_for_each_entryfunction mtu3_gadget_ep_set_haltfunction mtu3_gadget_ep_set_wedgefunction mtu3_gadget_get_framefunction function_wake_notiffunction mtu3_gadget_wakeupfunction mtu3_gadget_set_self_poweredfunction mtu3_gadget_pullupfunction mtu3_gadget_startfunction stop_activityfunction mtu3_gadget_stopfunction mtu3_gadget_set_speedfunction mtu3_gadget_async_callbacksfunction mtu3_state_resetfunction init_hw_epfunction mtu3_gadget_init_epsfunction mtu3_gadget_setupfunction mtu3_gadget_cleanupfunction mtu3_gadget_resumefunction mtu3_gadget_suspendfunction mtu3_gadget_disconnectfunction mtu3_gadget_reset
Annotated Snippet
usb_endpoint_xfer_isoc(desc)) {
interval = desc->bInterval;
interval = clamp_val(interval, 1, 16);
if (usb_endpoint_xfer_isoc(desc) && comp_desc)
mult = comp_desc->bmAttributes;
}
if (comp_desc)
burst = comp_desc->bMaxBurst;
break;
case USB_SPEED_HIGH:
if (usb_endpoint_xfer_isoc(desc) ||
usb_endpoint_xfer_int(desc)) {
interval = desc->bInterval;
interval = clamp_val(interval, 1, 16);
mult = usb_endpoint_maxp_mult(desc) - 1;
}
break;
case USB_SPEED_FULL:
if (usb_endpoint_xfer_isoc(desc))
interval = clamp_val(desc->bInterval, 1, 16);
else if (usb_endpoint_xfer_int(desc))
interval = clamp_val(desc->bInterval, 1, 255);
break;
default:
break; /*others are ignored */
}
dev_dbg(mtu->dev, "%s maxp:%d, interval:%d, burst:%d, mult:%d\n",
__func__, mep->maxp, interval, burst, mult);
mep->ep.maxpacket = mep->maxp;
mep->ep.desc = desc;
mep->ep.comp_desc = comp_desc;
/* slot mainly affects bulk/isoc transfer, so ignore int */
mep->slot = usb_endpoint_xfer_int(desc) ? 0 : mtu->slot;
ret = mtu3_config_ep(mtu, mep, interval, burst, mult);
if (ret < 0)
return ret;
ret = mtu3_gpd_ring_alloc(mep);
if (ret < 0) {
mtu3_deconfig_ep(mtu, mep);
return ret;
}
mtu3_qmu_start(mep);
return 0;
}
static int mtu3_ep_disable(struct mtu3_ep *mep)
{
struct mtu3 *mtu = mep->mtu;
/* abort all pending requests */
nuke(mep, -ESHUTDOWN);
mtu3_qmu_stop(mep);
mtu3_deconfig_ep(mtu, mep);
mtu3_gpd_ring_free(mep);
mep->desc = NULL;
mep->ep.desc = NULL;
mep->comp_desc = NULL;
mep->type = 0;
mep->flags = 0;
return 0;
}
static int mtu3_gadget_ep_enable(struct usb_ep *ep,
const struct usb_endpoint_descriptor *desc)
{
struct mtu3_ep *mep;
struct mtu3 *mtu;
unsigned long flags;
int ret = -EINVAL;
if (!ep || !desc || desc->bDescriptorType != USB_DT_ENDPOINT) {
pr_debug("%s invalid parameters\n", __func__);
return -EINVAL;
}
if (!desc->wMaxPacketSize) {
pr_debug("%s missing wMaxPacketSize\n", __func__);
return -EINVAL;
}
Annotation
- Immediate include surface: `linux/string_choices.h`, `mtu3.h`, `mtu3_trace.h`.
- Detected declarations: `function Copyright`, `function nuke`, `function mtu3_ep_enable`, `function mtu3_ep_disable`, `function mtu3_gadget_ep_enable`, `function mtu3_gadget_ep_disable`, `function mtu3_free_request`, `function mtu3_gadget_queue`, `function mtu3_gadget_dequeue`, `function list_for_each_entry`.
- Atlas domain: Driver Families / drivers/usb.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.