diff options
| author | Witold Sciuk <witold.sciuk@intel.com> | 2016-02-13 11:08:37 +0100 |
|---|---|---|
| committer | Badhri Jagan Sridharan <badhri@google.com> | 2017-05-03 17:59:57 +0000 |
| commit | 69a14c17de7edbaa354d56bbd25718a6e2cd6089 (patch) | |
| tree | 0629093e6e37d426a2ba293e263cc1ba849c17f9 /drivers/usb/gadget/function | |
| parent | 24ac44dc5c56770e9dbaa9024cb957a000b6c1b7 (diff) | |
ANDROID: usb: gadget: f_mtp: Set 0xFFFFFFFF in mtp header ContainerLength field
Value 0xFFFFFFFF should be set according specification
of MTP for large files when fileSize + mtpHeader is greater
than 0xFFFFFFFF.
MTP Specification, Appendix H - USB Optimizations
Patchset: mtp
Change-Id: I6213de052914350be2f87b73f8135f9c0cd05d7c
Signed-off-by: Witold Sciuk <witold.sciuk@intel.com>
Signed-off-by: Konrad Leszczynski <konrad.leszczynski@intel.com>
Signed-off-by: Russ Weight <russell.h.weight@intel.com>
Diffstat (limited to 'drivers/usb/gadget/function')
| -rw-r--r-- | drivers/usb/gadget/function/f_mtp.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/drivers/usb/gadget/function/f_mtp.c b/drivers/usb/gadget/function/f_mtp.c index b37cc8d87ca4..0fa79b0c26ab 100644 --- a/drivers/usb/gadget/function/f_mtp.c +++ b/drivers/usb/gadget/function/f_mtp.c @@ -43,6 +43,7 @@ #define MTP_BULK_BUFFER_SIZE 16384 #define INTR_BUFFER_SIZE 28 #define MAX_INST_NAME_LEN 40 +#define MTP_MAX_FILE_SIZE 0xFFFFFFFFL /* String IDs */ #define INTERFACE_STRING_INDEX 0 @@ -766,7 +767,12 @@ static void send_file_work(struct work_struct *data) if (hdr_size) { /* prepend MTP data header */ header = (struct mtp_data_header *)req->buf; - header->length = __cpu_to_le32(count); + /* + * set file size with header according to + * MTP Specification v1.0 + */ + header->length = (count > MTP_MAX_FILE_SIZE) ? + MTP_MAX_FILE_SIZE : __cpu_to_le32(count); header->type = __cpu_to_le16(2); /* data packet */ header->command = __cpu_to_le16(dev->xfer_command); header->transaction_id = |
