aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Duggan <aduggan@synaptics.com>2017-10-25 12:30:16 -0400
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2017-10-27 18:15:59 -0400
commit3e64fcbdbd10e46dede502d507dbcc104837cd59 (patch)
treeece39dc5ac2621ed847b6257bc9be61e30588eee
parenta50829479f58416a013a4ccca791336af3c584c7 (diff)
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>
-rw-r--r--drivers/input/rmi4/rmi_f30.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/input/rmi4/rmi_f30.c b/drivers/input/rmi4/rmi_f30.c
index 34dfee555b20..82e0f0d43d55 100644
--- a/drivers/input/rmi4/rmi_f30.c
+++ b/drivers/input/rmi4/rmi_f30.c
@@ -232,9 +232,10 @@ static int rmi_f30_map_gpios(struct rmi_function *fn,
232 unsigned int trackstick_button = BTN_LEFT; 232 unsigned int trackstick_button = BTN_LEFT;
233 bool button_mapped = false; 233 bool button_mapped = false;
234 int i; 234 int i;
235 int button_count = min_t(u8, f30->gpioled_count, TRACKSTICK_RANGE_END);
235 236
236 f30->gpioled_key_map = devm_kcalloc(&fn->dev, 237 f30->gpioled_key_map = devm_kcalloc(&fn->dev,
237 f30->gpioled_count, 238 button_count,
238 sizeof(f30->gpioled_key_map[0]), 239 sizeof(f30->gpioled_key_map[0]),
239 GFP_KERNEL); 240 GFP_KERNEL);
240 if (!f30->gpioled_key_map) { 241 if (!f30->gpioled_key_map) {
@@ -242,7 +243,7 @@ static int rmi_f30_map_gpios(struct rmi_function *fn,
242 return -ENOMEM; 243 return -ENOMEM;
243 } 244 }
244 245
245 for (i = 0; i < f30->gpioled_count; i++) { 246 for (i = 0; i < button_count; i++) {
246 if (!rmi_f30_is_valid_button(i, f30->ctrl)) 247 if (!rmi_f30_is_valid_button(i, f30->ctrl))
247 continue; 248 continue;
248 249