pci: Utilize device_getenv_int
[dragonfly.git] / sys / bus / pci / pci.c
index 62768d2..f752fa1 100644 (file)
@@ -28,7 +28,6 @@
  * $FreeBSD: src/sys/dev/pci/pci.c,v 1.355.2.9.2.1 2009/04/15 03:14:26 kensmith Exp $
  */
 
-#include "opt_bus.h"
 #include "opt_acpi.h"
 #include "opt_compat_oldpci.h"
 
@@ -1920,8 +1919,8 @@ pci_alloc_msi_method(device_t dev, device_t child, int *rid, int count,
 
        if (bootverbose) {
                device_printf(child,
-                   "attempting to allocate %d MSI vectors (%d supported)\n",
-                   count, cfg->msi.msi_msgnum);
+                   "attempting to allocate %d MSI vector%s (%d supported)\n",
+                   count, count > 1 ? "s" : "", cfg->msi.msi_msgnum);
        }
 
        if (start_cpuid < 0)
@@ -2690,10 +2689,16 @@ pci_assign_interrupt(device_t bus, device_t dev, int force_route)
        /* Let the user override the IRQ with a tunable. */
        irq = PCI_INVALID_IRQ;
        ksnprintf(tunable_name, sizeof(tunable_name),
-           "hw.pci%d.%d.%d.INT%c.irq",
-           cfg->domain, cfg->bus, cfg->slot, cfg->intpin + 'A' - 1);
-       if (TUNABLE_INT_FETCH(tunable_name, &irq) && (irq >= 255 || irq <= 0))
-               irq = PCI_INVALID_IRQ;
+           "hw.pci%d.%d.%d.%d.INT%c.irq",
+           cfg->domain, cfg->bus, cfg->slot, cfg->func, cfg->intpin + 'A' - 1);
+       if (TUNABLE_INT_FETCH(tunable_name, &irq)) {
+               if (irq >= 255 || irq <= 0) {
+                       irq = PCI_INVALID_IRQ;
+               } else {
+                       BUS_CONFIG_INTR(bus, dev, irq,
+                           INTR_TRIGGER_LEVEL, INTR_POLARITY_LOW);
+               }
+       }
 
        /*
         * If we didn't get an IRQ via the tunable, then we either use the
@@ -4093,22 +4098,16 @@ pci_alloc_1intr(device_t dev, int msi_enable, int *rid0, u_int *flags0)
 {
        int rid, type;
        u_int flags;
-       char env[64];
 
        rid = 0;
        type = PCI_INTR_TYPE_LEGACY;
        flags = RF_SHAREABLE | RF_ACTIVE;
 
-       ksnprintf(env, sizeof(env), "hw.%s.msi.enable",
-           device_get_nameunit(dev));
-       kgetenv_int(env, &msi_enable);
-
+       device_getenv_int(dev, "msi.enable", &msi_enable);
        if (msi_enable) {
                int cpu = -1;
 
-               ksnprintf(env, sizeof(env), "hw.%s.msi.cpu",
-                   device_get_nameunit(dev));
-               kgetenv_int(env, &cpu);
+               device_getenv_int(dev, "msi.cpu", &cpu);
                if (cpu >= ncpus)
                        cpu = ncpus - 1;