Skip to content

Commit 3e64fcb

Browse files
aduggan-synadtor
authored andcommitted
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 <[email protected]> Reported-by: Daniel Martin <[email protected]> Tested-by: Daniel Martin <[email protected]> Acked-By: Benjamin Tissoires <[email protected]> Signed-off-by: Dmitry Torokhov <[email protected]>
1 parent a508294 commit 3e64fcb

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

drivers/input/rmi4/rmi_f30.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,17 +232,18 @@ static int rmi_f30_map_gpios(struct rmi_function *fn,
232232
unsigned int trackstick_button = BTN_LEFT;
233233
bool button_mapped = false;
234234
int i;
235+
int button_count = min_t(u8, f30->gpioled_count, TRACKSTICK_RANGE_END);
235236

236237
f30->gpioled_key_map = devm_kcalloc(&fn->dev,
237-
f30->gpioled_count,
238+
button_count,
238239
sizeof(f30->gpioled_key_map[0]),
239240
GFP_KERNEL);
240241
if (!f30->gpioled_key_map) {
241242
dev_err(&fn->dev, "Failed to allocate gpioled map memory.\n");
242243
return -ENOMEM;
243244
}
244245

245-
for (i = 0; i < f30->gpioled_count; i++) {
246+
for (i = 0; i < button_count; i++) {
246247
if (!rmi_f30_is_valid_button(i, f30->ctrl))
247248
continue;
248249

0 commit comments

Comments
 (0)