This reworks the way SuperSpeed descriptors are added and instead of having a magic after full and high speed descriptors, it reworks the whole descriptors block to include a flags field which lists which descriptors are present and makes future extensions possible.
Showing the changes to include/uapi/linux (1 of 3 files). Show all
Unified · Split
| @@ -10,10 +10,15 @@ · 9 unmodified lines | ||
| 10 | 10 | |
| 11 | 11 | enum { |
| 12 | 12 | FUNCTIONFS_DESCRIPTORS_MAGIC = 1, |
| 13 | − FUNCTIONFS_STRINGS_MAGIC = 2 | |
| 13 | + FUNCTIONFS_STRINGS_MAGIC = 2, | |
| 14 | + FUNCTIONFS_DESCRIPTORS_MAGIC_V2 = 3, | |
| 14 | 15 | }; |
| 15 | 16 | |
| 16 | −#define FUNCTIONFS_SS_DESC_MAGIC 0x0055DE5C | |
| 17 | +enum functionfs_flags { | |
| 18 | + FUNCTIONFS_HAS_FS_DESC = 1, | |
| 19 | + FUNCTIONFS_HAS_HS_DESC = 2, | |
| 20 | + FUNCTIONFS_HAS_SS_DESC = 4, | |
| 21 | +}; | |
| 17 | 22 | |
| 18 | 23 | #ifndef __KERNEL__ |
| 19 | 24 | |
| @@ -29,34 +34,40 @@ struct usb_endpoint_descriptor_no_audio { · 9 unmodified lines | ||
| 29 | 34 | } __attribute__((packed)); |
| 30 | 35 | |
| 31 | 36 | |
| 32 | −/* | |
| 33 | − * All numbers must be in little endian order. | |
| 34 | − */ | |
| 35 | − | |
| 36 | −struct usb_functionfs_descs_head { | |
| 37 | − __le32 magic; | |
| 38 | − __le32 length; | |
| 39 | − __le32 fs_count; | |
| 40 | − __le32 hs_count; | |
| 41 | −} __attribute__((packed)); | |
| 42 | − | |
| 43 | 37 | /* |
| 44 | 38 | * Descriptors format: |
| 45 | 39 | * |
| 46 | 40 | * | off | name | type | description | |
| 47 | 41 | * |-----+-----------+--------------+--------------------------------------| |
| 48 | − * | 0 | magic | LE32 | FUNCTIONFS_{FS,HS}_DESCRIPTORS_MAGIC | | |
| 42 | + * | 0 | magic | LE32 | FUNCTIONFS_DESCRIPTORS_MAGIC_V2 | | |
| 43 | + * | 4 | length | LE32 | length of the whole data chunk | | |
| 44 | + * | 8 | flags | LE32 | combination of functionfs_flags | | |
| 45 | + * | | fs_count | LE32 | number of full-speed descriptors | | |
| 46 | + * | | hs_count | LE32 | number of high-speed descriptors | | |
| 47 | + * | | ss_count | LE32 | number of super-speed descriptors | | |
| 48 | + * | | fs_descrs | Descriptor[] | list of full-speed descriptors | | |
| 49 | + * | | hs_descrs | Descriptor[] | list of high-speed descriptors | | |
| 50 | + * | | ss_descrs | Descriptor[] | list of super-speed descriptors | | |
| 51 | + * | |
| 52 | + * Depending on which flags are set, various fields may be missing in the | |
| 53 | + * structure. Any flags that are not recognised cause the whole block to be | |
| 54 | + * rejected with -ENOSYS. | |
| 55 | + * | |
| 56 | + * Legacy descriptors format: | |
| 57 | + * | |
| 58 | + * | off | name | type | description | | |
| 59 | + * |-----+-----------+--------------+--------------------------------------| | |
| 60 | + * | 0 | magic | LE32 | FUNCTIONFS_DESCRIPTORS_MAGIC | | |
| 49 | 61 | * | 4 | length | LE32 | length of the whole data chunk | |
| 50 | 62 | * | 8 | fs_count | LE32 | number of full-speed descriptors | |
| 51 | 63 | * | 12 | hs_count | LE32 | number of high-speed descriptors | |
| 52 | 64 | * | 16 | fs_descrs | Descriptor[] | list of full-speed descriptors | |
| 53 | 65 | * | | hs_descrs | Descriptor[] | list of high-speed descriptors | |
| 54 | − * | | ss_magic | LE32 | FUNCTIONFS_SS_DESC_MAGIC | | |
| 55 | − * | | ss_count | LE32 | number of super-speed descriptors | | |
| 56 | − * | | ss_descrs | Descriptor[] | list of super-speed descriptors | | |
| 57 | 66 | * |
| 58 | − * ss_magic: if present then it implies that SS_DESCs are also present | |
| 59 | − * descs are just valid USB descriptors and have the following format: | |
| 67 | + * All numbers must be in little endian order. | |
| 68 | + * | |
| 69 | + * Descriptor[] is an array of valid USB descriptors which have the following | |
| 70 | + * format: | |
| 60 | 71 | * |
| 61 | 72 | * | off | name | type | description | |
| 62 | 73 | * |-----+-----------------+------+--------------------------| |