Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c49f51c4 authored by Christopher Ferris's avatar Christopher Ferris
Browse files

Fix the v2 descriptor handling.

There was a misinterpretation of how the v2 header works. The flags
in the header indicate what is in the rest of the structure.

Bug: 19127803

Change-Id: I5fa0dae6da51522c9afc4c94838eb6f462208683
parent 4e0bdd10
Loading
Loading
Loading
Loading
+6 −11
Original line number Diff line number Diff line
@@ -73,14 +73,10 @@ struct desc_v1 {
} __attribute__((packed));

struct desc_v2 {
    struct usb_functionfs_descs_head_v2 {
        __le32 magic;
        __le32 length;
        __le32 flags;
    struct usb_functionfs_descs_head_v2 header;
    // The rest of the structure depends on the flags in the header.
    __le32 fs_count;
    __le32 hs_count;
        __le32 ss_count;
    } __attribute__((packed)) header;
    struct func_desc fs_descs, hs_descs;
} __attribute__((packed));

@@ -284,9 +280,8 @@ static void init_functionfs(struct usb_handle *h)
    v2_descriptor.header.magic = cpu_to_le32(FUNCTIONFS_DESCRIPTORS_MAGIC_V2);
    v2_descriptor.header.length = cpu_to_le32(sizeof(v2_descriptor));
    v2_descriptor.header.flags = FUNCTIONFS_HAS_FS_DESC | FUNCTIONFS_HAS_HS_DESC;
    v2_descriptor.header.fs_count = 3;
    v2_descriptor.header.hs_count = 3;
    v2_descriptor.header.ss_count = 0;
    v2_descriptor.fs_count = 3;
    v2_descriptor.hs_count = 3;
    v2_descriptor.fs_descs = fs_descriptors;
    v2_descriptor.hs_descs = hs_descriptors;

+6 −11
Original line number Diff line number Diff line
@@ -87,14 +87,10 @@ struct desc_v1 {
} __attribute__((packed));

struct desc_v2 {
    struct usb_functionfs_descs_head_v2 {
        __le32 magic;
        __le32 length;
        __le32 flags;
    struct usb_functionfs_descs_head_v2 header;
    // The rest of the structure depends on the flags in the header.
    __le32 fs_count;
    __le32 hs_count;
        __le32 ss_count;
    } __attribute__((packed)) header;
    struct func_desc fs_descs, hs_descs;
} __attribute__((packed));

@@ -182,9 +178,8 @@ static int init_functionfs(struct usb_transport *usb_transport)
    v2_descriptor.header.magic = cpu_to_le32(FUNCTIONFS_DESCRIPTORS_MAGIC_V2);
    v2_descriptor.header.length = cpu_to_le32(sizeof(v2_descriptor));
    v2_descriptor.header.flags = FUNCTIONFS_HAS_FS_DESC | FUNCTIONFS_HAS_HS_DESC;
    v2_descriptor.header.fs_count = 3;
    v2_descriptor.header.hs_count = 3;
    v2_descriptor.header.ss_count = 0;
    v2_descriptor.fs_count = 3;
    v2_descriptor.hs_count = 3;
    v2_descriptor.fs_descs = fs_descriptors;
    v2_descriptor.hs_descs = hs_descriptors;