Loading drivers/usb/gadget/function/f_mtp.c +36 −5 Original line number Diff line number Diff line Loading @@ -134,6 +134,7 @@ struct mtp_dev { } perf[MAX_ITERATION]; unsigned dbg_read_index; unsigned dbg_write_index; bool is_ptp; }; static struct usb_interface_descriptor mtp_interface_desc = { Loading Loading @@ -340,10 +341,12 @@ struct mtp_ext_config_desc_function { }; /* MTP Extended Configuration Descriptor */ struct { struct ext_mtp_desc { struct mtp_ext_config_desc_header header; struct mtp_ext_config_desc_function function; } mtp_ext_config_desc = { }; struct ext_mtp_desc mtp_ext_config_desc = { .header = { .dwLength = __constant_cpu_to_le32(sizeof(mtp_ext_config_desc)), .bcdVersion = __constant_cpu_to_le16(0x0100), Loading @@ -357,6 +360,20 @@ struct { }, }; struct ext_mtp_desc ptp_ext_config_desc = { .header = { .dwLength = cpu_to_le32(sizeof(mtp_ext_config_desc)), .bcdVersion = cpu_to_le16(0x0100), .wIndex = cpu_to_le16(4), .bCount = cpu_to_le16(1), }, .function = { .bFirstInterfaceNumber = 0, .bInterfaceCount = 1, .compatibleID = { 'P', 'T', 'P' }, }, }; struct mtp_device_status { __le16 wLength; __le16 wCode; Loading Loading @@ -1275,9 +1292,21 @@ static int mtp_ctrlrequest(struct usb_composite_dev *cdev, 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); if (!dev->is_ptp) { value = (w_length < sizeof(mtp_ext_config_desc) ? w_length : sizeof(mtp_ext_config_desc)); memcpy(cdev->req->buf, &mtp_ext_config_desc, value); } else { value = (w_length < sizeof(ptp_ext_config_desc) ? w_length : sizeof(ptp_ext_config_desc)); memcpy(cdev->req->buf, &ptp_ext_config_desc, value); } } } else if ((ctrl->bRequestType & USB_TYPE_MASK) == USB_TYPE_CLASS) { DBG(cdev, "class request: %d index: %d value: %d length: %d\n", Loading Loading @@ -1401,6 +1430,7 @@ mtp_function_unbind(struct usb_configuration *c, struct usb_function *f) while ((req = mtp_req_get(dev, &dev->intr_idle))) mtp_request_free(req, dev->ep_intr); dev->state = STATE_OFFLINE; dev->is_ptp = false; } static int mtp_function_set_alt(struct usb_function *f, Loading Loading @@ -1507,6 +1537,7 @@ static int mtp_bind_config(struct usb_configuration *c, bool ptp_config) dev->function.set_alt = mtp_function_set_alt; dev->function.disable = mtp_function_disable; dev->is_ptp = ptp_config; return usb_add_function(c, &dev->function); } Loading Loading
drivers/usb/gadget/function/f_mtp.c +36 −5 Original line number Diff line number Diff line Loading @@ -134,6 +134,7 @@ struct mtp_dev { } perf[MAX_ITERATION]; unsigned dbg_read_index; unsigned dbg_write_index; bool is_ptp; }; static struct usb_interface_descriptor mtp_interface_desc = { Loading Loading @@ -340,10 +341,12 @@ struct mtp_ext_config_desc_function { }; /* MTP Extended Configuration Descriptor */ struct { struct ext_mtp_desc { struct mtp_ext_config_desc_header header; struct mtp_ext_config_desc_function function; } mtp_ext_config_desc = { }; struct ext_mtp_desc mtp_ext_config_desc = { .header = { .dwLength = __constant_cpu_to_le32(sizeof(mtp_ext_config_desc)), .bcdVersion = __constant_cpu_to_le16(0x0100), Loading @@ -357,6 +360,20 @@ struct { }, }; struct ext_mtp_desc ptp_ext_config_desc = { .header = { .dwLength = cpu_to_le32(sizeof(mtp_ext_config_desc)), .bcdVersion = cpu_to_le16(0x0100), .wIndex = cpu_to_le16(4), .bCount = cpu_to_le16(1), }, .function = { .bFirstInterfaceNumber = 0, .bInterfaceCount = 1, .compatibleID = { 'P', 'T', 'P' }, }, }; struct mtp_device_status { __le16 wLength; __le16 wCode; Loading Loading @@ -1275,9 +1292,21 @@ static int mtp_ctrlrequest(struct usb_composite_dev *cdev, 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); if (!dev->is_ptp) { value = (w_length < sizeof(mtp_ext_config_desc) ? w_length : sizeof(mtp_ext_config_desc)); memcpy(cdev->req->buf, &mtp_ext_config_desc, value); } else { value = (w_length < sizeof(ptp_ext_config_desc) ? w_length : sizeof(ptp_ext_config_desc)); memcpy(cdev->req->buf, &ptp_ext_config_desc, value); } } } else if ((ctrl->bRequestType & USB_TYPE_MASK) == USB_TYPE_CLASS) { DBG(cdev, "class request: %d index: %d value: %d length: %d\n", Loading Loading @@ -1401,6 +1430,7 @@ mtp_function_unbind(struct usb_configuration *c, struct usb_function *f) while ((req = mtp_req_get(dev, &dev->intr_idle))) mtp_request_free(req, dev->ep_intr); dev->state = STATE_OFFLINE; dev->is_ptp = false; } static int mtp_function_set_alt(struct usb_function *f, Loading Loading @@ -1507,6 +1537,7 @@ static int mtp_bind_config(struct usb_configuration *c, bool ptp_config) dev->function.set_alt = mtp_function_set_alt; dev->function.disable = mtp_function_disable; dev->is_ptp = ptp_config; return usb_add_function(c, &dev->function); } Loading