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

Commit 72c973dd authored by Tatyana Brokhman's avatar Tatyana Brokhman Committed by Greg Kroah-Hartman
Browse files

usb: gadget: add usb_endpoint_descriptor to struct usb_ep



Change usb_ep_enable() prototype to use endpoint
descriptor from usb_ep.

This optimization spares the FDs from saving the
endpoint chosen descriptor. This optimization is
not full though. To fully exploit this change, one
needs to update all the UDCs as well since in the
current implementation each of them saves the
endpoint descriptor in it's internal (and extended)
endpoint structure.

Signed-off-by: default avatarTatyana Brokhman <tlinder@codeaurora.org>
Signed-off-by: default avatarFelipe Balbi <balbi@ti.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 0f91349b
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -173,7 +173,9 @@ fail_1:

static int __enable_ep(struct usb_ep *ep, struct usb_endpoint_descriptor *desc)
{
	int err = usb_ep_enable(ep, desc);
	int err;
	ep->desc = desc;
	err = usb_ep_enable(ep);
	ep->driver_data = dbgp.gadget;
	return err;
}
@@ -268,8 +270,8 @@ static int __init dbgp_configure_endpoints(struct usb_gadget *gadget)
	dbgp.serial->in = dbgp.i_ep;
	dbgp.serial->out = dbgp.o_ep;

	dbgp.serial->in_desc = &i_desc;
	dbgp.serial->out_desc = &o_desc;
	dbgp.serial->in->desc = &i_desc;
	dbgp.serial->out->desc = &o_desc;

	if (gserial_setup(gadget, 1) < 0) {
		stp = 3;
+4 −5
Original line number Diff line number Diff line
@@ -62,7 +62,6 @@ struct f_acm {
	struct acm_ep_descs		hs;

	struct usb_ep			*notify;
	struct usb_endpoint_descriptor	*notify_desc;
	struct usb_request		*notify_req;

	struct usb_cdc_line_coding	port_line_coding;	/* 8-N-1 etc */
@@ -405,11 +404,11 @@ static int acm_set_alt(struct usb_function *f, unsigned intf, unsigned alt)
			usb_ep_disable(acm->notify);
		} else {
			VDBG(cdev, "init acm ctrl interface %d\n", intf);
			acm->notify_desc = ep_choose(cdev->gadget,
			acm->notify->desc = ep_choose(cdev->gadget,
					acm->hs.notify,
					acm->fs.notify);
		}
		usb_ep_enable(acm->notify, acm->notify_desc);
		usb_ep_enable(acm->notify);
		acm->notify->driver_data = acm;

	} else if (intf == acm->data_id) {
@@ -418,9 +417,9 @@ static int acm_set_alt(struct usb_function *f, unsigned intf, unsigned alt)
			gserial_disconnect(&acm->port);
		} else {
			DBG(cdev, "activate acm ttyGS%d\n", acm->port_num);
			acm->port.in_desc = ep_choose(cdev->gadget,
			acm->port.in->desc = ep_choose(cdev->gadget,
					acm->hs.in, acm->fs.in);
			acm->port.out_desc = ep_choose(cdev->gadget,
			acm->port.out->desc = ep_choose(cdev->gadget,
					acm->hs.out, acm->fs.out);
		}
		gserial_connect(&acm->port, acm->port_num);
+2 −3
Original line number Diff line number Diff line
@@ -279,7 +279,6 @@ struct f_audio {

	/* endpoints handle full and/or high speeds */
	struct usb_ep			*out_ep;
	struct usb_endpoint_descriptor	*out_desc;

	spinlock_t			lock;
	struct f_audio_buf *copy_buf;
@@ -575,7 +574,7 @@ static int f_audio_set_alt(struct usb_function *f, unsigned intf, unsigned alt)

	if (intf == 1) {
		if (alt == 1) {
			usb_ep_enable(out_ep, audio->out_desc);
			usb_ep_enable(out_ep);
			out_ep->driver_data = audio;
			audio->copy_buf = f_audio_buffer_alloc(audio_buf_size);
			if (IS_ERR(audio->copy_buf))
@@ -677,6 +676,7 @@ f_audio_bind(struct usb_configuration *c, struct usb_function *f)
	if (!ep)
		goto fail;
	audio->out_ep = ep;
	audio->out_ep->desc = &as_out_ep_desc;
	ep->driver_data = cdev;	/* claim */

	status = -ENOMEM;
@@ -776,7 +776,6 @@ int __init audio_bind_config(struct usb_configuration *c)
	audio->card.func.set_alt = f_audio_set_alt;
	audio->card.func.setup = f_audio_setup;
	audio->card.func.disable = f_audio_disable;
	audio->out_desc = &as_out_ep_desc;

	control_selector_init(audio);

+8 −9
Original line number Diff line number Diff line
@@ -68,7 +68,6 @@ struct f_ecm {
	struct ecm_ep_descs		hs;

	struct usb_ep			*notify;
	struct usb_endpoint_descriptor	*notify_desc;
	struct usb_request		*notify_req;
	u8				notify_state;
	bool				is_open;
@@ -466,11 +465,11 @@ static int ecm_set_alt(struct usb_function *f, unsigned intf, unsigned alt)
			usb_ep_disable(ecm->notify);
		} else {
			VDBG(cdev, "init ecm ctrl %d\n", intf);
			ecm->notify_desc = ep_choose(cdev->gadget,
			ecm->notify->desc = ep_choose(cdev->gadget,
					ecm->hs.notify,
					ecm->fs.notify);
		}
		usb_ep_enable(ecm->notify, ecm->notify_desc);
		usb_ep_enable(ecm->notify);
		ecm->notify->driver_data = ecm;

	/* Data interface has two altsettings, 0 and 1 */
@@ -483,11 +482,11 @@ static int ecm_set_alt(struct usb_function *f, unsigned intf, unsigned alt)
			gether_disconnect(&ecm->port);
		}

		if (!ecm->port.in) {
		if (!ecm->port.in_ep->desc) {
			DBG(cdev, "init ecm\n");
			ecm->port.in = ep_choose(cdev->gadget,
			ecm->port.in_ep->desc = ep_choose(cdev->gadget,
					ecm->hs.in, ecm->fs.in);
			ecm->port.out = ep_choose(cdev->gadget,
			ecm->port.out_ep->desc = ep_choose(cdev->gadget,
					ecm->hs.out, ecm->fs.out);
		}

@@ -549,7 +548,7 @@ static void ecm_disable(struct usb_function *f)
	if (ecm->notify->driver_data) {
		usb_ep_disable(ecm->notify);
		ecm->notify->driver_data = NULL;
		ecm->notify_desc = NULL;
		ecm->notify->desc = NULL;
	}
}

@@ -723,9 +722,9 @@ fail:
	/* we might as well release our claims on endpoints */
	if (ecm->notify)
		ecm->notify->driver_data = NULL;
	if (ecm->port.out)
	if (ecm->port.out_ep->desc)
		ecm->port.out_ep->driver_data = NULL;
	if (ecm->port.in)
	if (ecm->port.in_ep->desc)
		ecm->port.in_ep->driver_data = NULL;

	ERROR(cdev, "%s: can't bind, err %d\n", f->name, status);
+5 −5
Original line number Diff line number Diff line
@@ -176,11 +176,11 @@ static int eem_set_alt(struct usb_function *f, unsigned intf, unsigned alt)
			gether_disconnect(&eem->port);
		}

		if (!eem->port.in) {
		if (!eem->port.in_ep->desc) {
			DBG(cdev, "init eem\n");
			eem->port.in = ep_choose(cdev->gadget,
			eem->port.in_ep->desc = ep_choose(cdev->gadget,
					eem->hs.in, eem->fs.in);
			eem->port.out = ep_choose(cdev->gadget,
			eem->port.out_ep->desc = ep_choose(cdev->gadget,
					eem->hs.out, eem->fs.out);
		}

@@ -289,9 +289,9 @@ fail:
		usb_free_descriptors(f->descriptors);

	/* we might as well release our claims on endpoints */
	if (eem->port.out)
	if (eem->port.out_ep->desc)
		eem->port.out_ep->driver_data = NULL;
	if (eem->port.in)
	if (eem->port.in_ep->desc)
		eem->port.in_ep->driver_data = NULL;

	ERROR(cdev, "%s: can't bind, err %d\n", f->name, status);
Loading