]> rtime.felk.cvut.cz Git - sojka/nv-tegra/linux-3.10.git/commit
usb: free up composite gadget string ids on unbind
authorRakesh Bodla <rbodla@nvidia.com>
Thu, 5 Jun 2014 06:31:12 +0000 (12:01 +0530)
committerTodd Poynter <tpoynter@nvidia.com>
Thu, 19 Jun 2014 19:10:34 +0000 (12:10 -0700)
commitfc71534a90787bd763b7bd0f7c698b76b66ad251
treebf8d4537f5c2c68471a8bd3e235facb0486171c7
parent0bcd7d28167e7553859680449d66d8c1819a1d7d
usb: free up composite gadget string ids on unbind

There are only 254 USB composite gadget string_ids available.
When switching gadget mode such as mtp and acm repeatedly,
they will be exhausted.

This bug has been brought up since android composite driver
introduced a way to switch gadget modes while the composite
driver is still holding its bind.

Fix this by reset next_string_id and clean up gstrings when
android gadgets are disabled. Also by removing the condition
comparing gadgets' string id to 0 because gadget string id
has to be re-assigned whenever the string count is reset.

The codes removed the condition check will work as the same
as before they have changed if the gadgets are used by other
composite drivers other than android since all of them call
bind only once and never unbind it hence no side effects considered.

Ported from https://android-review.googlesource.com/#/c/95366/

Bug 200001941

Change-Id: I1e2fbe0f59fe05b89052db62e0b61b074d8f032b
Signed-off-by: Rakesh Bodla <rbodla@nvidia.com>
Reviewed-on: http://git-master/r/425165
Reviewed-by: Mitch Luban <mluban@nvidia.com>
drivers/usb/gadget/android.c
drivers/usb/gadget/f_accessory.c
drivers/usb/gadget/f_mass_storage.c
drivers/usb/gadget/f_mtp.c
drivers/usb/gadget/f_rndis.c