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

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

usb: gadget: use config_ep_by_speed() instead of ep_choose()



Remove obsolete functions:
1. ep_choose()
2. usb_find_endpoint()

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 48767a4e
Loading
Loading
Loading
Loading
+0 −25
Original line number Diff line number Diff line
@@ -165,28 +165,3 @@ usb_copy_descriptors(struct usb_descriptor_header **src)
	return ret;
}
/**
 * usb_find_endpoint - find a copy of an endpoint descriptor
 * @src: original vector of descriptors
 * @copy: copy of @src
 * @match: endpoint descriptor found in @src
 *
 * This returns the copy of the @match descriptor made for @copy.  Its
 * intended use is to help remembering the endpoint descriptor to use
 * when enabling a given endpoint.
 */
struct usb_endpoint_descriptor *
usb_find_endpoint(
	struct usb_descriptor_header **src,
	struct usb_descriptor_header **copy,
	struct usb_endpoint_descriptor *match
)
{
	while (*src) {
		if (*src == (void *) match)
			return (void *)*copy;
		src++;
		copy++;
	}
	return NULL;
}
+14 −33
Original line number Diff line number Diff line
@@ -39,12 +39,6 @@
 * descriptors (roughly equivalent to CDC Unions) may sometimes help.
 */

struct acm_ep_descs {
	struct usb_endpoint_descriptor	*in;
	struct usb_endpoint_descriptor	*out;
	struct usb_endpoint_descriptor	*notify;
};

struct f_acm {
	struct gserial			port;
	u8				ctrl_id, data_id;
@@ -58,9 +52,6 @@ struct f_acm {
	 */
	spinlock_t			lock;

	struct acm_ep_descs		fs;
	struct acm_ep_descs		hs;

	struct usb_ep			*notify;
	struct usb_request		*notify_req;

@@ -404,9 +395,8 @@ 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->hs.notify,
					acm->fs.notify);
			if (config_ep_by_speed(cdev->gadget, f, acm->notify))
				return -EINVAL;
		}
		usb_ep_enable(acm->notify);
		acm->notify->driver_data = acm;
@@ -415,12 +405,17 @@ static int acm_set_alt(struct usb_function *f, unsigned intf, unsigned alt)
		if (acm->port.in->driver_data) {
			DBG(cdev, "reset acm ttyGS%d\n", acm->port_num);
			gserial_disconnect(&acm->port);
		} else {
		}
		if (!acm->port.in->desc || !acm->port.out->desc) {
			DBG(cdev, "activate acm ttyGS%d\n", acm->port_num);
			acm->port.in->desc = ep_choose(cdev->gadget,
					acm->hs.in, acm->fs.in);
			acm->port.out->desc = ep_choose(cdev->gadget,
					acm->hs.out, acm->fs.out);
			if (config_ep_by_speed(cdev->gadget, f,
					       acm->port.in) ||
			    config_ep_by_speed(cdev->gadget, f,
					       acm->port.out)) {
				acm->port.in->desc = NULL;
				acm->port.out->desc = NULL;
				return -EINVAL;
			}
		}
		gserial_connect(&acm->port, acm->port_num);

