diff options
author | Sebastian Andrzej Siewior <bigeasy@linutronix.de> | 2012-10-22 16:15:06 -0400 |
---|---|---|
committer | Felipe Balbi <balbi@ti.com> | 2012-10-31 09:09:44 -0400 |
commit | 10287baec761d33f0a82d84b46e37a44030350d8 (patch) | |
tree | b769a6dddfd4ccf81a986386bf5771182d1b0c55 /drivers/usb/gadget/f_ncm.c | |
parent | 0f9df939385527049c8062a099fbfa1479fe7ce0 (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_ncm.c')
-rw-r--r-- | drivers/usb/gadget/f_ncm.c | 32 |
1 files changed, 8 insertions, 24 deletions
diff --git a/drivers/usb/gadget/f_ncm.c b/drivers/usb/gadget/f_ncm.c index 424fc3d1cc36..326d7e6c297c 100644 --- a/drivers/usb/gadget/f_ncm.c +++ b/drivers/usb/gadget/f_ncm.c | |||
@@ -1208,30 +1208,18 @@ ncm_bind(struct usb_configuration *c, struct usb_function *f) | |||
1208 | ncm->notify_req->context = ncm; | 1208 | ncm->notify_req->context = ncm; |
1209 | ncm->notify_req->complete = ncm_notify_complete; | 1209 | ncm->notify_req->complete = ncm_notify_complete; |
1210 | 1210 | ||
1211 | /* copy descriptors, and track endpoint copies */ | ||
1212 | f->descriptors = usb_copy_descriptors(ncm_fs_function); | ||
1213 | if (!f->descriptors) | ||
1214 | goto fail; | ||
1215 | |||
1216 | /* | 1211 | /* |
1217 | * support all relevant hardware speeds... we expect that when | 1212 | * support all relevant hardware speeds... we expect that when |
1218 | * hardware is dual speed, all bulk-capable endpoints work at | 1213 | * hardware is dual speed, all bulk-capable endpoints work at |
1219 | * both speeds | 1214 | * both speeds |
1220 | */ | 1215 | */ |
1221 | if (gadget_is_dualspeed(c->cdev->gadget)) { | 1216 | hs_ncm_in_desc.bEndpointAddress = fs_ncm_in_desc.bEndpointAddress; |
1222 | hs_ncm_in_desc.bEndpointAddress = | 1217 | hs_ncm_out_desc.bEndpointAddress = fs_ncm_out_desc.bEndpointAddress; |
1223 | fs_ncm_in_desc.bEndpointAddress; | 1218 | hs_ncm_notify_desc.bEndpointAddress = |
1224 | hs_ncm_out_desc.bEndpointAddress = | 1219 | fs_ncm_notify_desc.bEndpointAddress; |
1225 | fs_ncm_out_desc.bEndpointAddress; | ||
1226 | hs_ncm_notify_desc.bEndpointAddress = | ||
1227 | fs_ncm_notify_desc.bEndpointAddress; | ||
1228 | |||
1229 | /* copy descriptors, and track endpoint copies */ | ||
1230 | f->hs_descriptors = usb_copy_descriptors(ncm_hs_function); | ||
1231 | if (!f->hs_descriptors) | ||
1232 | goto fail; | ||
1233 | } | ||
1234 | 1220 | ||
1221 | status = usb_assign_descriptors(f, ncm_fs_function, ncm_hs_function, | ||
1222 | NULL); | ||
1235 | /* | 1223 | /* |
1236 | * NOTE: all that is done without knowing or caring about | 1224 | * NOTE: all that is done without knowing or caring about |
1237 | * the network link ... which is unavailable to this code | 1225 | * the network link ... which is unavailable to this code |
@@ -1248,9 +1236,7 @@ ncm_bind(struct usb_configuration *c, struct usb_function *f) | |||
1248 | return 0; | 1236 | return 0; |
1249 | 1237 | ||
1250 | fail: | 1238 | fail: |
1251 | if (f->descriptors) | 1239 | usb_free_all_descriptors(f); |
1252 | usb_free_descriptors(f->descriptors); | ||
1253 | |||
1254 | if (ncm->notify_req) { | 1240 | if (ncm->notify_req) { |
1255 | kfree(ncm->notify_req->buf); | 1241 | kfree(ncm->notify_req->buf); |
1256 | usb_ep_free_request(ncm->notify, ncm->notify_req); | 1242 | usb_ep_free_request(ncm->notify, ncm->notify_req); |
@@ -1276,9 +1262,7 @@ ncm_unbind(struct usb_configuration *c, struct usb_function *f) | |||
1276 | 1262 | ||
1277 | DBG(c->cdev, "ncm unbind\n"); | 1263 | DBG(c->cdev, "ncm unbind\n"); |
1278 | 1264 | ||
1279 | if (gadget_is_dualspeed(c->cdev->gadget)) | 1265 | usb_free_all_descriptors(f); |
1280 | usb_free_descriptors(f->hs_descriptors); | ||
1281 | usb_free_descriptors(f->descriptors); | ||
1282 | 1266 | ||
1283 | kfree(ncm->notify_req->buf); | 1267 | kfree(ncm->notify_req->buf); |
1284 | usb_ep_free_request(ncm->notify, ncm->notify_req); | 1268 | usb_ep_free_request(ncm->notify, ncm->notify_req); |