Input: synaptics-rmi4 - limit the range of what GPIOs are buttons

By convention the first 6 bits of F30 Ctrl 2 and 3 are used to signify
GPIOs which are connected to buttons. Additional GPIOs may be used as
input GPIOs to signal the touch controller of some event
(ie disable touchpad). These additional GPIOs may meet the criteria of
a button in rmi_f30_is_valid_button() but should not be considered
buttons. This patch limits the GPIOs which are mapped to buttons to just
the first 6.

Signed-off-by: Andrew Duggan <aduggan@synaptics.com>
Reported-by: Daniel Martin <consume.noise@gmail.com>
Tested-by: Daniel Martin <consume.noise@gmail.com>
Acked-By: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

authored by

Andrew Duggan and committed by
Dmitry Torokhov
3e64fcbd a5082947

+3 -2
+3 -2
drivers/input/rmi4/rmi_f30.c
··· 232 unsigned int trackstick_button = BTN_LEFT; 233 bool button_mapped = false; 234 int i; 235 236 f30->gpioled_key_map = devm_kcalloc(&fn->dev, 237 - f30->gpioled_count, 238 sizeof(f30->gpioled_key_map[0]), 239 GFP_KERNEL); 240 if (!f30->gpioled_key_map) { ··· 243 return -ENOMEM; 244 } 245 246 - for (i = 0; i < f30->gpioled_count; i++) { 247 if (!rmi_f30_is_valid_button(i, f30->ctrl)) 248 continue; 249
··· 232 unsigned int trackstick_button = BTN_LEFT; 233 bool button_mapped = false; 234 int i; 235 + int button_count = min_t(u8, f30->gpioled_count, TRACKSTICK_RANGE_END); 236 237 f30->gpioled_key_map = devm_kcalloc(&fn->dev, 238 + button_count, 239 sizeof(f30->gpioled_key_map[0]), 240 GFP_KERNEL); 241 if (!f30->gpioled_key_map) { ··· 242 return -ENOMEM; 243 } 244 245 + for (i = 0; i < button_count; i++) { 246 if (!rmi_f30_is_valid_button(i, f30->ctrl)) 247 continue; 248