@@ -628,18 +623,11 @@ acm_bind(struct usb_configuration *c, struct usb_function *f)
	acm->notify_req->complete = acm_cdc_notify_complete;
	acm->notify_req->context = acm;

	/* copy descriptors, and track endpoint copies */
	/* copy descriptors */
	f->descriptors = usb_copy_descriptors(acm_fs_function);
	if (!f->descriptors)
		goto fail;

	acm->fs.in = usb_find_endpoint(acm_fs_function,
			f->descriptors, &acm_fs_in_desc);
	acm->fs.out = usb_find_endpoint(acm_fs_function,
			f->descriptors, &acm_fs_out_desc);
	acm->fs.notify = usb_find_endpoint(acm_fs_function,
			f->descriptors, &acm_fs_notify_desc);

	/* support all relevant hardware speeds... we expect that when
	 * hardware is dual speed, all bulk-capable endpoints work at
	 * both speeds
@@ -652,15 +640,8 @@ acm_bind(struct usb_configuration *c, struct usb_function *f)
		acm_hs_notify_desc.bEndpointAddress =
				acm_fs_notify_desc.bEndpointAddress;

		/* copy descriptors, and track endpoint copies */
		/* copy descriptors */
		f->hs_descriptors = usb_copy_descriptors(acm_hs_function);

		acm->hs.in = usb_find_endpoint(acm_hs_function,
				f->hs_descriptors, &acm_hs_in_desc);
		acm->hs.out = usb_find_endpoint(acm_hs_function,
				f->hs_descriptors, &acm_hs_out_desc);
		acm->hs.notify = usb_find_endpoint(acm_hs_function,
				f->hs_descriptors, &acm_hs_notify_desc);
	}

	DBG(cdev, "acm ttyGS%d: %s speed IN/%s OUT/%s NOTIFY/%s\n",
+14 −31
Original line number Diff line number Diff line
@@ -46,11 +46,6 @@
 * and also means that a get_alt() method is required.
 */

struct ecm_ep_descs {
	struct usb_endpoint_descriptor	*in;
	struct usb_endpoint_descriptor	*out;
	struct usb_endpoint_descriptor	*notify;
};

enum ecm_notify_state {
	ECM_NOTIFY_NONE,		/* don't notify */
@@ -64,9 +59,6 @@ struct f_ecm {

	char				ethaddr[14];

	struct ecm_ep_descs		fs;
	struct ecm_ep_descs		hs;

	struct usb_ep			*notify;
	struct usb_request		*notify_req;
	u8				notify_state;
@@ -463,11 +455,11 @@ static int ecm_set_alt(struct usb_function *f, unsigned intf, unsigned alt)
		if (ecm->notify->driver_data) {
			VDBG(cdev, "reset ecm control %d\n", intf);
			usb_ep_disable(ecm->notify);
		} else {
		}
		if (!(ecm->notify->desc)) {
			VDBG(cdev, "init ecm ctrl %d\n", intf);
			ecm->notify->desc = ep_choose(cdev->gadget,
					ecm->hs.notify,
					ecm->fs.notify);
			if (config_ep_by_speed(cdev->gadget, f, ecm->notify))
				goto fail;
		}
		usb_ep_enable(ecm->notify);
		ecm->notify->driver_data = ecm;
@@ -482,12 +474,17 @@ static int ecm_set_alt(struct usb_function *f, unsigned intf, unsigned alt)
			gether_disconnect(&ecm->port);
		}

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

		/* CDC Ethernet only sends data in non-default altsettings.
@@ -664,13 +661,6 @@ ecm_bind(struct usb_configuration *c, struct usb_function *f)
	if (!f->descriptors)
		goto fail;

	ecm->fs.in = usb_find_endpoint(ecm_fs_function,
			f->descriptors, &fs_ecm_in_desc);
	ecm->fs.out = usb_find_endpoint(ecm_fs_function,
			f->descriptors, &fs_ecm_out_desc);
	ecm->fs.notify = usb_find_endpoint(ecm_fs_function,
			f->descriptors, &fs_ecm_notify_desc);

	/* support all relevant hardware speeds... we expect that when
	 * hardware is dual speed, all bulk-capable endpoints work at
	 * both speeds
@@ -687,13 +677,6 @@ ecm_bind(struct usb_configuration *c, struct usb_function *f)
		f->hs_descriptors = usb_copy_descriptors(ecm_hs_function);
		if (!f->hs_descriptors)
			goto fail;

		ecm->hs.in = usb_find_endpoint(ecm_hs_function,
				f->hs_descriptors, &hs_ecm_in_desc);
		ecm->hs.out = usb_find_endpoint(ecm_hs_function,
				f->hs_descriptors, &hs_ecm_out_desc);
		ecm->hs.notify = usb_find_endpoint(ecm_hs_function,
				f->hs_descriptors, &hs_ecm_notify_desc);
	}

	/* NOTE:  all that is done without knowing or caring about
+9 −23
Original line number Diff line number Diff line
@@ -35,17 +35,9 @@
 * Ethernet link.
 */

struct eem_ep_descs {
	struct usb_endpoint_descriptor	*in;
	struct usb_endpoint_descriptor	*out;
};

struct f_eem {
	struct gether			port;
	u8				ctrl_id;

	struct eem_ep_descs		fs;
	struct eem_ep_descs		hs;
};

static inline struct f_eem *func_to_eem(struct usb_function *f)
@@ -176,12 +168,16 @@ static int eem_set_alt(struct usb_function *f, unsigned intf, unsigned alt)
			gether_disconnect(&eem->port);
		}

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

		/* zlps should not occur because zero-length EEM packets
@@ -253,11 +249,6 @@ eem_bind(struct usb_configuration *c, struct usb_function *f)
	if (!f->descriptors)
		goto fail;

	eem->fs.in = usb_find_endpoint(eem_fs_function,
			f->descriptors, &eem_fs_in_desc);
	eem->fs.out = usb_find_endpoint(eem_fs_function,
			f->descriptors, &eem_fs_out_desc);

	/* support all relevant hardware speeds... we expect that when
	 * hardware is dual speed, all bulk-capable endpoints work at
	 * both speeds
@@ -272,11 +263,6 @@ eem_bind(struct usb_configuration *c, struct usb_function *f)
		f->hs_descriptors = usb_copy_descriptors(eem_hs_function);
		if (!f->hs_descriptors)
			goto fail;

		eem->hs.in = usb_find_endpoint(eem_hs_function,
				f->hs_descriptors, &eem_hs_in_desc);
		eem->hs.out = usb_find_endpoint(eem_hs_function,
				f->hs_descriptors, &eem_hs_out_desc);
	}

	DBG(cdev, "CDC Ethernet (EEM): %s speed IN/%s OUT/%s\n",
+6 −13
Original line number Diff line number Diff line
@@ -59,8 +59,6 @@ struct f_hidg {
	struct cdev			cdev;
	struct usb_function		func;
	struct usb_ep			*in_ep;
	struct usb_endpoint_descriptor	*fs_in_ep_desc;
	struct usb_endpoint_descriptor	*hs_in_ep_desc;
};

static inline struct f_hidg *func_to_hidg(struct usb_function *f)
@@ -425,8 +423,12 @@ static int hidg_set_alt(struct usb_function *f, unsigned intf, unsigned alt)
		if (hidg->in_ep->driver_data != NULL)
			usb_ep_disable(hidg->in_ep);

		hidg->in_ep->desc = ep_choose(f->config->cdev->gadget,
				hidg->hs_in_ep_desc, hidg->fs_in_ep_desc);
		status = config_ep_by_speed(f->config->cdev->gadget, f,
					    hidg->in_ep);
		if (status) {
			ERROR(cdev, "config_ep_by_speed FAILED!\n");
			goto fail;
		}
		status = usb_ep_enable(hidg->in_ep);
		if (status < 0) {
			ERROR(cdev, "Enable endpoint FAILED!\n");
@@ -497,21 +499,12 @@ static int __init hidg_bind(struct usb_configuration *c, struct usb_function *f)
	if (!f->descriptors)
		goto fail;

	hidg->fs_in_ep_desc = usb_find_endpoint(hidg_fs_descriptors,
						f->descriptors,
						&hidg_fs_in_ep_desc);

	if (gadget_is_dualspeed(c->cdev->gadget)) {
		hidg_hs_in_ep_desc.bEndpointAddress =
			hidg_fs_in_ep_desc.bEndpointAddress;
		f->hs_descriptors = usb_copy_descriptors(hidg_hs_descriptors);
		if (!f->hs_descriptors)
			goto fail;
		hidg->hs_in_ep_desc = usb_find_endpoint(hidg_hs_descriptors,
							f->hs_descriptors,
							&hidg_hs_in_ep_desc);
	} else {
		hidg->hs_in_ep_desc = NULL;
	}

	mutex_init(&hidg->lock);
Loading