mptable: Reset pinmask on new bus or device.

Fix small possibility of bus changing without device changing.
diff --git a/src/mptable.c b/src/mptable.c
index f87e685..eba7d97 100644
--- a/src/mptable.c
+++ b/src/mptable.c
@@ -110,8 +110,8 @@
         int irq = pci_config_readb(bdf, PCI_INTERRUPT_LINE);
         if (pin == 0)
             continue;
-        if (dev != pci_bdf_to_dev(bdf)) {
-            dev = pci_bdf_to_dev(bdf);
+        if (dev != pci_bdf_to_busdev(bdf)) {
+            dev = pci_bdf_to_busdev(bdf);
             pinmask = 0;
         }
         if (pinmask & (1 << pin)) /* pin was seen already */
@@ -123,7 +123,7 @@
         intsrc->irqtype = 0; /* INT */
         intsrc->irqflag = 1; /* active high */
         intsrc->srcbus = pci_bdf_to_bus(bdf); /* PCI bus */
-        intsrc->srcbusirq = (dev << 2) | (pin - 1);
+        intsrc->srcbusirq = (pci_bdf_to_dev(bdf) << 2) | (pin - 1);
         intsrc->dstapic = ioapic_id;
         intsrc->dstirq = irq;
         intsrc++;
diff --git a/src/pci.h b/src/pci.h
index a0b6b9c..3c04529 100644
--- a/src/pci.h
+++ b/src/pci.h
@@ -9,6 +9,9 @@
 static inline u8 pci_bdf_to_devfn(u16 bdf) {
     return bdf & 0xff;
 }
+static inline u16 pci_bdf_to_busdev(u16 bdf) {
+    return bdf & ~0x07;
+}
 static inline u8 pci_bdf_to_dev(u16 bdf) {
     return (bdf >> 3) & 0x1f;
 }