summaryrefslogtreecommitdiff
path: root/libhw_cr/rp2040_gpioirq.c
diff options
context:
space:
mode:
authorLuke T. Shumaker <lukeshu@lukeshu.com>2025-04-22 18:51:59 -0600
committerLuke T. Shumaker <lukeshu@lukeshu.com>2025-05-06 11:53:17 -0600
commit24e5d0ec1219e2dbb4b9510ef20833092a2b3871 (patch)
tree01bbcc34c6190fa1c35b2625e9ba1744b1447606 /libhw_cr/rp2040_gpioirq.c
parentf09b7435b3a5222597d27238226d23ec0cbd5bd2 (diff)
wip: Build with -Wconversionlukeshu/safe-conversion
I think this found a real bug in the dhcp packet parser. I don't think anything called lib9p_str{,n}() values that could be big enough, but their bounds-checking was broken.
Diffstat (limited to 'libhw_cr/rp2040_gpioirq.c')
-rw-r--r--libhw_cr/rp2040_gpioirq.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/libhw_cr/rp2040_gpioirq.c b/libhw_cr/rp2040_gpioirq.c
index 1ae74f9..8d406c6 100644
--- a/libhw_cr/rp2040_gpioirq.c
+++ b/libhw_cr/rp2040_gpioirq.c
@@ -17,8 +17,6 @@ struct gpioirq_handler_entry {
};
struct gpioirq_handler_entry gpioirq_handlers[NUM_BANK0_GPIOS][4] = {0};
-int gpioirq_core = -1;
-
static void gpioirq_handler(void) {
uint core = get_core_num();
io_bank0_irq_ctrl_hw_t *irq_ctrl_base;
@@ -44,6 +42,8 @@ static void gpioirq_handler(void) {
}
void gpioirq_set_and_enable_exclusive_handler(uint gpio, enum gpio_irq_level event, gpioirq_handler_t fn, void *arg) {
+ static uint gpioirq_core = ~0U;
+
assert(gpio < NUM_BANK0_GPIOS);
assert(event == GPIO_IRQ_LEVEL_LOW ||
event == GPIO_IRQ_LEVEL_HIGH ||
@@ -55,7 +55,7 @@ void gpioirq_set_and_enable_exclusive_handler(uint gpio, enum gpio_irq_level eve
assert(gpioirq_handlers[gpio][event_idx].fn == NULL);
uint core = get_core_num();
- assert(gpioirq_core == -1 || gpioirq_core == (int)core);
+ assert(gpioirq_core == ~0U || gpioirq_core == core);
io_bank0_irq_ctrl_hw_t *irq_ctrl_base;
switch (core) {
@@ -67,7 +67,7 @@ void gpioirq_set_and_enable_exclusive_handler(uint gpio, enum gpio_irq_level eve
gpioirq_handlers[gpio][event_idx].fn = fn;
gpioirq_handlers[gpio][event_idx].arg = arg;
hw_set_bits(&irq_ctrl_base->inte[gpio/8], 1u<<((4*(gpio%8))+event_idx));
- if (gpioirq_core == -1) {
+ if (gpioirq_core == ~0U) {
irq_set_exclusive_handler(IO_IRQ_BANK0, gpioirq_handler);
irq_set_enabled(IO_IRQ_BANK0, true);
gpioirq_core = core;