Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6aee52f7 authored by ChandanaKishori Chiluveru's avatar ChandanaKishori Chiluveru
Browse files

usb: gadget: Ignore the second set_config from the host



Some USB hosts may send SET_CONFIGURATION with same value twice.
The current code implementation of android_work() issues disconnect
event to userspace if SetConfiguration with non-zero value is sent
twice. The Userspace application may disconnect USB and it causes
fail to connect to the USB host.

Fix this by ignoring the second time SET_CONFIGURATION request
from the host only for the same configuration value twice.

CRs-Fixed: 661220
Change-Id: Iec8dd7824fa9f371ea147784cf9137aa88a7128e
Signed-off-by: default avatarChandanaKishori Chiluveru <cchilu@codeaurora.org>
parent 3bb9501c
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -610,6 +610,16 @@ static int set_config(struct usb_composite_dev *cdev,
	unsigned		power = gadget_is_otg(gadget) ? 8 : 100;
	int			tmp;

	/*
	 * ignore 2nd time SET_CONFIGURATION
	 * only for same config value twice.
	 */
	if (cdev->config && (cdev->config->bConfigurationValue == number)) {
		DBG(cdev, "already in the same config with value %d\n",
				number);
		return 0;
	}

	if (number) {
		list_for_each_entry(c, &cdev->configs, list) {
			if (c->bConfigurationValue == number) {