drivers/usb/gadget/udc/cdns2/cdns2-ep0.c
Source file repositories/reference/linux-study-clean/drivers/usb/gadget/udc/cdns2/cdns2-ep0.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/usb/gadget/udc/cdns2/cdns2-ep0.c- Extension
.c- Size
- 15992 bytes
- Lines
- 660
- 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/unaligned.hcdns2-gadget.hcdns2-trace.h
Detected Declarations
function cdns2_w_index_to_ep_indexfunction cdns2_check_new_setupfunction cdns2_ep0_enqueuefunction cdns2_ep0_delegate_reqfunction cdns2_ep0_stallfunction cdns2_status_stagefunction cdns2_req_ep0_set_configurationfunction cdns2_req_ep0_set_addressfunction cdns2_req_ep0_handle_statusfunction cdns2_ep0_handle_feature_devicefunction cdns2_ep0_handle_feature_intffunction cdns2_ep0_handle_feature_endpointfunction cdns2_req_ep0_handle_featurefunction cdns2_ep0_std_requestfunction __pending_setup_status_handlerfunction cdns2_pending_setup_status_handlerfunction cdns2_handle_setup_packetfunction cdns2_transfer_completedfunction cdns2_handle_ep0_interruptfunction cdns2_gadget_ep0_enablefunction cdns2_gadget_ep0_disablefunction cdns2_gadget_ep0_set_haltfunction cdns2_gadget_ep0_set_wedgefunction cdns2_gadget_ep0_queuefunction cdns2_ep0_configfunction cdns2_init_ep0
Annotated Snippet
switch (tmode) {
case USB_TEST_J:
case USB_TEST_K:
case USB_TEST_SE0_NAK:
case USB_TEST_PACKET:
/*
* The USBHS controller automatically handles the
* Set_Feature(testmode) request. Standard test modes
* that use values of test mode selector from
* 01h to 04h (Test_J, Test_K, Test_SE0_NAK,
* Test_Packet) are supported by the
* controller(HS - ack, FS - stall).
*/
break;
default:
ret = -EINVAL;
}
break;
default:
ret = -EINVAL;
}
return ret;
}
static int cdns2_ep0_handle_feature_intf(struct cdns2_device *pdev,
struct usb_ctrlrequest *ctrl,
int set)
{
int ret = 0;
u32 wValue;
wValue = le16_to_cpu(ctrl->wValue);
switch (wValue) {
case USB_INTRF_FUNC_SUSPEND:
break;
default:
ret = -EINVAL;
}
return ret;
}
static int cdns2_ep0_handle_feature_endpoint(struct cdns2_device *pdev,
struct usb_ctrlrequest *ctrl,
int set)
{
struct cdns2_endpoint *pep;
u8 wValue;
wValue = le16_to_cpu(ctrl->wValue);
pep = &pdev->eps[cdns2_w_index_to_ep_index(le16_to_cpu(ctrl->wIndex))];
if (wValue != USB_ENDPOINT_HALT)
return -EINVAL;
if (!(le16_to_cpu(ctrl->wIndex) & ~USB_DIR_IN))
return 0;
switch (wValue) {
case USB_ENDPOINT_HALT:
if (set || !(pep->ep_state & EP_WEDGE))
return cdns2_halt_endpoint(pdev, pep, set);
break;
default:
dev_warn(pdev->dev, "WARN Incorrect wValue %04x\n", wValue);
return -EINVAL;
}
return 0;
}
static int cdns2_req_ep0_handle_feature(struct cdns2_device *pdev,
struct usb_ctrlrequest *ctrl,
int set)
{
switch (ctrl->bRequestType & USB_RECIP_MASK) {
case USB_RECIP_DEVICE:
return cdns2_ep0_handle_feature_device(pdev, ctrl, set);
case USB_RECIP_INTERFACE:
return cdns2_ep0_handle_feature_intf(pdev, ctrl, set);
case USB_RECIP_ENDPOINT:
return cdns2_ep0_handle_feature_endpoint(pdev, ctrl, set);
default:
return -EINVAL;
}
}
static int cdns2_ep0_std_request(struct cdns2_device *pdev)
Annotation
- Immediate include surface: `linux/usb/composite.h`, `linux/unaligned.h`, `cdns2-gadget.h`, `cdns2-trace.h`.
- Detected declarations: `function cdns2_w_index_to_ep_index`, `function cdns2_check_new_setup`, `function cdns2_ep0_enqueue`, `function cdns2_ep0_delegate_req`, `function cdns2_ep0_stall`, `function cdns2_status_stage`, `function cdns2_req_ep0_set_configuration`, `function cdns2_req_ep0_set_address`, `function cdns2_req_ep0_handle_status`, `function cdns2_ep0_handle_feature_device`.
- 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.