Skip to content

Commit

Permalink
crypto: atmel - Fix sparse endianness warnings
Browse files Browse the repository at this point in the history
The param2 member in atmel_i2c_cmd is supposed to be little-endian
but was marked as u16.  This patch changes it to a __le16 which
reveals a missing endian swap in atmel_i2c_init_read_cmd.

Another missing little-endian marking is also added in
atmel_i2c_checksum.

Fixes: 1110569 ("crypto: atmel-ecc - introduce Microchip...")
Reported-by: kbuild test robot <[email protected]>
Signed-off-by: Herbert Xu <[email protected]>
  • Loading branch information
herbertx committed Jun 6, 2019
1 parent 20a0f97 commit 49d2216
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions drivers/crypto/atmel-i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ static void atmel_i2c_checksum(struct atmel_i2c_cmd *cmd)
{
u8 *data = &cmd->count;
size_t len = cmd->count - CRC_SIZE;
u16 *__crc16 = (u16 *)(data + len);
__le16 *__crc16 = (__le16 *)(data + len);

*__crc16 = cpu_to_le16(bitrev16(crc16(0, data, len)));
}
Expand All @@ -48,7 +48,7 @@ void atmel_i2c_init_read_cmd(struct atmel_i2c_cmd *cmd)
* (UserExtra, Selector, LockValue, LockConfig).
*/
cmd->param1 = CONFIG_ZONE;
cmd->param2 = DEVICE_LOCK_ADDR;
cmd->param2 = cpu_to_le16(DEVICE_LOCK_ADDR);
cmd->count = READ_COUNT;

atmel_i2c_checksum(cmd);
Expand Down
3 changes: 2 additions & 1 deletion drivers/crypto/atmel-i2c.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#define __ATMEL_I2C_H__

#include <linux/hw_random.h>
#include <linux/types.h>

#define ATMEL_ECC_PRIORITY 300

Expand Down Expand Up @@ -50,7 +51,7 @@ struct atmel_i2c_cmd {
u8 count;
u8 opcode;
u8 param1;
u16 param2;
__le16 param2;
u8 data[MAX_RSP_SIZE];
u8 msecs;
u16 rxsize;
Expand Down

0 comments on commit 49d2216

Please sign in to comment.