From d3abebf20251fb20ada4ec5148d5ed75bac2a2de Mon Sep 17 00:00:00 2001 From: Benjamin Tissoires Date: Wed, 14 Oct 2015 16:51:19 -0400 Subject: [PATCH] hidpp20: change hidpp20_onboard_profiles_read_memory API It looks like we can not use a section > 0xff and that the first parameter corresponds to the type of the available memory (rom or flash). Signed-off-by: Benjamin Tissoires --- src/hidpp20.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/hidpp20.c b/src/hidpp20.c index 95a3eba6..86d67f15 100644 --- a/src/hidpp20.c +++ b/src/hidpp20.c @@ -935,9 +935,10 @@ int hidpp20_adjustable_dpi_set_sensor_dpi(struct hidpp20_device *device, static int hidpp20_onboard_profiles_read_memory(struct hidpp20_device *device, - uint16_t page, - uint16_t section, - uint8_t *result) + uint8_t read_rom, + uint8_t page, + uint8_t section, + uint8_t result[16]) { uint8_t feature_index; int rc; @@ -945,12 +946,15 @@ hidpp20_onboard_profiles_read_memory(struct hidpp20_device *device, .msg.report_id = REPORT_ID_LONG, .msg.device_idx = device->index, .msg.address = CMD_ONBOARD_PROFILES_MEMORY_READ, - .msg.parameters[0] = page >> 8, - .msg.parameters[1] = page & 0xFF, - .msg.parameters[2] = section >> 8, - .msg.parameters[3] = section & 0xFF, + .msg.parameters[0] = read_rom, + .msg.parameters[1] = page, + .msg.parameters[2] = 0, + .msg.parameters[3] = section, }; + if (read_rom > 1) + return -EINVAL; + feature_index = hidpp_root_get_feature_idx(device, HIDPP_PAGE_ONBOARD_PROFILES); if (feature_index == 0) @@ -1037,8 +1041,9 @@ hidpp20_onboard_profiles_allocate(struct hidpp20_device *device, unsigned profile_count = 0; rc = hidpp20_onboard_profiles_read_memory(device, - 0x0000, - 0x0000, + 0x00, + 0x00, + 0x00, data); if (rc < 0) return rc; @@ -1079,6 +1084,7 @@ int hidpp20_onboard_profiles_read(struct hidpp20_device *device, for (i = 0; i < HIDPP20_PROFILE_SIZE / 0x10; i++) { rc = hidpp20_onboard_profiles_read_memory(device, + 0, index + 1, i * 0x10, data + i * 0x10);