From 071a507d44c3d3b1e112f67ff5a63d15014b4f12 Mon Sep 17 00:00:00 2001 From: Benjamin Tissoires Date: Fri, 6 Nov 2015 18:24:14 +0100 Subject: [PATCH] hidpp20: replace manual BE feeding by the helpers Signed-off-by: Benjamin Tissoires --- src/hidpp20.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/hidpp20.c b/src/hidpp20.c index 76136694..f26d2c6e 100644 --- a/src/hidpp20.c +++ b/src/hidpp20.c @@ -210,10 +210,10 @@ hidpp_root_get_feature(struct hidpp20_device *device, .msg.device_idx = device->index, .msg.sub_id = HIDPP_PAGE_ROOT_IDX, .msg.address = CMD_ROOT_GET_FEATURE, - .msg.parameters[0] = feature >> 8, - .msg.parameters[1] = feature & 0xff, }; + hidpp_set_unaligned_be_u16(&msg.msg.parameters[0], feature); + rc = hidpp20_request_command(device, &msg); if (rc) return rc; @@ -568,10 +568,10 @@ hidpp20_special_keys_buttons_get_reporting(struct hidpp20_device *device, .msg.device_idx = device->index, .msg.sub_id = reg, .msg.address = CMD_SPECIAL_KEYS_BUTTONS_GET_REPORTING, - .msg.parameters[0] = control->control_id >> 8, - .msg.parameters[1] = control->control_id & 0xff, }; + hidpp_set_unaligned_be_u16(&msg.msg.parameters[0], control->control_id); + rc = hidpp20_request_command(device, &msg); if (rc) return rc; @@ -662,13 +662,11 @@ hidpp20_special_key_mouse_set_control(struct hidpp20_device *device, .msg.report_id = REPORT_ID_LONG, .msg.device_idx = device->index, .msg.address = CMD_SPECIAL_KEYS_BUTTONS_SET_REPORTING, - .msg.parameters[0] = control->control_id >> 8, - .msg.parameters[1] = control->control_id & 0xff, - .msg.parameters[2] = 0x00, - .msg.parameters[3] = control->reporting.remapped >> 8, - .msg.parameters[4] = control->reporting.remapped & 0xff, }; + hidpp_set_unaligned_be_u16(&msg.msg.parameters[0], control->control_id); + hidpp_set_unaligned_be_u16(&msg.msg.parameters[3], control->reporting.remapped); + feature_index = hidpp_root_get_feature_idx(device, HIDPP_PAGE_SPECIAL_KEYS_BUTTONS); if (feature_index == 0) @@ -880,10 +878,10 @@ int hidpp20_adjustable_dpi_set_sensor_dpi(struct hidpp20_device *device, .msg.device_idx = device->index, .msg.address = CMD_ADJUSTABLE_DPI_SET_SENSOR_DPI, .msg.parameters[0] = sensor->index, - .msg.parameters[1] = dpi >> 8, - .msg.parameters[2] = dpi & 0xff, }; + hidpp_set_unaligned_be_u16(&msg.msg.parameters[1], dpi); + feature_index = hidpp_root_get_feature_idx(device, HIDPP_PAGE_ADJUSTABLE_DPI); if (feature_index == 0)