PCI/MSI: Make msix_update_entries() smarter
authorThomas Gleixner <tglx@linutronix.de>
Mon, 6 Dec 2021 22:27:46 +0000 (23:27 +0100)
committerThomas Gleixner <tglx@linutronix.de>
Thu, 9 Dec 2021 10:52:21 +0000 (11:52 +0100)
No need to walk the descriptors and check for each one whether the entries
pointer function argument is NULL. Do it once.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Link: https://lore.kernel.org/r/20211206210224.600351129@linutronix.de
drivers/pci/msi.c

index a76fcf4b2bde7c1572623637438abd12d419197d..15730910b3cb853e0a689723d8ce9886d3597d85 100644 (file)
@@ -642,8 +642,8 @@ static void msix_update_entries(struct pci_dev *dev, struct msix_entry *entries)
 {
        struct msi_desc *entry;
 
-       for_each_pci_msi_entry(entry, dev) {
-               if (entries) {
+       if (entries) {
+               for_each_pci_msi_entry(entry, dev) {
                        entries->vector = entry->irq;
                        entries++;
                }