drivers/usb/cdns3/cdns3-ep0.c
Source file repositories/reference/linux-study-clean/drivers/usb/cdns3/cdns3-ep0.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/usb/cdns3/cdns3-ep0.c- Extension
.c- Size
- 23440 bytes
- Lines
- 896
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/usb/composite.hlinux/iopoll.hcdns3-gadget.hcdns3-trace.h
Detected Declarations
function cdns3_ep0_run_transferfunction cdns3_ep0_delegate_reqfunction cdns3_prepare_setup_packetfunction cdns3_ep0_complete_setupfunction cdns3_req_ep0_set_configurationfunction cdns3_req_ep0_set_addressfunction cdns3_req_ep0_get_statusfunction cdns3_ep0_feature_handle_devicefunction cdns3_ep0_feature_handle_intffunction cdns3_ep0_feature_handle_endpointfunction cdns3_req_ep0_handle_featurefunction cdns3_req_ep0_set_selfunction cdns3_req_ep0_set_isoch_delayfunction cdns3_ep0_standard_requestfunction __pending_setup_status_handlerfunction cdns3_pending_setup_status_handlerfunction cdns3_ep0_setup_phasefunction cdns3_transfer_completedfunction cdns3_check_new_setupfunction cdns3_check_ep0_interrupt_proceedfunction cdns3_gadget_ep0_enablefunction cdns3_gadget_ep0_disablefunction cdns3_gadget_ep0_set_haltfunction cdns3_gadget_ep0_queuefunction cdns3_gadget_ep_set_wedgefunction cdns3_ep0_configfunction cdns3_init_ep0
Annotated Snippet
switch (tmode) {
case USB_TEST_J:
case USB_TEST_K:
case USB_TEST_SE0_NAK:
case USB_TEST_PACKET:
cdns3_set_register_bit(&priv_dev->regs->usb_cmd,
USB_CMD_STMODE |
USB_STS_TMODE_SEL(tmode - 1));
break;
default:
ret = -EINVAL;
}
break;
default:
ret = -EINVAL;
}
return ret;
}
static int cdns3_ep0_feature_handle_intf(struct cdns3_device *priv_dev,
struct usb_ctrlrequest *ctrl,
int set)
{
u32 wValue;
int ret = 0;
wValue = le16_to_cpu(ctrl->wValue);
switch (wValue) {
case USB_INTRF_FUNC_SUSPEND:
break;
default:
ret = -EINVAL;
}
return ret;
}
static int cdns3_ep0_feature_handle_endpoint(struct cdns3_device *priv_dev,
struct usb_ctrlrequest *ctrl,
int set)
{
struct cdns3_endpoint *priv_ep;
int ret = 0;
u8 index;
if (le16_to_cpu(ctrl->wValue) != USB_ENDPOINT_HALT)
return -EINVAL;
if (!(le16_to_cpu(ctrl->wIndex) & ~USB_DIR_IN))
return 0;
index = cdns3_ep_addr_to_index(le16_to_cpu(ctrl->wIndex));
priv_ep = priv_dev->eps[index];
cdns3_select_ep(priv_dev, le16_to_cpu(ctrl->wIndex));
if (set)
__cdns3_gadget_ep_set_halt(priv_ep);
else if (!(priv_ep->flags & EP_WEDGE))
ret = __cdns3_gadget_ep_clear_halt(priv_ep);
cdns3_select_ep(priv_dev, 0x00);
return ret;
}
/**
* cdns3_req_ep0_handle_feature -
* Handling of GET/SET_FEATURE standard USB request
*
* @priv_dev: extended gadget object
* @ctrl: pointer to received setup packet
* @set: must be set to 1 for SET_FEATURE request
*
* Returns 0 if success, error code on error
*/
static int cdns3_req_ep0_handle_feature(struct cdns3_device *priv_dev,
struct usb_ctrlrequest *ctrl,
int set)
{
int ret = 0;
u32 recip;
recip = ctrl->bRequestType & USB_RECIP_MASK;
switch (recip) {
case USB_RECIP_DEVICE:
ret = cdns3_ep0_feature_handle_device(priv_dev, ctrl, set);
Annotation
- Immediate include surface: `linux/usb/composite.h`, `linux/iopoll.h`, `cdns3-gadget.h`, `cdns3-trace.h`.
- Detected declarations: `function cdns3_ep0_run_transfer`, `function cdns3_ep0_delegate_req`, `function cdns3_prepare_setup_packet`, `function cdns3_ep0_complete_setup`, `function cdns3_req_ep0_set_configuration`, `function cdns3_req_ep0_set_address`, `function cdns3_req_ep0_get_status`, `function cdns3_ep0_feature_handle_device`, `function cdns3_ep0_feature_handle_intf`, `function cdns3_ep0_feature_handle_endpoint`.
- 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.