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

Commit 5477b054 authored by Devdutt Patnaik's avatar Devdutt Patnaik Committed by Mayank Rana
Browse files

usb: gadget: Support endpoint allocation by ep name



Implement support for allocating an EP based on name.
This allows a function driver to request an EP using an
ep name string. This is useful to request GSI specific
EPs.

CRs-Fixed: 946385
Change-Id: Id38e6e1e3c2d82f440c0507d24f18f808dc3e4dc
Signed-off-by: default avatarDevdutt Patnaik <dpatnaik@codeaurora.org>
Signed-off-by: default avatarMayank Rana <mrana@codeaurora.org>
parent 5f5dff01
Loading
Loading
Loading
Loading
+38 −0
Original line number Diff line number Diff line
@@ -209,3 +209,41 @@ void usb_ep_autoconfig_reset (struct usb_gadget *gadget)
	gadget->out_epnum = 0;
}
EXPORT_SYMBOL_GPL(usb_ep_autoconfig_reset);

/**
 * usb_ep_autoconfig_by_name - Used to pick the endpoint by name. eg ep1in-gsi
 * @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;
	bool ep_found = false;

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

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

	pr_err("%s:error finding ep %s\n", __func__, ep_name);
	return NULL;
}
EXPORT_SYMBOL(usb_ep_autoconfig_by_name);
+5 −0
Original line number Diff line number Diff line
@@ -297,6 +297,7 @@ struct usb_ep_caps {
 * @comp_desc: In case of SuperSpeed support, this is the endpoint companion
 *	descriptor that is used to configure the endpoint
 * @ep_type: Used to specify type of EP eg. normal vs h/w accelerated.
 * @ep_num: Used EP number
 * @ep_intr_num: Interrupter number for EP.
 *
 * the bus controller driver lists all the general purpose endpoints in
@@ -322,6 +323,7 @@ struct usb_ep {
	const struct usb_endpoint_descriptor	*desc;
	const struct usb_ss_ep_comp_descriptor	*comp_desc;
	enum ep_type		ep_type;
	u8			ep_num;
	u8			ep_intr_num;
};

@@ -984,6 +986,9 @@ extern struct usb_ep *usb_ep_autoconfig_ss(struct usb_gadget *,
extern void usb_ep_autoconfig_release(struct usb_ep *);

extern void usb_ep_autoconfig_reset(struct usb_gadget *);
extern struct usb_ep *usb_ep_autoconfig_by_name(struct usb_gadget *gadget,
			struct usb_endpoint_descriptor *desc,
			const char *ep_name);

#ifdef CONFIG_USB_DWC3_MSM
int msm_ep_config(struct usb_ep *ep);