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

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
...@@ -173,7 +173,9 @@ static int dbgp_enable_ep_req(struct usb_ep *ep) ...@@ -173,7 +173,9 @@ static int dbgp_enable_ep_req(struct usb_ep *ep)
static int __enable_ep(struct usb_ep *ep, struct usb_endpoint_descriptor *desc) 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; ep->driver_data = dbgp.gadget;
return err; return err;
} }
...@@ -268,8 +270,8 @@ static int __init dbgp_configure_endpoints(struct usb_gadget *gadget) ...@@ -268,8 +270,8 @@ static int __init dbgp_configure_endpoints(struct usb_gadget *gadget)
dbgp.serial->in = dbgp.i_ep; dbgp.serial->in = dbgp.i_ep;
dbgp.serial->out = dbgp.o_ep; dbgp.serial->out = dbgp.o_ep;
dbgp.serial->in_desc = &i_desc; dbgp.serial->in->desc = &i_desc;
dbgp.serial->out_desc = &o_desc; dbgp.serial->out->desc = &o_desc;
if (gserial_setup(gadget, 1) < 0) { if (gserial_setup(gadget, 1) < 0) {
stp = 3; stp = 3;
......
...@@ -62,7 +62,6 @@ struct f_acm { ...@@ -62,7 +62,6 @@ struct f_acm {
struct acm_ep_descs hs; struct acm_ep_descs hs;
struct usb_ep *notify; struct usb_ep *notify;
struct usb_endpoint_descriptor *notify_desc;
struct usb_request *notify_req; struct usb_request *notify_req;
struct usb_cdc_line_coding port_line_coding; /* 8-N-1 etc */ 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) ...@@ -405,11 +404,11 @@ static int acm_set_alt(struct usb_function *f, unsigned intf, unsigned alt)
usb_ep_disable(acm->notify); usb_ep_disable(acm->notify);
} else { } else {
VDBG(cdev, "init acm ctrl interface %d\n", intf); 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->hs.notify,
acm->fs.notify); acm->fs.notify);
} }
usb_ep_enable(acm->notify, acm->notify_desc); usb_ep_enable(acm->notify);
acm->notify->driver_data = acm; acm->notify->driver_data = acm;
} else if (intf == acm->data_id) { } else if (intf == acm->data_id) {
...@@ -418,9 +417,9 @@ static int acm_set_alt(struct usb_function *f, unsigned intf, unsigned alt) ...@@ -418,9 +417,9 @@ static int acm_set_alt(struct usb_function *f, unsigned intf, unsigned alt)
gserial_disconnect(&acm->port); gserial_disconnect(&acm->port);
} else { } else {
DBG(cdev, "activate acm ttyGS%d\n", acm->port_num); 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->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); acm->hs.out, acm->fs.out);
} }
gserial_connect(&acm->port, acm->port_num); gserial_connect(&acm->port, acm->port_num);
......
...@@ -279,7 +279,6 @@ struct f_audio { ...@@ -279,7 +279,6 @@ struct f_audio {
/* endpoints handle full and/or high speeds */ /* endpoints handle full and/or high speeds */
struct usb_ep *out_ep; struct usb_ep *out_ep;
struct usb_endpoint_descriptor *out_desc;
spinlock_t lock; spinlock_t lock;
struct f_audio_buf *copy_buf; struct f_audio_buf *copy_buf;
...@@ -575,7 +574,7 @@ static int f_audio_set_alt(struct usb_function *f, unsigned intf, unsigned alt) ...@@ -575,7 +574,7 @@ static int f_audio_set_alt(struct usb_function *f, unsigned intf, unsigned alt)
if (intf == 1) { if (intf == 1) {
if (alt == 1) { if (alt == 1) {
usb_ep_enable(out_ep, audio->out_desc); usb_ep_enable(out_ep);
out_ep->driver_data = audio; out_ep->driver_data = audio;
audio->copy_buf = f_audio_buffer_alloc(audio_buf_size); audio->copy_buf = f_audio_buffer_alloc(audio_buf_size);
if (IS_ERR(audio->copy_buf)) if (IS_ERR(audio->copy_buf))
...@@ -677,6 +676,7 @@ f_audio_bind(struct usb_configuration *c, struct usb_function *f) ...@@ -677,6 +676,7 @@ f_audio_bind(struct usb_configuration *c, struct usb_function *f)
if (!ep) if (!ep)
goto fail; goto fail;
audio->out_ep = ep; audio->out_ep = ep;
audio->out_ep->desc = &as_out_ep_desc;
ep->driver_data = cdev; /* claim */ ep->driver_data = cdev; /* claim */
status = -ENOMEM; status = -ENOMEM;
...@@ -776,7 +776,6 @@ int __init audio_bind_config(struct usb_configuration *c) ...@@ -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.set_alt = f_audio_set_alt;
audio->card.func.setup = f_audio_setup; audio->card.func.setup = f_audio_setup;
audio->card.func.disable = f_audio_disable; audio->card.func.disable = f_audio_disable;
audio->out_desc = &as_out_ep_desc;
control_selector_init(audio); control_selector_init(audio);
......
...@@ -68,7 +68,6 @@ struct f_ecm { ...@@ -68,7 +68,6 @@ struct f_ecm {
struct ecm_ep_descs hs; struct ecm_ep_descs hs;
struct usb_ep *notify; struct usb_ep *notify;
struct usb_endpoint_descriptor *notify_desc;
struct usb_request *notify_req; struct usb_request *notify_req;
u8 notify_state; u8 notify_state;
bool is_open; bool is_open;
...@@ -466,11 +465,11 @@ static int ecm_set_alt(struct usb_function *f, unsigned intf, unsigned alt) ...@@ -466,11 +465,11 @@ static int ecm_set_alt(struct usb_function *f, unsigned intf, unsigned alt)
usb_ep_disable(ecm->notify); usb_ep_disable(ecm->notify);
} else { } else {
VDBG(cdev, "init ecm ctrl %d\n", intf); 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->hs.notify,
ecm->fs.notify); ecm->fs.notify);
} }
usb_ep_enable(ecm->notify, ecm->notify_desc); usb_ep_enable(ecm->notify);
ecm->notify->driver_data = ecm; ecm->notify->driver_data = ecm;
/* Data interface has two altsettings, 0 and 1 */ /* 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) ...@@ -483,11 +482,11 @@ static int ecm_set_alt(struct usb_function *f, unsigned intf, unsigned alt)
gether_disconnect(&ecm->port); gether_disconnect(&ecm->port);
} }
if (!ecm->port.in) { if (!ecm->port.in_ep->desc) {
DBG(cdev, "init ecm\n"); 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->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); ecm->hs.out, ecm->fs.out);
} }
...@@ -549,7 +548,7 @@ static void ecm_disable(struct usb_function *f) ...@@ -549,7 +548,7 @@ static void ecm_disable(struct usb_function *f)
if (ecm->notify->driver_data) { if (ecm->notify->driver_data) {
usb_ep_disable(ecm->notify); usb_ep_disable(ecm->notify);
ecm->notify->driver_data = NULL; ecm->notify->driver_data = NULL;
ecm->notify_desc = NULL; ecm->notify->desc = NULL;
} }
} }
...@@ -723,9 +722,9 @@ ecm_bind(struct usb_configuration *c, struct usb_function *f) ...@@ -723,9 +722,9 @@ ecm_bind(struct usb_configuration *c, struct usb_function *f)
/* we might as well release our claims on endpoints */ /* we might as well release our claims on endpoints */
if (ecm->notify) if (ecm->notify)
ecm->notify->driver_data = NULL; ecm->notify->driver_data = NULL;
if (ecm->port.out) if (ecm->port.out_ep->desc)
ecm->port.out_ep->driver_data = NULL; ecm->port.out_ep->driver_data = NULL;
if (ecm->port.in) if (ecm->port.in_ep->desc)
ecm->port.in_ep->driver_data = NULL; ecm->port.in_ep->driver_data = NULL;
ERROR(cdev, "%s: can't bind, err %d\n", f->name, status); ERROR(cdev, "%s: can't bind, err %d\n", f->name, status);
......
...@@ -176,11 +176,11 @@ static int eem_set_alt(struct usb_function *f, unsigned intf, unsigned alt) ...@@ -176,11 +176,11 @@ static int eem_set_alt(struct usb_function *f, unsigned intf, unsigned alt)
gether_disconnect(&eem->port); gether_disconnect(&eem->port);
} }
if (!eem->port.in) { if (!eem->port.in_ep->desc) {
DBG(cdev, "init eem\n"); 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->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); eem->hs.out, eem->fs.out);
} }
...@@ -289,9 +289,9 @@ eem_bind(struct usb_configuration *c, struct usb_function *f) ...@@ -289,9 +289,9 @@ eem_bind(struct usb_configuration *c, struct usb_function *f)
usb_free_descriptors(f->descriptors); usb_free_descriptors(f->descriptors);
/* we might as well release our claims on endpoints */ /* 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; eem->port.out_ep->driver_data = NULL;
if (eem->port.in) if (eem->port.in_ep->desc)
eem->port.in_ep->driver_data = NULL; eem->port.in_ep->driver_data = NULL;
ERROR(cdev, "%s: can't bind, err %d\n", f->name, status); ERROR(cdev, "%s: can't bind, err %d\n", f->name, status);
......
...@@ -1544,7 +1544,8 @@ static int ffs_func_eps_enable(struct ffs_function *func) ...@@ -1544,7 +1544,8 @@ static int ffs_func_eps_enable(struct ffs_function *func)
ds = ep->descs[ep->descs[1] ? 1 : 0]; ds = ep->descs[ep->descs[1] ? 1 : 0];
ep->ep->driver_data = ep; ep->ep->driver_data = ep;
ret = usb_ep_enable(ep->ep, ds); ep->ep->desc = ds;
ret = usb_ep_enable(ep->ep);
if (likely(!ret)) { if (likely(!ret)) {
epfile->ep = ep; epfile->ep = ep;
epfile->in = usb_endpoint_dir_in(ds); epfile->in = usb_endpoint_dir_in(ds);
......
...@@ -416,7 +416,6 @@ static int hidg_set_alt(struct usb_function *f, unsigned intf, unsigned alt) ...@@ -416,7 +416,6 @@ static int hidg_set_alt(struct usb_function *f, unsigned intf, unsigned alt)
{ {
struct usb_composite_dev *cdev = f->config->cdev; struct usb_composite_dev *cdev = f->config->cdev;
struct f_hidg *hidg = func_to_hidg(f); struct f_hidg *hidg = func_to_hidg(f);
const struct usb_endpoint_descriptor *ep_desc;
int status = 0; int status = 0;
VDBG(cdev, "hidg_set_alt intf:%d alt:%d\n", intf, alt); VDBG(cdev, "hidg_set_alt intf:%d alt:%d\n", intf, alt);
...@@ -426,9 +425,9 @@ static int hidg_set_alt(struct usb_function *f, unsigned intf, unsigned alt) ...@@ -426,9 +425,9 @@ static int hidg_set_alt(struct usb_function *f, unsigned intf, unsigned alt)
if (hidg->in_ep->driver_data != NULL) if (hidg->in_ep->driver_data != NULL)
usb_ep_disable(hidg->in_ep); usb_ep_disable(hidg->in_ep);
ep_desc = ep_choose(f->config->cdev->gadget, hidg->in_ep->desc = ep_choose(f->config->cdev->gadget,
hidg->hs_in_ep_desc, hidg->fs_in_ep_desc); hidg->hs_in_ep_desc, hidg->fs_in_ep_desc);
status = usb_ep_enable(hidg->in_ep, ep_desc); status = usb_ep_enable(hidg->in_ep);
if (status < 0) { if (status < 0) {
ERROR(cdev, "Enable endpoint FAILED!\n"); ERROR(cdev, "Enable endpoint FAILED!\n");
goto fail; goto fail;
......
...@@ -250,26 +250,24 @@ static int ...@@ -250,26 +250,24 @@ static int
enable_loopback(struct usb_composite_dev *cdev, struct f_loopback *loop) enable_loopback(struct usb_composite_dev *cdev, struct f_loopback *loop)
{ {
int result = 0; int result = 0;
const struct usb_endpoint_descriptor *src, *sink;
struct usb_ep *ep; struct usb_ep *ep;
struct usb_request *req; struct usb_request *req;
unsigned i; unsigned i;
src = ep_choose(cdev->gadget,
&hs_loop_source_desc, &fs_loop_source_desc);
sink = ep_choose(cdev->gadget,
&hs_loop_sink_desc, &fs_loop_sink_desc);
/* one endpoint writes data back IN to the host */ /* one endpoint writes data back IN to the host */
ep = loop->in_ep; ep = loop->in_ep;
result = usb_ep_enable(ep, src); ep->desc = ep_choose(cdev->gadget,
&hs_loop_source_desc, &fs_loop_source_desc);
result = usb_ep_enable(ep);
if (result < 0) if (result < 0)
return result; return result;
ep->driver_data = loop; ep->driver_data = loop;
/* one endpoint just reads OUT packets */ /* one endpoint just reads OUT packets */
ep = loop->out_ep; ep = loop->out_ep;
result = usb_ep_enable(ep, sink); ep->desc = ep_choose(cdev->gadget,
&hs_loop_sink_desc, &fs_loop_sink_desc);
result = usb_ep_enable(ep);
if (result < 0) { if (result < 0) {
fail0: fail0:
ep = loop->in_ep; ep = loop->in_ep;
......
...@@ -2330,7 +2330,8 @@ static int enable_endpoint(struct fsg_common *common, struct usb_ep *ep, ...@@ -2330,7 +2330,8 @@ static int enable_endpoint(struct fsg_common *common, struct usb_ep *ep,
int rc; int rc;
ep->driver_data = common; ep->driver_data = common;
rc = usb_ep_enable(ep, d); ep->desc = (struct usb_endpoint_descriptor *)d;
rc = usb_ep_enable(ep);
if (rc) if (rc)
ERROR(common, "can't enable %s, result %d\n", ep->name, rc); ERROR(common, "can't enable %s, result %d\n", ep->name, rc);
return rc; return rc;
......
...@@ -70,7 +70,6 @@ struct f_ncm { ...@@ -70,7 +70,6 @@ struct f_ncm {
struct ncm_ep_descs hs; struct ncm_ep_descs hs;
struct usb_ep *notify; struct usb_ep *notify;
struct usb_endpoint_descriptor *notify_desc;
struct usb_request *notify_req; struct usb_request *notify_req;
u8 notify_state; u8 notify_state;
bool is_open; bool is_open;
...@@ -804,11 +803,11 @@ static int ncm_set_alt(struct usb_function *f, unsigned intf, unsigned alt) ...@@ -804,11 +803,11 @@ static int ncm_set_alt(struct usb_function *f, unsigned intf, unsigned alt)
usb_ep_disable(ncm->notify); usb_ep_disable(ncm->notify);
} else { } else {
DBG(cdev, "init ncm ctrl %d\n", intf); DBG(cdev, "init ncm ctrl %d\n", intf);
ncm->notify_desc = ep_choose(cdev->gadget, ncm->notify->desc = ep_choose(cdev->gadget,
ncm->hs.notify, ncm->hs.notify,
ncm->fs.notify); ncm->fs.notify);
} }
usb_ep_enable(ncm->notify, ncm->notify_desc); usb_ep_enable(ncm->notify);
ncm->notify->driver_data = ncm; ncm->notify->driver_data = ncm;
/* Data interface has two altsettings, 0 and 1 */ /* Data interface has two altsettings, 0 and 1 */
...@@ -829,12 +828,12 @@ static int ncm_set_alt(struct usb_function *f, unsigned intf, unsigned alt) ...@@ -829,12 +828,12 @@ static int ncm_set_alt(struct usb_function *f, unsigned intf, unsigned alt)
if (alt == 1) { if (alt == 1) {
struct net_device *net; struct net_device *net;
if (!ncm->port.in) { if (!ncm->port.in_ep->desc) {
DBG(cdev, "init ncm\n"); DBG(cdev, "init ncm\n");
ncm->port.in = ep_choose(cdev->gadget, ncm->port.in_ep->desc = ep_choose(cdev->gadget,
ncm->hs.in, ncm->hs.in,
ncm->fs.in); ncm->fs.in);
ncm->port.out = ep_choose(cdev->gadget, ncm->port.out_ep->desc = ep_choose(cdev->gadget,
ncm->hs.out, ncm->hs.out,
ncm->fs.out); ncm->fs.out);
} }
...@@ -1111,7 +1110,7 @@ static void ncm_disable(struct usb_function *f) ...@@ -1111,7 +1110,7 @@ static void ncm_disable(struct usb_function *f)
if (ncm->notify->driver_data) { if (ncm->notify->driver_data) {
usb_ep_disable(ncm->notify); usb_ep_disable(ncm->notify);
ncm->notify->driver_data = NULL; ncm->notify->driver_data = NULL;
ncm->notify_desc = NULL; ncm->notify->desc = NULL;
} }
} }
...@@ -1288,9 +1287,9 @@ ncm_bind(struct usb_configuration *c, struct usb_function *f) ...@@ -1288,9 +1287,9 @@ ncm_bind(struct usb_configuration *c, struct usb_function *f)
/* we might as well release our claims on endpoints */ /* we might as well release our claims on endpoints */
if (ncm->notify) if (ncm->notify)
ncm->notify->driver_data = NULL; ncm->notify->driver_data = NULL;
if (ncm->port.out) if (ncm->port.out_ep->desc)
ncm->port.out_ep->driver_data = NULL; ncm->port.out_ep->driver_data = NULL;
if (ncm->port.in) if (ncm->port.in_ep->desc)
ncm->port.in_ep->driver_data = NULL; ncm->port.in_ep->driver_data = NULL;
ERROR(cdev, "%s: can't bind, err %d\n", f->name, status); ERROR(cdev, "%s: can't bind, err %d\n", f->name, status);
......
...@@ -227,11 +227,11 @@ static int obex_set_alt(struct usb_function *f, unsigned intf, unsigned alt) ...@@ -227,11 +227,11 @@ static int obex_set_alt(struct usb_function *f, unsigned intf, unsigned alt)
gserial_disconnect(&obex->port); gserial_disconnect(&obex->port);
} }
if (!obex->port.in_desc) { if (!obex->port.in->desc) {
DBG(cdev, "init obex ttyGS%d\n", obex->port_num); DBG(cdev, "init obex ttyGS%d\n", obex->port_num);
obex->port.in_desc = ep_choose(cdev->gadget, obex->port.in->desc = ep_choose(cdev->gadget,
obex->hs.obex_in, obex->fs.obex_in); obex->hs.obex_in, obex->fs.obex_in);
obex->port.out_desc = ep_choose(cdev->gadget, obex->port.out->desc = ep_choose(cdev->gadget,
obex->hs.obex_out, obex->fs.obex_out); obex->hs.obex_out, obex->fs.obex_out);
} }
......
...@@ -427,17 +427,16 @@ static int pn_set_alt(struct usb_function *f, unsigned intf, unsigned alt) ...@@ -427,17 +427,16 @@ static int pn_set_alt(struct usb_function *f, unsigned intf, unsigned alt)
spin_lock(&port->lock); spin_lock(&port->lock);
__pn_reset(f); __pn_reset(f);
if (alt == 1) { if (alt == 1) {
struct usb_endpoint_descriptor *out, *in;
int i; int i;
out = ep_choose(gadget, fp->out_ep->desc = ep_choose(gadget,
&pn_hs_sink_desc, &pn_hs_sink_desc,
&pn_fs_sink_desc); &pn_fs_sink_desc);
in = ep_choose(gadget, fp->in_ep->desc = ep_choose(gadget,
&pn_hs_source_desc, &pn_hs_source_desc,
&pn_fs_source_desc); &pn_fs_source_desc);
usb_ep_enable(fp->out_ep, out); usb_ep_enable(fp->out_ep);
usb_ep_enable(fp->in_ep, in); usb_ep_enable(fp->in_ep);
port->usb = fp; port->usb = fp;
fp->out_ep->driver_data = fp; fp->out_ep->driver_data = fp;
......
...@@ -92,7 +92,6 @@ struct f_rndis { ...@@ -92,7 +92,6 @@ struct f_rndis {
struct rndis_ep_descs hs; struct rndis_ep_descs hs;
struct usb_ep *notify; struct usb_ep *notify;
struct usb_endpoint_descriptor *notify_desc;
struct usb_request *notify_req; struct usb_request *notify_req;
atomic_t notify_count; atomic_t notify_count;
}; };
...@@ -486,11 +485,11 @@ static int rndis_set_alt(struct usb_function *f, unsigned intf, unsigned alt) ...@@ -486,11 +485,11 @@ static int rndis_set_alt(struct usb_function *f, unsigned intf, unsigned alt)
usb_ep_disable(rndis->notify); usb_ep_disable(rndis->notify);
} else { } else {
VDBG(cdev, "init rndis ctrl %d\n", intf); VDBG(cdev, "init rndis ctrl %d\n", intf);
rndis->notify_desc = ep_choose(cdev->gadget, rndis->notify->desc = ep_choose(cdev->gadget,
rndis->hs.notify, rndis->hs.notify,
rndis->fs.notify); rndis->fs.notify);
} }
usb_ep_enable(rndis->notify, rndis->notify_desc); usb_ep_enable(rndis->notify);
rndis->notify->driver_data = rndis; rndis->notify->driver_data = rndis;
} else if (intf == rndis->data_id) { } else if (intf == rndis->data_id) {
...@@ -501,11 +500,11 @@ static int rndis_set_alt(struct usb_function *f, unsigned intf, unsigned alt) ...@@ -501,11 +500,11 @@ static int rndis_set_alt(struct usb_function *f, unsigned intf, unsigned alt)
gether_disconnect(&rndis->port); gether_disconnect(&rndis->port);
} }
if (!rndis->port.in) { if (!rndis->port.in_ep->desc) {
DBG(cdev, "init rndis\n"); DBG(cdev, "init rndis\n");
rndis->port.in = ep_choose(cdev->gadget, rndis->port.in_ep->desc = ep_choose(cdev->gadget,
rndis->hs.in, rndis->fs.in); rndis->hs.in, rndis->fs.in);
rndis->port.out = ep_choose(cdev->gadget, rndis->port.out_ep->desc = ep_choose(cdev->gadget,
rndis->hs.out, rndis->fs.out); rndis->hs.out, rndis->fs.out);
} }
...@@ -738,9 +737,9 @@ rndis_bind(struct usb_configuration *c, struct usb_function *f) ...@@ -738,9 +737,9 @@ rndis_bind(struct usb_configuration *c, struct usb_function *f)
/* we might as well release our claims on endpoints */ /* we might as well release our claims on endpoints */
if (rndis->notify) if (rndis->notify)
rndis->notify->driver_data = NULL; rndis->notify->driver_data = NULL;
if (rndis->port.out) if (rndis->port.out_ep->desc)
rndis->port.out_ep->driver_data = NULL; rndis->port.out_ep->driver_data = NULL;
if (rndis->port.in) if (rndis->port.in_ep->desc)
rndis->port.in_ep->driver_data = NULL; rndis->port.in_ep->driver_data = NULL;
ERROR(cdev, "%s: can't bind, err %d\n", f->name, status); ERROR(cdev, "%s: can't bind, err %d\n", f->name, status);
......
...@@ -138,9 +138,9 @@ static int gser_set_alt(struct usb_function *f, unsigned intf, unsigned alt) ...@@ -138,9 +138,9 @@ static int gser_set_alt(struct usb_function *f, unsigned intf, unsigned alt)
gserial_disconnect(&gser->port); gserial_disconnect(&gser->port);
} else { } else {
DBG(cdev, "activate generic ttyGS%d\n", gser->port_num); DBG(cdev, "activate generic ttyGS%d\n", gser->port_num);
gser->port.in_desc = ep_choose(cdev->gadget, gser->port.in->desc = ep_choose(cdev->gadget,
gser->hs.in, gser->fs.in); gser->hs.in, gser->fs.in);
gser->port.out_desc = ep_choose(cdev->gadget, gser->port.out->desc = ep_choose(cdev->gadget,
gser->hs.out, gser->fs.out); gser->hs.out, gser->fs.out);
} }
gserial_connect(&gser->port, gser->port_num); gserial_connect(&gser->port, gser->port_num);
......
...@@ -343,15 +343,12 @@ static int ...@@ -343,15 +343,12 @@ static int
enable_source_sink(struct usb_composite_dev *cdev, struct f_sourcesink *ss) enable_source_sink(struct usb_composite_dev *cdev, struct f_sourcesink *ss)
{ {
int result = 0; int result = 0;
const struct usb_endpoint_descriptor *src, *sink;
struct usb_ep *ep; struct usb_ep *ep;
src = ep_choose(cdev->gadget, &hs_source_desc, &fs_source_desc);
sink = ep_choose(cdev->gadget, &hs_sink_desc, &fs_sink_desc);
/* one endpoint writes (sources) zeroes IN (to the host) */ /* one endpoint writes (sources) zeroes IN (to the host) */
ep = ss->in_ep; ep = ss->in_ep;
result = usb_ep_enable(ep, src); ep->desc = ep_choose(cdev->gadget, &hs_source_desc, &fs_source_desc);
result = usb_ep_enable(ep);
if (result < 0) if (result < 0)
return result; return result;
ep->driver_data = ss; ep->driver_data = ss;
...@@ -367,7 +364,8 @@ enable_source_sink(struct usb_composite_dev *cdev, struct f_sourcesink *ss) ...@@ -367,7 +364,8 @@ enable_source_sink(struct usb_composite_dev *cdev, struct f_sourcesink *ss)
/* one endpoint reads (sinks) anything OUT (from the host) */ /* one endpoint reads (sinks) anything OUT (from the host) */
ep = ss->out_ep; ep = ss->out_ep;
result = usb_ep_enable(ep, sink); ep->desc = ep_choose(cdev->gadget, &hs_sink_desc, &fs_sink_desc);
result = usb_ep_enable(ep);
if (result < 0) if (result < 0)
goto fail; goto fail;
ep->driver_data = ss; ep->driver_data = ss;
......
...@@ -243,9 +243,9 @@ static int geth_set_alt(struct usb_function *f, unsigned intf, unsigned alt) ...@@ -243,9 +243,9 @@ static int geth_set_alt(struct usb_function *f, unsigned intf, unsigned alt)
} }
DBG(cdev, "init + activate cdc subset\n"); DBG(cdev, "init + activate cdc subset\n");
geth->port.in = ep_choose(cdev->gadget, geth->port.in_ep->desc = ep_choose(cdev->gadget,
geth->hs.in, geth->fs.in); geth->hs.in, geth->fs.in);
geth->port.out = ep_choose(cdev->gadget, geth->port.out_ep->desc = ep_choose(cdev->gadget,
geth->hs.out, geth->fs.out); geth->hs.out, geth->fs.out);
net = gether_connect(&geth->port); net = gether_connect(&geth->port);
...@@ -334,9 +334,9 @@ geth_bind(struct usb_configuration *c, struct usb_function *f) ...@@ -334,9 +334,9 @@ geth_bind(struct usb_configuration *c, struct usb_function *f)
fail: fail:
/* we might as well release our claims on endpoints */ /* we might as well release our claims on endpoints */
if (geth->port.out) if (geth->port.out_ep->desc)
geth->port.out_ep->driver_data = NULL; geth->port.out_ep->driver_data = NULL;
if (geth->port.in) if (geth->port.in_ep->desc)
geth->port.in_ep->driver_data = NULL; geth->port.in_ep->driver_data = NULL;
ERROR(cdev, "%s: can't bind, err %d\n", f->name, status); ERROR(cdev, "%s: can't bind, err %d\n", f->name, status);
......
...@@ -262,8 +262,10 @@ uvc_function_set_alt(struct usb_function *f, unsigned interface, unsigned alt) ...@@ -262,8 +262,10 @@ uvc_function_set_alt(struct usb_function *f, unsigned interface, unsigned alt)
if (uvc->state != UVC_STATE_CONNECTED) if (uvc->state != UVC_STATE_CONNECTED)
return 0; return 0;
if (uvc->video.ep) if (uvc->video.ep) {
usb_ep_enable(uvc->video.ep, &uvc_streaming_ep); uvc->video.ep->desc = &uvc_streaming_ep;
usb_ep_enable(uvc->video.ep);
}
memset(&v4l2_event, 0, sizeof(v4l2_event)); memset(&v4l2_event, 0, sizeof(v4l2_event));
v4l2_event.type = UVC_EVENT_STREAMON; v4l2_event.type = UVC_EVENT_STREAMON;
......
...@@ -2713,7 +2713,8 @@ static int enable_endpoint(struct fsg_dev *fsg, struct usb_ep *ep, ...@@ -2713,7 +2713,8 @@ static int enable_endpoint(struct fsg_dev *fsg, struct usb_ep *ep,
int rc; int rc;
ep->driver_data = fsg; ep->driver_data = fsg;
rc = usb_ep_enable(ep, d); ep->desc = d;
rc = usb_ep_enable(ep);
if (rc) if (rc)
ERROR(fsg, "can't enable %s, result %d\n", ep->name, rc); ERROR(fsg, "can't enable %s, result %d\n", ep->name, rc);
return rc; return rc;
......
...@@ -537,14 +537,16 @@ static int set_gmidi_config(struct gmidi_device *dev, gfp_t gfp_flags) ...@@ -537,14 +537,16 @@ static int set_gmidi_config(struct gmidi_device *dev, gfp_t gfp_flags)
struct usb_ep *ep; struct usb_ep *ep;
unsigned i; unsigned i;
err = usb_ep_enable(dev->in_ep, &bulk_in_desc); dev->in_ep->desc = &bulk_in_desc;
err = usb_ep_enable(dev->in_ep);
if (err) { if (err) {
ERROR(dev, "can't start %s: %d\n", dev->in_ep->name, err); ERROR(dev, "can't start %s: %d\n", dev->in_ep->name, err);
goto fail; goto fail;
} }
dev->in_ep->driver_data = dev; dev->in_ep->driver_data = dev;
err = usb_ep_enable(dev->out_ep, &bulk_out_desc); dev->out_ep->desc = &bulk_out_desc;
err = usb_ep_enable(dev->out_ep);
if (err) { if (err) {
ERROR(dev, "can't start %s: %d\n", dev->out_ep->name, err); ERROR(dev, "can't start %s: %d\n", dev->out_ep->name, err);
goto fail; goto fail;
......
...@@ -832,14 +832,16 @@ ep_config (struct file *fd, const char __user *buf, size_t len, loff_t *ptr) ...@@ -832,14 +832,16 @@ ep_config (struct file *fd, const char __user *buf, size_t len, loff_t *ptr)
switch (data->dev->gadget->speed) { switch (data->dev->gadget->speed) {
case USB_SPEED_LOW: case USB_SPEED_LOW:
case USB_SPEED_FULL: case USB_SPEED_FULL:
value = usb_ep_enable (ep, &data->desc); ep->desc = &data->desc;
value = usb_ep_enable(ep);
if (value == 0) if (value == 0)
data->state = STATE_EP_ENABLED; data->state = STATE_EP_ENABLED;
break; break;
#ifdef CONFIG_USB_GADGET_DUALSPEED #ifdef CONFIG_USB_GADGET_DUALSPEED
case USB_SPEED_HIGH: case USB_SPEED_HIGH:
/* fails if caller didn't provide that descriptor... */ /* fails if caller didn't provide that descriptor... */
value = usb_ep_enable (ep, &data->hs_desc); ep->desc = &data->hs_desc;
value = usb_ep_enable(ep);
if (value == 0) if (value == 0)
data->state = STATE_EP_ENABLED; data->state = STATE_EP_ENABLED;
break; break;
......
...@@ -89,8 +89,7 @@ struct printer_dev { ...@@ -89,8 +89,7 @@ struct printer_dev {
u8 config; u8 config;
s8 interface; s8 interface;
struct usb_ep *in_ep, *out_ep; struct usb_ep *in_ep, *out_ep;
const struct usb_endpoint_descriptor
*in, *out;
struct list_head rx_reqs; /* List of free RX structs */ struct list_head rx_reqs; /* List of free RX structs */
struct list_head rx_reqs_active; /* List of Active RX xfers */ struct list_head rx_reqs_active; /* List of Active RX xfers */
struct list_head rx_buffers; /* List of completed xfers */ struct list_head rx_buffers; /* List of completed xfers */
...@@ -895,19 +894,20 @@ set_printer_interface(struct printer_dev *dev) ...@@ -895,19 +894,20 @@ set_printer_interface(struct printer_dev *dev)
{ {
int result = 0; int result = 0;
dev->in = ep_desc(dev->gadget, &hs_ep_in_desc, &fs_ep_in_desc); dev->in_ep->desc = ep_desc(dev->gadget, &hs_ep_in_desc, &fs_ep_in_desc);
dev->in_ep->driver_data = dev; dev->in_ep->driver_data = dev;
dev->out = ep_desc(dev->gadget, &hs_ep_out_desc, &fs_ep_out_desc); dev->out_ep->desc = ep_desc(dev->gadget, &hs_ep_out_desc,
&fs_ep_out_desc);
dev->out_ep->driver_data = dev; dev->out_ep->driver_data = dev;
result = usb_ep_enable(dev->in_ep, dev->in); result = usb_ep_enable(dev->in_ep);
if (result != 0) { if (result != 0) {
DBG(dev, "enable %s --> %d\n", dev->in_ep->name, result); DBG(dev, "enable %s --> %d\n", dev->in_ep->name, result);
goto done; goto done;
} }
result = usb_ep_enable(dev->out_ep, dev->out); result = usb_ep_enable(dev->out_ep);
if (result != 0) { if (result != 0) {
DBG(dev, "enable %s --> %d\n", dev->in_ep->name, result); DBG(dev, "enable %s --> %d\n", dev->in_ep->name, result);
goto done; goto done;
...@@ -918,8 +918,8 @@ set_printer_interface(struct printer_dev *dev) ...@@ -918,8 +918,8 @@ set_printer_interface(struct printer_dev *dev)
if (result != 0) { if (result != 0) {
(void) usb_ep_disable(dev->in_ep); (void) usb_ep_disable(dev->in_ep);
(void) usb_ep_disable(dev->out_ep); (void) usb_ep_disable(dev->out_ep);
dev->in = NULL; dev->in_ep->desc = NULL;
dev->out = NULL; dev->out_ep->desc = NULL;
} }
/* caller is responsible for cleanup on error */ /* caller is responsible for cleanup on error */
...@@ -933,12 +933,14 @@ static void printer_reset_interface(struct printer_dev *dev) ...@@ -933,12 +933,14 @@ static void printer_reset_interface(struct printer_dev *dev)
DBG(dev, "%s\n", __func__); DBG(dev, "%s\n", __func__);
if (dev->in) if (dev->in_ep->desc)
usb_ep_disable(dev->in_ep); usb_ep_disable(dev->in_ep);
if (dev->out) if (dev->out_ep->desc)
usb_ep_disable(dev->out_ep); usb_ep_disable(dev->out_ep);
dev->in_ep->desc = NULL;
dev->out_ep->desc = NULL;
dev->interface = -1; dev->interface = -1;
} }
...@@ -1104,9 +1106,9 @@ static void printer_soft_reset(struct printer_dev *dev) ...@@ -1104,9 +1106,9 @@ static void printer_soft_reset(struct printer_dev *dev)
list_add(&req->list, &dev->tx_reqs); list_add(&req->list, &dev->tx_reqs);
} }
if (usb_ep_enable(dev->in_ep, dev->in)) if (usb_ep_enable(dev->in_ep))
DBG(dev, "Failed to enable USB in_ep\n"); DBG(dev, "Failed to enable USB in_ep\n");
if (usb_ep_enable(dev->out_ep, dev->out)) if (usb_ep_enable(dev->out_ep))
DBG(dev, "Failed to enable USB out_ep\n"); DBG(dev, "Failed to enable USB out_ep\n");
wake_up_interruptible(&dev->rx_wait); wake_up_interruptible(&dev->rx_wait);
......
...@@ -693,8 +693,8 @@ static int eth_stop(struct net_device *net) ...@@ -693,8 +693,8 @@ static int eth_stop(struct net_device *net)
usb_ep_disable(link->out_ep); usb_ep_disable(link->out_ep);
if (netif_carrier_ok(net)) { if (netif_carrier_ok(net)) {
DBG(dev, "host still using in/out endpoints\n"); DBG(dev, "host still using in/out endpoints\n");
usb_ep_enable(link->in_ep, link->in); usb_ep_enable(link->in_ep);
usb_ep_enable(link->out_ep, link->out); usb_ep_enable(link->out_ep);
} }
} }
spin_unlock_irqrestore(&dev->lock, flags); spin_unlock_irqrestore(&dev->lock, flags);
...@@ -871,7 +871,7 @@ struct net_device *gether_connect(struct gether *link) ...@@ -871,7 +871,7 @@ struct net_device *gether_connect(struct gether *link)
return ERR_PTR(-EINVAL); return ERR_PTR(-EINVAL);
link->in_ep->driver_data = dev; link->in_ep->driver_data = dev;
result = usb_ep_enable(link->in_ep, link->in); result = usb_ep_enable(link->in_ep);
if (result != 0) { if (result != 0) {
DBG(dev, "enable %s --> %d\n", DBG(dev, "enable %s --> %d\n",
link->in_ep->name, result); link->in_ep->name, result);
...@@ -879,7 +879,7 @@ struct net_device *gether_connect(struct gether *link) ...@@ -879,7 +879,7 @@ struct net_device *gether_connect(struct gether *link)
} }
link->out_ep->driver_data = dev; link->out_ep->driver_data = dev;
result = usb_ep_enable(link->out_ep, link->out); result = usb_ep_enable(link->out_ep);
if (result != 0) { if (result != 0) {
DBG(dev, "enable %s --> %d\n", DBG(dev, "enable %s --> %d\n",
link->out_ep->name, result); link->out_ep->name, result);
...@@ -969,7 +969,7 @@ void gether_disconnect(struct gether *link) ...@@ -969,7 +969,7 @@ void gether_disconnect(struct gether *link)
} }
spin_unlock(&dev->req_lock); spin_unlock(&dev->req_lock);
link->in_ep->driver_data = NULL; link->in_ep->driver_data = NULL;
link->in = NULL; link->in_ep->desc = NULL;
usb_ep_disable(link->out_ep); usb_ep_disable(link->out_ep);
spin_lock(&dev->req_lock); spin_lock(&dev->req_lock);
...@@ -984,7 +984,7 @@ void gether_disconnect(struct gether *link) ...@@ -984,7 +984,7 @@ void gether_disconnect(struct gether *link)
} }
spin_unlock(&dev->req_lock); spin_unlock(&dev->req_lock);
link->out_ep->driver_data = NULL; link->out_ep->driver_data = NULL;
link->out = NULL; link->out_ep->desc = NULL;
/* finish forgetting about this USB link episode */ /* finish forgetting about this USB link episode */
dev->header_len = 0; dev->header_len = 0;
......
...@@ -52,10 +52,6 @@ struct gether { ...@@ -52,10 +52,6 @@ struct gether {
struct usb_ep *in_ep; struct usb_ep *in_ep;
struct usb_ep *out_ep; struct usb_ep *out_ep;
/* descriptors match device speed at gether_connect() time */
struct usb_endpoint_descriptor *in;
struct usb_endpoint_descriptor *out;
bool is_zlp_ok; bool is_zlp_ok;
u16 cdc_filter; u16 cdc_filter;
......
...@@ -1247,12 +1247,12 @@ int gserial_connect(struct gserial *gser, u8 port_num) ...@@ -1247,12 +1247,12 @@ int gserial_connect(struct gserial *gser, u8 port_num)
port = ports[port_num].port; port = ports[port_num].port;
/* activate the endpoints */ /* activate the endpoints */
status = usb_ep_enable(gser->in, gser->in_desc); status = usb_ep_enable(gser->in);
if (status < 0) if (status < 0)
return status; return status;
gser->in->driver_data = port; gser->in->driver_data = port;
status = usb_ep_enable(gser->out, gser->out_desc); status = usb_ep_enable(gser->out);
if (status < 0) if (status < 0)
goto fail_out; goto fail_out;
gser->out->driver_data = port; gser->out->driver_data = port;
......
...@@ -35,8 +35,6 @@ struct gserial { ...@@ -35,8 +35,6 @@ struct gserial {
struct usb_ep *in; struct usb_ep *in;
struct usb_ep *out; struct usb_ep *out;
struct usb_endpoint_descriptor *in_desc;
struct usb_endpoint_descriptor *out_desc;
/* REVISIT avoid this CDC-ACM support harder ... */ /* REVISIT avoid this CDC-ACM support harder ... */
struct usb_cdc_line_coding port_line_coding; /* 9600-8-N-1 etc */ struct usb_cdc_line_coding port_line_coding; /* 9600-8-N-1 etc */
......
...@@ -132,8 +132,9 @@ struct usb_ep_ops { ...@@ -132,8 +132,9 @@ struct usb_ep_ops {
* @maxpacket:The maximum packet size used on this endpoint. The initial * @maxpacket:The maximum packet size used on this endpoint. The initial
* value can sometimes be reduced (hardware allowing), according to * value can sometimes be reduced (hardware allowing), according to
* the endpoint descriptor used to configure the endpoint. * the endpoint descriptor used to configure the endpoint.
* @driver_data:for use by the gadget driver. all other fields are * @driver_data:for use by the gadget driver.
* read-only to gadget drivers. * @desc: endpoint descriptor. This pointer is set before the endpoint is
* enabled and remains valid until the endpoint is disabled.
* *
* the bus controller driver lists all the general purpose endpoints in * the bus controller driver lists all the general purpose endpoints in
* gadget->ep_list. the control endpoint (gadget->ep0) is not in that list, * gadget->ep_list. the control endpoint (gadget->ep0) is not in that list,
...@@ -146,6 +147,7 @@ struct usb_ep { ...@@ -146,6 +147,7 @@ struct usb_ep {
const struct usb_ep_ops *ops; const struct usb_ep_ops *ops;
struct list_head ep_list; struct list_head ep_list;
unsigned maxpacket:16; unsigned maxpacket:16;
const struct usb_endpoint_descriptor *desc;
}; };
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
...@@ -154,11 +156,8 @@ struct usb_ep { ...@@ -154,11 +156,8 @@ struct usb_ep {
* usb_ep_enable - configure endpoint, making it usable * usb_ep_enable - configure endpoint, making it usable
* @ep:the endpoint being configured. may not be the endpoint named "ep0". * @ep:the endpoint being configured. may not be the endpoint named "ep0".
* drivers discover endpoints through the ep_list of a usb_gadget. * drivers discover endpoints through the ep_list of a usb_gadget.
* @desc:descriptor for desired behavior. caller guarantees this pointer
* remains valid until the endpoint is disabled; the data byte order
* is little-endian (usb-standard).
* *
* when configurations are set, or when interface settings change, the driver * When configurations are set, or when interface settings change, the driver
* will enable or disable the relevant endpoints. while it is enabled, an * will enable or disable the relevant endpoints. while it is enabled, an
* endpoint may be used for i/o until the driver receives a disconnect() from * endpoint may be used for i/o until the driver receives a disconnect() from
* the host or until the endpoint is disabled. * the host or until the endpoint is disabled.
...@@ -173,10 +172,9 @@ struct usb_ep { ...@@ -173,10 +172,9 @@ struct usb_ep {
* *
* returns zero, or a negative error code. * returns zero, or a negative error code.
*/ */
static inline int usb_ep_enable(struct usb_ep *ep, static inline int usb_ep_enable(struct usb_ep *ep)
const struct usb_endpoint_descriptor *desc)
{ {
return ep->ops->enable(ep, desc); return ep->ops->enable(ep, ep->desc);
} }
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment