aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/gadget/f_loopback.c
diff options
context:
space:
mode:
authorSebastian Andrzej Siewior <bigeasy@linutronix.de>2012-10-22 16:15:06 -0400
committerFelipe Balbi <balbi@ti.com>2012-10-31 09:09:44 -0400
commit10287baec761d33f0a82d84b46e37a44030350d8 (patch)
treeb769a6dddfd4ccf81a986386bf5771182d1b0c55 /drivers/usb/gadget/f_loopback.c
parent0f9df939385527049c8062a099fbfa1479fe7ce0 (diff)
usb: gadget: always update HS/SS descriptors and create a copy of them
HS and SS descriptors are staticaly created. They are updated during the bind process with the endpoint address, string id or interface numbers. After that, the descriptor chain is linked to struct usb_function which is used by composite in order to serve the GET_DESCRIPTOR requests, number of available configs and so on. There is no need to assign the HS descriptor only if the UDC supports HS speed because composite won't report those to the host if HS support has not been reached. The same reasoning is valid for SS. This patch makes sure each function updates HS/SS descriptors unconditionally and uses the newly introduced helper function to create a copy the descriptors for the speed which is supported by the UDC. While at that, also rename f->descriptors to f->fs_descriptors in order to make it more explicit what that means. Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb/gadget/f_loopback.c')
-rw-r--r--drivers/usb/gadget/f_loopback.c28
1 files changed, 13 insertions, 15 deletions
diff --git a/drivers/usb/gadget/f_loopback.c b/drivers/usb/gadget/f_loopback.c
index 7275706caeb0..bb39cb2bb3a3 100644
--- a/drivers/usb/gadget/f_loopback.c
+++ b/drivers/usb/gadget/f_loopback.c
@@ -177,6 +177,7 @@ loopback_bind(struct usb_configuration *c, struct usb_function *f)
177 struct usb_composite_dev *cdev = c->cdev; 177 struct usb_composite_dev *cdev = c->cdev;
178 struct f_loopback *loop = func_to_loop(f); 178 struct f_loopback *loop = func_to_loop(f);
179 int id; 179 int id;
180 int ret;
180 181
181 /* allocate interface ID(s) */ 182 /* allocate interface ID(s) */
182 id = usb_interface_id(c, f); 183 id = usb_interface_id(c, f);
@@ -201,22 +202,19 @@ autoconf_fail:
201 loop->out_ep->driver_data = cdev; /* claim */ 202 loop->out_ep->driver_data = cdev; /* claim */
202 203
203 /* support high speed hardware */ 204 /* support high speed hardware */
204 if (gadget_is_dualspeed(c->cdev->gadget)) { 205 hs_loop_source_desc.bEndpointAddress =
205 hs_loop_source_desc.bEndpointAddress = 206 fs_loop_source_desc.bEndpointAddress;
206 fs_loop_source_desc.bEndpointAddress; 207 hs_loop_sink_desc.bEndpointAddress = fs_loop_sink_desc.bEndpointAddress;
207 hs_loop_sink_desc.bEndpointAddress =
208 fs_loop_sink_desc.bEndpointAddress;
209 f->hs_descriptors = hs_loopback_descs;
210 }
211 208
212 /* support super speed hardware */ 209 /* support super speed hardware */
213 if (gadget_is_superspeed(c->cdev->gadget)) { 210 ss_loop_source_desc.bEndpointAddress =
214 ss_loop_source_desc.bEndpointAddress = 211 fs_loop_source_desc.bEndpointAddress;
215 fs_loop_source_desc.bEndpointAddress; 212 ss_loop_sink_desc.bEndpointAddress = fs_loop_sink_desc.bEndpointAddress;
216 ss_loop_sink_desc.bEndpointAddress = 213
217 fs_loop_sink_desc.bEndpointAddress; 214 ret = usb_assign_descriptors(f, fs_loopback_descs, hs_loopback_descs,
218 f->ss_descriptors = ss_loopback_descs; 215 ss_loopback_descs);
219 } 216 if (ret)
217 return ret;
220 218
221 DBG(cdev, "%s speed %s: IN/%s, OUT/%s\n", 219 DBG(cdev, "%s speed %s: IN/%s, OUT/%s\n",
222 (gadget_is_superspeed(c->cdev->gadget) ? "super" : 220 (gadget_is_superspeed(c->cdev->gadget) ? "super" :
@@ -228,6 +226,7 @@ autoconf_fail:
228static void 226static void
229loopback_unbind(struct usb_configuration *c, struct usb_function *f) 227loopback_unbind(struct usb_configuration *c, struct usb_function *f)
230{ 228{
229 usb_free_all_descriptors(f);
231 kfree(func_to_loop(f)); 230 kfree(func_to_loop(f));
232} 231}
233 232
@@ -379,7 +378,6 @@ static int __init loopback_bind_config(struct usb_configuration *c)
379 return -ENOMEM; 378 return -ENOMEM;
380 379
381 loop->function.name = "loopback"; 380 loop->function.name = "loopback";
382 loop->function.descriptors = fs_loopback_descs;
383 loop->function.bind = loopback_bind; 381 loop->function.bind = loopback_bind;
384 loop->function.unbind = loopback_unbind; 382 loop->function.unbind = loopback_unbind;
385 loop->function.set_alt = loopback_set_alt; 383 loop->function.set_alt = loopback_set_alt;