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.

Dependency Surface

Detected Declarations

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

Implementation Notes