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

Commit 1e8e848d authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "usb: gadget: Support endpoint allocation by ep name"

parents bf1f2607 5cb39587
Loading
Loading
Loading
Loading
+39 −0
Original line number Diff line number Diff line
@@ -377,3 +377,42 @@ 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 (0 == strcmp(ep->name, ep_name) &&
				!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);
+3 −0
Original line number Diff line number Diff line
@@ -1341,5 +1341,8 @@ extern struct usb_ep *usb_ep_autoconfig_ss(struct usb_gadget *,
			struct usb_ss_ep_comp_descriptor *);

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

#endif /* __LINUX_USB_GADGET_H */