From e29485fa59b9f0cf3e8ffd7e9d2a3120799bf8cd Mon Sep 17 00:00:00 2001 From: Stefan Kalkowski Date: Tue, 25 Aug 2020 15:13:41 +0200 Subject: [PATCH] dde_linux: decouple Lx_kit::Irq and Platform::Device Follow-up commit to fix the old usb_drv. Under rpi one and the same irq can be requested several times. Therefore, we've to track the Irq_connection objects. Ref #3865 --- .../drivers/usb/spec/arm/platform_generic.cc | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/repos/dde_linux/src/drivers/usb/spec/arm/platform_generic.cc b/repos/dde_linux/src/drivers/usb/spec/arm/platform_generic.cc index 45b738a867..d63fd8b0f4 100644 --- a/repos/dde_linux/src/drivers/usb/spec/arm/platform_generic.cc +++ b/repos/dde_linux/src/drivers/usb/spec/arm/platform_generic.cc @@ -47,9 +47,20 @@ void Lx::backend_free(Genode::Ram_dataspace_capability cap) { extern "C" int request_irq(unsigned int irq, irq_handler_t handler, unsigned long flags, const char *name, void *dev) { - Genode::Irq_connection * irq_con = new (Lx_kit::env().heap()) - Genode::Irq_connection(Lx_kit::env().env(), irq); - Lx::Irq::irq().request_irq(irq_con->cap(), irq, handler, dev); + struct Irq : Genode::List::Element { + unsigned const nr; + Genode::Irq_connection irq_con { Lx_kit::env().env(), nr }; + Irq(unsigned const irq, Genode::List & list) + : nr(irq) { list.insert(this); } + }; + + static Genode::List irq_list; + + Irq * i = irq_list.first(); + for (; i; i = i->next()) { if (i->nr == irq) break; } + if (!i) i = new (Lx_kit::env().heap()) Irq(irq, irq_list); + + Lx::Irq::irq().request_irq(i->irq_con.cap(), irq, handler, dev); return 0; }