Skip to content

Commit 7a538c8

Browse files
fabiobaltiericarlescufi
authored andcommitted
input: gpio_keys: skip change checking when suspended
Check if the driver is suspended in gpio_keys_change_deferred(), this avoids a potential situation where a race condition could try and read from a pin that has just been disconnected. Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
1 parent ed501d7 commit 7a538c8

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

drivers/input/input_gpio_keys.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,14 @@ static __maybe_unused void gpio_keys_change_deferred(struct k_work *work)
106106
const struct gpio_keys_config *cfg = dev->config;
107107
int key_index = pin_data - (struct gpio_keys_pin_data *)cfg->pin_data;
108108

109+
#ifdef CONFIG_PM_DEVICE
110+
struct gpio_keys_data *data = dev->data;
111+
112+
if (atomic_get(&data->suspended) == 1) {
113+
return;
114+
}
115+
#endif
116+
109117
gpio_keys_poll_pin(dev, key_index);
110118
}
111119

0 commit comments

Comments
 (0)