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

Commit d88fbcd8 authored by Pratham Pratap's avatar Pratham Pratap Committed by Gerrit - the friendly Code Review server
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 c1c8fe5e
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -1464,6 +1464,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"),
@@ -1475,9 +1476,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;
	mutex_lock(&dev->read_mutex);
	while ((req = mtp_req_get(dev, &dev->tx_idle)))
@@ -1490,6 +1492,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,