PCI: restructure 'pci_do_fixups()'
authorMyron Stowe <myron.stowe@redhat.com>
Mon, 9 Jul 2012 21:36:02 +0000 (15:36 -0600)
committerBjorn Helgaas <bhelgaas@google.com>
Mon, 9 Jul 2012 22:41:13 +0000 (16:41 -0600)
This patch restructures pci_do_fixups()'s quirk invocations in the style
of initcall_debug_start() and initcall_debug_report(), so we have only
one call site for the quirk.

[bhelgaas: changelog]
Signed-off-by: Myron Stowe <myron.stowe@redhat.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
drivers/pci/quirks.c

index 2a75216775410df88e19fd9faa21e0045c16d15d..51c4a4409e8c8e501a3d138ab24448dd336a5c97 100644 (file)
@@ -2879,20 +2879,34 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x65f9, quirk_intel_mc_errata);
 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x65fa, quirk_intel_mc_errata);
 
 
-static void do_one_fixup_debug(void (*fn)(struct pci_dev *dev), struct pci_dev *dev)
+static ktime_t fixup_debug_start(struct pci_dev *dev,
+                                void (*fn)(struct pci_dev *dev))
 {
-       ktime_t calltime, delta, rettime;
+       ktime_t calltime = ktime_set(0, 0);
+
+       dev_dbg(&dev->dev, "calling %pF\n", fn);
+       if (initcall_debug) {
+               pr_debug("calling  %pF @ %i for %s\n",
+                        fn, task_pid_nr(current), dev_name(&dev->dev));
+               calltime = ktime_get();
+       }
+
+       return calltime;
+}
+
+static void fixup_debug_report(struct pci_dev *dev, ktime_t calltime,
+                              void (*fn)(struct pci_dev *dev))
+{
+       ktime_t delta, rettime;
        unsigned long long duration;
 
-       printk(KERN_DEBUG "calling  %pF @ %i for %s\n",
-                       fn, task_pid_nr(current), dev_name(&dev->dev));
-       calltime = ktime_get();
-       fn(dev);
-       rettime = ktime_get();
-       delta = ktime_sub(rettime, calltime);
-       duration = (unsigned long long) ktime_to_ns(delta) >> 10;
-       printk(KERN_DEBUG "pci fixup %pF returned after %lld usecs for %s\n",
-                       fn, duration, dev_name(&dev->dev));
+       if (initcall_debug) {
+               rettime = ktime_get();
+               delta = ktime_sub(rettime, calltime);
+               duration = (unsigned long long) ktime_to_ns(delta) >> 10;
+               pr_debug("pci fixup %pF returned after %lld usecs for %s\n",
+                        fn, duration, dev_name(&dev->dev));
+       }
 }
 
 /*
@@ -2932,6 +2946,8 @@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x010a, disable_igfx_irq);
 static void pci_do_fixups(struct pci_dev *dev, struct pci_fixup *f,
                          struct pci_fixup *end)
 {
+       ktime_t calltime;
+
        for (; f < end; f++)
                if ((f->class == (u32) (dev->class >> f->class_shift) ||
                     f->class == (u32) PCI_ANY_ID) &&
@@ -2939,11 +2955,9 @@ static void pci_do_fixups(struct pci_dev *dev, struct pci_fixup *f,
                     f->vendor == (u16) PCI_ANY_ID) &&
                    (f->device == dev->device ||
                     f->device == (u16) PCI_ANY_ID)) {
-                       dev_dbg(&dev->dev, "calling %pF\n", f->hook);
-                       if (initcall_debug)
-                               do_one_fixup_debug(f->hook, dev);
-                       else
-                               f->hook(dev);
+                       calltime = fixup_debug_start(dev, f->hook);
+                       f->hook(dev);
+                       fixup_debug_report(dev, calltime, f->hook);
                }
 }