From: Antonio Ospite Date: Fri, 26 Jun 2015 08:25:26 +0000 (+0200) Subject: am7xxx-modeswitch: fix the Length field in the switch command X-Git-Tag: v0.1.6~11 X-Git-Url: https://git.ao2.it/libam7xxx.git/commitdiff_plain/109d788a6a63bb604a2c72dd101bc9e58885b1f2 am7xxx-modeswitch: fix the Length field in the switch command The switch_command is a USB storage message, the bulk_cb_wrap structure from include/linux/usb/storage.h in the Linux kernel shows the fields meanings: struct bulk_cb_wrap { __le32 Signature; /* contains 'USBC' */ __u32 Tag; /* unique per command id */ __le32 DataTransferLength; /* size of data */ __u8 Flags; /* direction in bit 0 */ __u8 Lun; /* LUN normally 0 */ __u8 Length; /* length of the CDB */ __u8 CDB[16]; /* max command */ }; In switch_command the data in CDB is 16 bytes long (0x10), so using 0x0c was wrong, it worked on some devices but it did not on others. Use the correct value. Thanks-to: Balasubramanian S --- diff --git a/examples/am7xxx-modeswitch.c b/examples/am7xxx-modeswitch.c index 2764ab2..62db796 100644 --- a/examples/am7xxx-modeswitch.c +++ b/examples/am7xxx-modeswitch.c @@ -29,7 +29,7 @@ static unsigned char switch_command[] = "\x55\x53\x42\x43\x08\x70\x52\x89\x00\x00\x00\x00\x00\x00" - "\x0c\xff\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"; + "\x10\xff\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"; int main(void) {