support sector size that are not multiple of 16

Signed-off-by: Ogier Bouvier <obouvier@logitech.com>

Squashed the comment into this
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
This commit is contained in:
Ogier Bouvier
2017-09-11 13:15:42 +02:00
committed by Benjamin Tissoires
parent 59df7defdb
commit 4a61dc413b

View File

@@ -1132,6 +1132,12 @@ hidpp20_onboard_profiles_read_sector(struct hidpp20_device *device,
count = sector_size;
for (offset = 0; offset < sector_size; offset += 16) {
/*
* the firmware replies with an ERR_INVALID_ARGUMENT error
* if we try to read past sector_size - 16, so when we are left with
* less than 16 bytes to read we need to read from sector_size - 16
*/
offset = (sector_size - offset < 16) ? sector_size - 16 : offset;
hidpp_set_unaligned_be_u16(&msg.msg.parameters[2], offset);
buf = msg;
rc = hidpp20_request_command(device, &buf);