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

Commit c5f8a96b authored by Sai krishna juturi's avatar Sai krishna juturi
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 avatarSai krishna juturi <jsaikrishna@codeaurora.org>
parent 9416e47b
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -1490,6 +1490,7 @@ mtp_function_bind(struct usb_configuration *c, struct usb_function *f)
			mtp_fullspeed_out_desc.bEndpointAddress;
	}

	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"),
@@ -1501,9 +1502,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)))
@@ -1517,6 +1519,7 @@ mtp_function_unbind(struct usb_configuration *c, struct usb_function *f)
	dev->is_ptp = false;
	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,
@@ -1914,7 +1917,6 @@ struct usb_function *function_alloc_mtp_ptp(struct usb_function_instance *fi,
	dev->function.setup = mtp_ctrlreq_configfs;
	dev->function.free_func = mtp_free;
	dev->is_ptp = !mtp_config;
	fi->f = &dev->function;

	mutex_init(&dev->read_mutex);
	return &dev->function;