input: gpio_keys: drop the pin filter from the callback

The bit check field is redundant since the callback struct is masked to
a single pin already. Drop it, simplify the code a bit.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
This commit is contained in:
Fabio Baltieri 2023-11-28 15:30:56 +00:00 committed by Maureen Helm
parent f6917bca14
commit 9080007ef9

View file

@ -65,30 +65,19 @@ static void gpio_keys_change_deferred(struct k_work *work)
} }
} }
static void gpio_keys_change_call_deferred(struct gpio_keys_pin_data *data, uint32_t msec)
{
int __maybe_unused rv = k_work_reschedule(&data->work, K_MSEC(msec));
__ASSERT(rv >= 0, "Set wake mask work queue error");
}
static void gpio_keys_interrupt(const struct device *dev, struct gpio_callback *cbdata, static void gpio_keys_interrupt(const struct device *dev, struct gpio_callback *cbdata,
uint32_t pins) uint32_t pins)
{ {
ARG_UNUSED(dev); /* This is a pointer to GPIO device, use dev pointer in
* cbdata for pointer to gpio_debounce device node
*/
struct gpio_keys_callback *keys_cb = CONTAINER_OF( struct gpio_keys_callback *keys_cb = CONTAINER_OF(
cbdata, struct gpio_keys_callback, gpio_cb); cbdata, struct gpio_keys_callback, gpio_cb);
struct gpio_keys_pin_data *pin_data = CONTAINER_OF( struct gpio_keys_pin_data *pin_data = CONTAINER_OF(
keys_cb, struct gpio_keys_pin_data, cb_data); keys_cb, struct gpio_keys_pin_data, cb_data);
const struct gpio_keys_config *cfg = pin_data->dev->config; const struct gpio_keys_config *cfg = pin_data->dev->config;
for (int i = 0; i < cfg->num_keys; i++) { ARG_UNUSED(dev); /* GPIO device pointer. */
if (pins & BIT(cfg->pin_cfg[i].spec.pin)) { ARG_UNUSED(pins);
gpio_keys_change_call_deferred(pin_data, cfg->debounce_interval_ms);
} k_work_reschedule(&pin_data->work, K_MSEC(cfg->debounce_interval_ms));
}
} }
static int gpio_keys_interrupt_configure(const struct gpio_dt_spec *gpio_spec, static int gpio_keys_interrupt_configure(const struct gpio_dt_spec *gpio_spec,