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

Commit 83a3c58f authored by Pratham Pratap's avatar Pratham Pratap Committed by Mayank Rana
Browse files

usb: gadget: f_mtp: Handle OS descriptors properly



The mtp_ctrl_request function is responding to every os
descriptor sent by host,There by enumerating the device
with mtp composition. Once mtp is disabled, need to clear
the function instances on unbind.

Change-Id: I6679a1c1009df291a85ba8dcc34997d757c320b9
Signed-off-by: default avatarPratham Pratap <prathampratap@codeaurora.org>
parent d3b9791e
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -1235,6 +1235,7 @@ mtp_function_bind(struct usb_configuration *c, struct usb_function *f)
		mtp_ss_out_comp_desc.bMaxBurst = max_burst;
	}

	fi_mtp->func_inst.f = &dev->function;
	DBG(cdev, "%s speed %s: IN/%s, OUT/%s\n",
		gadget_is_superspeed(c->cdev->gadget) ? "super" :
		(gadget_is_dualspeed(c->cdev->gadget) ? "dual" : "full"),
@@ -1246,9 +1247,10 @@ static void
mtp_function_unbind(struct usb_configuration *c, struct usb_function *f)
{
	struct mtp_dev	*dev = func_to_mtp(f);
	struct mtp_instance *fi_mtp;
	struct usb_request *req;
	int i;

	fi_mtp = container_of(f->fi, struct mtp_instance, func_inst);
	mtp_string_defs[INTERFACE_STRING_INDEX].id = 0;
	while ((req = mtp_req_get(dev, &dev->tx_idle)))
		mtp_request_free(req, dev->ep_in);
@@ -1259,6 +1261,7 @@ mtp_function_unbind(struct usb_configuration *c, struct usb_function *f)
	dev->state = STATE_OFFLINE;
	kfree(f->os_desc_table);
	f->os_desc_n = 0;
	fi_mtp->func_inst.f = NULL;
}

static int mtp_function_set_alt(struct usb_function *f,