devices: direct_irq: switch to using IrqEdgeEvent and IrqLevelEvent

With users of IRQ code switching to dedicated objects to represent IRQ
signalling, let's introduce DirectIrq::new_edge() and
DirectIrq::new_level() methods accepting appropriate event types.

BUG=None
TEST=./tools/presubmit

Change-Id: I18d9373c8cf5ed9db7c33227ca8b67e0a9136f6c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3548062
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dmitry Torokhov <dtor@chromium.org>
diff --git a/src/linux/mod.rs b/src/linux/mod.rs
index 21208ca..0db8334 100644
--- a/src/linux/mod.rs
+++ b/src/linux/mod.rs
@@ -1231,12 +1231,11 @@
         if !sys_allocator.reserve_irq(*irq) {
             warn!("irq {} already reserved.", irq);
         }
-        let trigger = Event::new().context("failed to create event")?;
-        let resample = Event::new().context("failed to create event")?;
+        let irq_evt = devices::IrqLevelEvent::new().context("failed to create event")?;
         irq_chip
-            .register_irq_event(*irq, &trigger, Some(&resample))
+            .register_irq_event(*irq, irq_evt.get_trigger(), Some(irq_evt.get_resample()))
             .unwrap();
-        let direct_irq = devices::DirectIrq::new(trigger, Some(resample))
+        let direct_irq = devices::DirectIrq::new_level(&irq_evt)
             .context("failed to enable interrupt forwarding")?;
         direct_irq
             .irq_enable(*irq)
@@ -1249,9 +1248,11 @@
         if !sys_allocator.reserve_irq(*irq) {
             warn!("irq {} already reserved.", irq);
         }
-        let trigger = Event::new().context("failed to create event")?;
-        irq_chip.register_irq_event(*irq, &trigger, None).unwrap();
-        let direct_irq = devices::DirectIrq::new(trigger, None)
+        let irq_evt = devices::IrqEdgeEvent::new().context("failed to create event")?;
+        irq_chip
+            .register_irq_event(*irq, irq_evt.get_trigger(), None)
+            .unwrap();
+        let direct_irq = devices::DirectIrq::new_edge(&irq_evt)
             .context("failed to enable interrupt forwarding")?;
         direct_irq
             .irq_enable(*irq)