Skip to content

Commit 678cbaa

Browse files
EvenxfJiri Kosina
authored andcommitted
HID: Intel-thc-hid: Intel-quicki2c: Use put_unaligned_le16 for __le16 writes
Replace memcpy operations with put_unaligned_le16() when writing 16-bit little-endian values to the write buffer. This change improves code clarity and ensures proper handling of unaligned memory access. Signed-off-by: Even Xu <even.xu@intel.com> Signed-off-by: Jiri Kosina <jkosina@suse.com>
1 parent dabc153 commit 678cbaa

1 file changed

Lines changed: 1 addition & 3 deletions

File tree

drivers/hid/intel-thc-hid/intel-quicki2c/quicki2c-protocol.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,7 @@ static ssize_t quicki2c_init_write_buf(struct quicki2c_device *qcdev, u32 cmd, s
4141
}
4242

4343
if (data && data_len) {
44-
__le16 len = cpu_to_le16(data_len + HIDI2C_LENGTH_LEN);
45-
46-
memcpy(write_buf + offset, &len, HIDI2C_LENGTH_LEN);
44+
put_unaligned_le16(data_len + HIDI2C_LENGTH_LEN, write_buf + offset);
4745
offset += HIDI2C_LENGTH_LEN;
4846
memcpy(write_buf + offset, data, data_len);
4947
}

0 commit comments

Comments
 (0)