diff mbox

[6/8] pci/msi: MSI-X cleanup, msix_program_entries()

Message ID 4A7A415E.2090303@jp.fujitsu.com (mailing list archive)
State Accepted, archived
Headers show

Commit Message

Hidetoshi Seto Aug. 6, 2009, 2:35 a.m. UTC
Cleanup based on the prototype from Matthew Milcox.

Signed-off-by: Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>
---
 drivers/pci/msi.c |   29 +++++++++++++++++++----------
 1 files changed, 19 insertions(+), 10 deletions(-)

Comments

Matthew Wilcox Aug. 7, 2009, 5:23 p.m. UTC | #1
On Thu, Aug 06, 2009 at 11:35:10AM +0900, Hidetoshi Seto wrote:
> Cleanup based on the prototype from Matthew Milcox.
> 
> Signed-off-by: Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>

Reviewed-by: Matthew Wilcox <willy@linux.intel.com>
diff mbox

Patch

diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
index b0cc821..ce08d0b 100644
--- a/drivers/pci/msi.c
+++ b/drivers/pci/msi.c
@@ -447,6 +447,24 @@  static void __iomem *msix_map_region(struct pci_dev *dev, unsigned pos,
 	return ioremap_nocache(phys_addr, nr_entries * PCI_MSIX_ENTRY_SIZE);
 }
 
+static void msix_program_entries(struct pci_dev *dev,
+					struct msix_entry *entries)
+{
+	struct msi_desc *entry;
+	int i = 0;
+
+	list_for_each_entry(entry, &dev->msi_list, list) {
+		int offset = entries[i].entry * PCI_MSIX_ENTRY_SIZE +
+						PCI_MSIX_ENTRY_VECTOR_CTRL;
+
+		entries[i].vector = entry->irq;
+		set_irq_msi(entry->irq, entry);
+		entry->masked = readl(entry->mask_base + offset);
+		msix_mask_irq(entry, 1);
+		i++;
+	}
+}
+
 /**
  * msix_capability_init - configure device's MSI-X capability
  * @dev: pointer to the pci_dev data structure of MSI-X device function
@@ -511,16 +529,7 @@  static int msix_capability_init(struct pci_dev *dev,
 	control |= PCI_MSIX_FLAGS_MASKALL | PCI_MSIX_FLAGS_ENABLE;
 	pci_write_config_word(dev, pos + PCI_MSIX_FLAGS, control);
 
-	i = 0;
-	list_for_each_entry(entry, &dev->msi_list, list) {
-		entries[i].vector = entry->irq;
-		set_irq_msi(entry->irq, entry);
-		j = entries[i].entry;
-		entry->masked = readl(base + j * PCI_MSIX_ENTRY_SIZE +
-						PCI_MSIX_ENTRY_VECTOR_CTRL);
-		msix_mask_irq(entry, 1);
-		i++;
-	}
+	msix_program_entries(dev, entries);
 
 	/* Set MSI-X enabled bits and unmask the function */
 	pci_intx_for_msi(dev, 0);