From 2c23465dbc0b728fa900464e97f04a215377ade9 Mon Sep 17 00:00:00 2001 From: Marcin Niestroj Date: Mon, 6 Apr 2020 14:25:50 +0200 Subject: [PATCH] drivers: lora: sx1276: check gpio controller when looking for triggered DIO So far only GPIO pin number of registered DIO line was compared with arguments passed to GPIO callback. This is not enough when multiple gpio controllers are used for DIO lines. As an example when DIO0 is on PA1 and DIO1 is on PB1, then DIO0 handler is called all the time. Compare GPIO controller (in addition to pin number) of DIO lines with the argument passed to gpio callback, so proper DIO handler is used. Signed-off-by: Marcin Niestroj --- drivers/lora/sx1276.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/lora/sx1276.c b/drivers/lora/sx1276.c index 17ac9622e95..2b1b8b53fff 100644 --- a/drivers/lora/sx1276.c +++ b/drivers/lora/sx1276.c @@ -164,7 +164,8 @@ static void sx1276_irq_callback(struct device *dev, pin = find_lsb_set(pins) - 1; for (i = 0; i < SX1276_MAX_DIO; i++) { - if (pin == sx1276_dios[i].pin) { + if (dev == dev_data.dio_dev[i] && + pin == sx1276_dios[i].pin) { (*DioIrq[i])(NULL); } }