public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] usb: gadget: don't create new string_container if already exist
@ 2014-10-28 11:33 Neil Zhang
  2014-10-28 13:10 ` Andrzej Pietrasiewicz
  0 siblings, 1 reply; 5+ messages in thread
From: Neil Zhang @ 2014-10-28 11:33 UTC (permalink / raw)
  To: linux-usb, linux-kernel; +Cc: balbi, gregkh, Neil Zhang

Don't create new usb_gadget_string_container if the current strings are
already exist in the usb_composite_dev.
Otherwise the ids_tab will overflow soon if we bind / unbind usb
functions frequently like android does.

Signed-off-by: Neil Zhang <zhangwm@marvell.com>
---
 drivers/usb/gadget/composite.c |    6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index a8c18df..6fe3c6b 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -1183,6 +1183,12 @@ struct usb_string *usb_gstrings_attach(struct usb_composite_dev *cdev,
 	if (!n_gstrings)
 		return ERR_PTR(-EINVAL);
 
+	list_for_each_entry(uc, &cdev->gstrings, list) {
+		n_gs = get_containers_gs(uc);
+		if (!strcmp(n_gs[0]->strings[0].s, sp[0]->strings[0].s))
+			return n_gs[0]->strings;
+	}
+
 	uc = copy_gadget_strings(sp, n_gstrings, n_strings);
 	if (IS_ERR(uc))
 		return ERR_CAST(uc);
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-11-05 19:07 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-28 11:33 [PATCH] usb: gadget: don't create new string_container if already exist Neil Zhang
2014-10-28 13:10 ` Andrzej Pietrasiewicz
2014-11-04 11:05   ` Neil Zhang
2014-11-04 11:29     ` Andrzej Pietrasiewicz
2014-11-05 19:08     ` Felipe Balbi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox