diff mbox

[4/6] Fixed IRQ problem for CAN device can_pcm3680_pci.

Message ID af380121337bf56948a5579f95ad35005fc125a2.1483655894.git.pisa@cmp.felk.cvut.cz (mailing list archive)
State New, archived
Headers show

Commit Message

Pavel Pisa Jan. 5, 2017, 11:11 p.m. UTC
From: Deniz Eren <deniz.eren@icloud.com>

---
 hw/can/can_pcm3680_pci.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
diff mbox

Patch

diff --git a/hw/can/can_pcm3680_pci.c b/hw/can/can_pcm3680_pci.c
index 6e5c9f2..9d8d3f7 100644
--- a/hw/can/can_pcm3680_pci.c
+++ b/hw/can/can_pcm3680_pci.c
@@ -61,6 +61,7 @@  typedef struct Pcm3680iPCIState {
     MemoryRegion    sja_io[2];
 
     CanSJA1000State sja_state[2];
+    qemu_irq        irq;
 
     char            *model; /* The model that support, only SJA1000 now. */
     char            *canbus[2];
@@ -69,10 +70,16 @@  typedef struct Pcm3680iPCIState {
 
 static void pcm3680i_pci_irq_raise(void *opaque)
 {
+    Pcm3680iPCIState *d = (Pcm3680iPCIState *)opaque;
+
+    qemu_irq_raise(d->irq);
 }
 
 static void pcm3680i_pci_irq_lower(void *opaque)
 {
+    Pcm3680iPCIState *d = (Pcm3680iPCIState *)opaque;
+
+    qemu_irq_lower(d->irq);
 }
 
 static void
@@ -202,6 +209,8 @@  static int pcm3680i_pci_init(PCIDevice *pci_dev)
     pci_conf = pci_dev->config;
     pci_conf[PCI_INTERRUPT_PIN] = 0x01; /* interrupt pin A */
 
+    d->irq = pci_allocate_irq(&d->dev);
+
     can_sja_init(s1, pcm3680i_pci_irq_raise, pcm3680i_pci_irq_lower, d);
     can_sja_init(s2, pcm3680i_pci_irq_raise, pcm3680i_pci_irq_lower, d);
 
@@ -248,6 +257,8 @@  static void pcm3680i_pci_exit(PCIDevice *pci_dev)
 
     can_sja_exit(s1);
     can_sja_exit(s2);
+
+    qemu_free_irq(d->irq);
 }
 
 static const VMStateDescription vmstate_pcm3680i_pci = {