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

Commit 7034eb70 authored by Hemant Kumar's avatar Hemant Kumar Committed by Ajay Agarwal
Browse files

usb: dwc3: Give unique name to gsi endpoints



Using same gsi endpoint name gsi-epin twice prevents creating
second gsi-epin dir and endpoint files for debugfs. Hence
give unique name by appending index after gsi-epin/out string.
Also modify usb_ep_autoconfig_by_name() API to restrict string
comparison to the length of the string passed as parameter.

Change-Id: I3d6e9a3f9eb3fd0c445afc3b76f28dc9199374f4
Signed-off-by: default avatarHemant Kumar <hemantk@codeaurora.org>
Signed-off-by: default avatarAjay Agarwal <ajaya@codeaurora.org>
parent 409330d3
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -2422,9 +2422,12 @@ static int dwc3_gadget_init_hw_endpoints(struct dwc3 *dwc,
		if ((gsi_ep_index < gsi_ep_count) &&
				(i > (num - 1 - gsi_ep_count))) {
			gsi_ep_index++;
			/* For GSI EPs, name eps as "gsi-epin" or "gsi-epout" */
			snprintf(dep->name, sizeof(dep->name), "%s",
				(epnum & 1) ? "gsi-epin" : "gsi-epout");
			/*
			 * For GSI EPs, name eps as "gsi-epin<i>" or
			 * "gsi-epout<i>"
			 */
			snprintf(dep->name, sizeof(dep->name), "%s%d",
			    (epnum & 1) ? "gsi-epin" : "gsi-epout", epnum >> 1);
			/* Set ep type as GSI */
			dep->endpoint.ep_type = EP_TYPE_GSI;
		} else {
+7 −2
Original line number Diff line number Diff line
@@ -211,7 +211,7 @@ void usb_ep_autoconfig_reset (struct usb_gadget *gadget)
EXPORT_SYMBOL_GPL(usb_ep_autoconfig_reset);

/**
 * usb_ep_autoconfig_by_name - Used to pick the endpoint by name. eg ep1in-gsi
 * usb_ep_autoconfig_by_name - Used to pick the endpoint by name. eg gsi-epin14
 * @gadget: The device to which the endpoint must belong.
 * @desc: Endpoint descriptor, with endpoint direction and transfer mode
 *	initialized.
@@ -227,8 +227,12 @@ struct usb_ep *usb_ep_autoconfig_by_name(
	struct usb_ep	*ep;
	bool ep_found = false;

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

	list_for_each_entry(ep, &gadget->ep_list, ep_list)
		if (strcmp(ep->name, ep_name) == 0 && !ep->driver_data) {
		if (strncmp(ep->name, ep_name, strlen(ep_name)) == 0 &&
				!ep->driver_data) {
			ep_found = true;
			break;
		}
@@ -243,6 +247,7 @@ struct usb_ep *usb_ep_autoconfig_by_name(
		return ep;
	}

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