Revert "usb: f_mtp: Don't handle OS descriptors from MTP driver"

Breaks MTP on Windows.

This reverts commit 5d93fbb51b.

Change-Id: Ifbfee3e9911e9dfdff21f11ec73fde715adb1ab6
This commit is contained in:
Edwin Moquete 2023-01-01 19:23:23 +00:00 committed by Michael Bestas
parent d230856d41
commit 96619acd03
No known key found for this signature in database
GPG key ID: CC95044519BE6669

View file

@ -354,6 +354,20 @@ struct mtp_ext_config_desc {
struct mtp_ext_config_desc_function function;
};
static struct mtp_ext_config_desc mtp_ext_config_desc = {
.header = {
.dwLength = __constant_cpu_to_le32(sizeof(mtp_ext_config_desc)),
.bcdVersion = __constant_cpu_to_le16(0x0100),
.wIndex = __constant_cpu_to_le16(4),
.bCount = 1,
},
.function = {
.bFirstInterfaceNumber = 0,
.bInterfaceCount = 1,
.compatibleID = { 'M', 'T', 'P' },
},
};
struct mtp_device_status {
__le16 wLength;
__le16 wCode;
@ -1324,7 +1338,20 @@ static int mtp_ctrlrequest(struct usb_composite_dev *cdev,
mtp_log("vendor request: %d index: %d value: %d length: %d\n",
ctrl->bRequest, w_index, w_value, w_length);
value = -EOPNOTSUPP;
if (ctrl->bRequest == 1
&& (ctrl->bRequestType & USB_DIR_IN)
&& (w_index == 4 || w_index == 5)) {
value = (w_length < sizeof(mtp_ext_config_desc) ?
w_length : sizeof(mtp_ext_config_desc));
memcpy(cdev->req->buf, &mtp_ext_config_desc, value);
/* update compatibleID if PTP */
if (dev->function.fs_descriptors == fs_ptp_descs) {
struct mtp_ext_config_desc *d = cdev->req->buf;
d->function.compatibleID[0] = 'P';
}
}
} else if ((ctrl->bRequestType & USB_TYPE_MASK) == USB_TYPE_CLASS) {
mtp_log("class request: %d index: %d value: %d length: %d\n",
ctrl->bRequest, w_index, w_value, w_length);
@ -1803,10 +1830,6 @@ struct usb_function_instance *alloc_inst_mtp_ptp(bool mtp_config)
return ERR_PTR(-ENOMEM);
fi_mtp->func_inst.set_inst_name = mtp_set_inst_name;
fi_mtp->func_inst.free_func_inst = mtp_free_inst;
if (mtp_config)
memcpy(fi_mtp->mtp_ext_compat_id, "MTP", 3);
else
memcpy(fi_mtp->mtp_ext_compat_id, "PTP", 3);
fi_mtp->mtp_os_desc.ext_compat_id = fi_mtp->mtp_ext_compat_id;
INIT_LIST_HEAD(&fi_mtp->mtp_os_desc.ext_prop);