diff options
author | Marc Zyngier <maz@kernel.org> | 2023-03-11 11:42:05 +0000 |
---|---|---|
committer | Marc Zyngier <maz@kernel.org> | 2023-03-11 11:42:05 +0000 |
commit | 40fee32f3b5f22c3336667c6d39dd11c0782c536 (patch) | |
tree | 5299f972dd2620c474897af89bba6436d3d34655 | |
parent | 9428c1798b13eaaa45ea082274d654d0dc71df55 (diff) | |
download | cs-sw-40fee32f3b5f22c3336667c6d39dd11c0782c536.tar.gz |
Blinky activity LED
Signed-off-by: Marc Zyngier <maz@kernel.org>
-rw-r--r-- | vdmtool.c | 31 |
1 files changed, 18 insertions, 13 deletions
@@ -647,6 +647,12 @@ static bool m1_pd_bmc_run_one(struct vdm_context *cxt) return serial_handler(cxt) || cxt->pending; } +#define for_each_cxt(___c) \ + for (struct vdm_context *___c = &vdm_contexts[0]; \ + (___c - vdm_contexts) < CONFIG_USB_PD_PORT_COUNT; \ + ___c++) \ + if (___c->hw) + void m1_pd_bmc_run(void) { int i; @@ -654,24 +660,23 @@ void m1_pd_bmc_run(void) while (1) { bool busy = false; - for (i = 0; i < CONFIG_USB_PD_PORT_COUNT; i++) { - if (!vdm_contexts[i].hw) - continue; - - busy |= m1_pd_bmc_run_one(&vdm_contexts[i]); - irq_set_enabled(vdm_contexts[i].hw->uart_irq, false); + for_each_cxt(cxt) { + gpio_put(PIN(cxt, LED_G), HIGH); + busy |= m1_pd_bmc_run_one(cxt); + irq_set_enabled(cxt->hw->uart_irq, false); } tud_task(); - for (i = 0; i < CONFIG_USB_PD_PORT_COUNT; i++) { - if (!vdm_contexts[i].hw) - continue; + for_each_cxt(cxt) + irq_set_enabled(cxt->hw->uart_irq, true); - irq_set_enabled(vdm_contexts[i].hw->uart_irq, true); - } + if (busy) + continue; + + for_each_cxt(cxt) + gpio_put(PIN(cxt, LED_G), LOW); - if (!busy) - __wfe(); + __wfe(); } } |