Closed kadamski closed 1 year ago
LGTM! Still can't believe I missed that completely
Tested this patch on bl808/all as this branch did not boot. Without this patch:
# gpio-event-mon -n gpiochip0 -o 14 -f
[ 9.137851] genirq: Setting trigger mode 2 for irq 14 failed (bflb_gpio_irq_set_type+0x0/0xf8)
Failed to issue GPIO_GET_LINE_IOCTL (-22), Invalid argument
With this patch, after conecting the GPIO14 to GND:
# gpio-event-mon -n gpiochip0 -o 14 -f
Monitoring line 14 on gpiochip0
Initial line value: 1
GPIO EVENT at 256636683000 on line 14 (1|1) falling edge
Cherry-picked into bl808/pinctrl-hwrng
and bl808/all
branches and tested, working. Thank you!
The bflb_gpio_irq_type() would return a BFLB_IRQ_MODE_SYNC_EDGE_FALLING value in case none of the supported types were matched. It happens that this define is represented by the value 0.
The bflb_gpio_irq_set_type() would reject the value 0 returned by that function and return -EINVAL. Problem is, that same thing would happen when the EDGE_FALLING (which is valid) mode was requested making it impossible to select this mode.
This patch fixes the problem by returning an -EINVAL from the bflb_gpio_irq_type() in case of an error instead of value 0 so we can now easily differentiate those two cases and requesting EDGE_FALLING interrupt is now possible.