Commit 4f2a2b64 authored by Johan Hovold's avatar Johan Hovold Committed by Ben Hutchings

USB: io_ti: fix firmware download on big-endian machines (part 2)

commit c03890ff upstream.

A recent patch that purported to fix firmware download on big-endian
machines failed to add the corresponding sparse annotation to the
i2c-header. This was reported by the kbuild test robot.

Adding the appropriate annotation revealed another endianess bug related
to the i2c-header Size-field in a code path that is exercised when the
firmware is actually being downloaded (and not just verified and left
untouched unless older than the firmware at hand).

This patch adds the required sparse annotation to the i2c-header and
makes sure that the Size-field is sent in little-endian byte order
during firmware download also on big-endian machines.

Note that this patch is only compile-tested, but that there is no
functional change for little-endian systems.
Reported-by: default avatarkbuild test robot <fengguang.wu@intel.com>
Cc: Ludovic Drolez <ldrolez@debian.org>
Signed-off-by: default avatarJohan Hovold <jhovold@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
parent 5ddef05c
...@@ -923,7 +923,7 @@ static int build_i2c_fw_hdr(__u8 *header, struct device *dev) ...@@ -923,7 +923,7 @@ static int build_i2c_fw_hdr(__u8 *header, struct device *dev)
firmware_rec = (struct ti_i2c_firmware_rec*)i2c_header->Data; firmware_rec = (struct ti_i2c_firmware_rec*)i2c_header->Data;
i2c_header->Type = I2C_DESC_TYPE_FIRMWARE_BLANK; i2c_header->Type = I2C_DESC_TYPE_FIRMWARE_BLANK;
i2c_header->Size = (__u16)buffer_size; i2c_header->Size = cpu_to_le16(buffer_size);
i2c_header->CheckSum = cs; i2c_header->CheckSum = cs;
firmware_rec->Ver_Major = OperationalMajorVersion; firmware_rec->Ver_Major = OperationalMajorVersion;
firmware_rec->Ver_Minor = OperationalMinorVersion; firmware_rec->Ver_Minor = OperationalMinorVersion;
......
...@@ -594,7 +594,7 @@ struct edge_boot_descriptor { ...@@ -594,7 +594,7 @@ struct edge_boot_descriptor {
struct ti_i2c_desc { struct ti_i2c_desc {
__u8 Type; // Type of descriptor __u8 Type; // Type of descriptor
__u16 Size; // Size of data only not including header __le16 Size; // Size of data only not including header
__u8 CheckSum; // Checksum (8 bit sum of data only) __u8 CheckSum; // Checksum (8 bit sum of data only)
__u8 Data[0]; // Data starts here __u8 Data[0]; // Data starts here
} __attribute__((packed)); } __attribute__((packed));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment