1
0
forked from drath/libratbag

hidpp10: read_memory should take offset in bytes

The current API takes offset in 2-byte values. Taking a byte value
is more natural. We need to upgrade the type of offset to uint16_t
to handle values > 256.
This commit is contained in:
Thomas Hindoe Paaboel Andersen
2015-10-18 13:09:08 +02:00
parent 3b3b9ce0a2
commit 7e5f77f402
2 changed files with 9 additions and 4 deletions

View File

@@ -541,7 +541,7 @@ hidpp10_get_profile(struct hidpp10_device *dev, int8_t number, struct hidpp10_pr
for (i = 0; i < sizeof(data); i += 16) {
/* each sector contains 16 bytes of data */
res = hidpp10_read_memory(dev, number, i / 2, &data.data[i]);
res = hidpp10_read_memory(dev, number, i, &data.data[i]);
if (res)
return res;
}
@@ -1011,13 +1011,18 @@ hidpp10_set_usb_refresh_rate(struct hidpp10_device *dev,
}
int
hidpp10_read_memory(struct hidpp10_device *dev, uint8_t page, uint8_t offset,
hidpp10_read_memory(struct hidpp10_device *dev, uint8_t page, uint16_t offset,
uint8_t bytes[16])
{
unsigned idx = dev->index;
union hidpp10_message readmem = CMD_READ_MEMORY(idx, page, offset);
union hidpp10_message readmem = CMD_READ_MEMORY(idx, page, offset / 2);
int res;
if (offset % 2 != 0) {
hidpp_log_error(&dev->base, "Reading memory with odd offset is not supported.\n");
return -EINVAL;
}
if (page > 31)
return -EINVAL;

View File

@@ -462,7 +462,7 @@ hidpp10_set_usb_refresh_rate(struct hidpp10_device *dev,
int
hidpp10_read_memory(struct hidpp10_device *dev,
uint8_t page,
uint8_t offset,
uint16_t offset,
uint8_t bytes[16]);
/* -------------------------------------------------------------------------- */