Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b49d4cf2 authored by qctecmdr's avatar qctecmdr Committed by Gerrit - the friendly Code Review server
Browse files

Merge "usb: dwc3-msm: Add usb_ep_autoconfig_by_name"

parents 8a9739ba 505da987
Loading
Loading
Loading
Loading
+45 −0
Original line number Diff line number Diff line
@@ -1861,6 +1861,51 @@ static int dbm_ep_config(struct dwc3_msm *mdwc, u8 usb_ep, u8 bam_pipe,
	return dbm_ep;
}

/**
 * usb_ep_autoconfig_by_name - Used to pick the endpoint by name. eg gsi-epin1
 * @gadget: The device to which the endpoint must belong.
 * @desc: Endpoint descriptor, with endpoint direction and transfer mode
 *	initialized.
 * @ep_name: EP name that is to be searched.
 *
 */
struct usb_ep *usb_ep_autoconfig_by_name(
			struct usb_gadget		*gadget,
			struct usb_endpoint_descriptor	*desc,
			const char			*ep_name
)
{
	struct usb_ep *ep;
	struct dwc3_ep *dep;
	bool ep_found = false;

	if (!ep_name || !strlen(ep_name))
		goto err;

	list_for_each_entry(ep, &gadget->ep_list, ep_list)
		if (strncmp(ep->name, ep_name, strlen(ep_name)) == 0 &&
				!ep->driver_data) {
			ep_found = true;
			break;
		}

	if (ep_found) {
		dep = to_dwc3_ep(ep);
		desc->bEndpointAddress &= USB_DIR_IN;
		desc->bEndpointAddress |= dep->number >> 1;
		ep->address = desc->bEndpointAddress;
		pr_debug("Allocating ep address:%x\n", ep->address);
		ep->desc = NULL;
		ep->comp_desc = NULL;
		return ep;
	}

err:
	pr_err("%s:error finding ep %s\n", __func__, ep_name);
	return NULL;
}
EXPORT_SYMBOL(usb_ep_autoconfig_by_name);

/**
 * Configure MSM endpoint.
 * This function do specific configurations
+6 −0
Original line number Diff line number Diff line
@@ -112,6 +112,8 @@ struct gsi_channel_info {
};

#if IS_ENABLED(CONFIG_USB_DWC3_MSM)
struct usb_ep *usb_ep_autoconfig_by_name(struct usb_gadget *gadget,
		struct usb_endpoint_descriptor *desc, const char *ep_name);
int usb_gsi_ep_op(struct usb_ep *ep, void *op_data, enum gsi_ep_op op);
int msm_ep_config(struct usb_ep *ep, struct usb_request *request, u32 bam_opts);
int msm_ep_unconfig(struct usb_ep *ep);
@@ -121,6 +123,10 @@ int msm_data_fifo_config(struct usb_ep *ep, unsigned long addr, u32 size,
bool msm_dwc3_reset_ep_after_lpm(struct usb_gadget *gadget);
int msm_dwc3_reset_dbm_ep(struct usb_ep *ep);
#else
static inline struct usb_ep *usb_ep_autoconfig_by_name(
		struct usb_gadget *gadget, struct usb_endpoint_descriptor *desc,
		const char *ep_name)
{ return NULL; }
static inline int usb_gsi_ep_op(struct usb_ep *ep, void *op_data,
		enum gsi_ep_op op)
{ return 0; }