Commit 811a4e6f authored by Jiang Liu's avatar Jiang Liu Committed by Bjorn Helgaas

PCI: Add helpers to manage pci_dev->irq and pci_dev->irq_managed

Add pci_has_managed_irq(), pci_set_managed_irq(), and
pci_reset_managed_irq() to simplify code.  No functional change.

[bhelgaas: changelog]
Signed-off-by: default avatarJiang Liu <jiang.liu@linux.intel.com>
Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
Acked-by: default avatarThomas Gleixner <tglx@linutronix.de>
parent 991de2e5
...@@ -211,7 +211,7 @@ static int intel_mid_pci_irq_enable(struct pci_dev *dev) ...@@ -211,7 +211,7 @@ static int intel_mid_pci_irq_enable(struct pci_dev *dev)
struct irq_alloc_info info; struct irq_alloc_info info;
int polarity; int polarity;
if (dev->irq_managed && dev->irq > 0) if (pci_has_managed_irq(dev))
return 0; return 0;
if (intel_mid_identify_cpu() == INTEL_MID_CPU_CHIP_TANGIER) if (intel_mid_identify_cpu() == INTEL_MID_CPU_CHIP_TANGIER)
...@@ -234,7 +234,7 @@ static int intel_mid_pci_irq_enable(struct pci_dev *dev) ...@@ -234,7 +234,7 @@ static int intel_mid_pci_irq_enable(struct pci_dev *dev)
static void intel_mid_pci_irq_disable(struct pci_dev *dev) static void intel_mid_pci_irq_disable(struct pci_dev *dev)
{ {
if (dev->irq_managed && dev->irq > 0) { if (pci_has_managed_irq(dev)) {
mp_unmap_irq(dev->irq); mp_unmap_irq(dev->irq);
dev->irq_managed = 0; dev->irq_managed = 0;
/* /*
......
...@@ -1202,7 +1202,7 @@ static int pirq_enable_irq(struct pci_dev *dev) ...@@ -1202,7 +1202,7 @@ static int pirq_enable_irq(struct pci_dev *dev)
struct pci_dev *temp_dev; struct pci_dev *temp_dev;
int irq; int irq;
if (dev->irq_managed && dev->irq > 0) if (pci_has_managed_irq(dev))
return 0; return 0;
irq = IO_APIC_get_PCI_irq_vector(dev->bus->number, irq = IO_APIC_get_PCI_irq_vector(dev->bus->number,
...@@ -1230,8 +1230,7 @@ static int pirq_enable_irq(struct pci_dev *dev) ...@@ -1230,8 +1230,7 @@ static int pirq_enable_irq(struct pci_dev *dev)
} }
dev = temp_dev; dev = temp_dev;
if (irq >= 0) { if (irq >= 0) {
dev->irq_managed = 1; pci_set_managed_irq(dev, irq);
dev->irq = irq;
dev_info(&dev->dev, "PCI->APIC IRQ transform: " dev_info(&dev->dev, "PCI->APIC IRQ transform: "
"INT %c -> IRQ %d\n", 'A' + pin - 1, irq); "INT %c -> IRQ %d\n", 'A' + pin - 1, irq);
return 0; return 0;
...@@ -1259,9 +1258,8 @@ static int pirq_enable_irq(struct pci_dev *dev) ...@@ -1259,9 +1258,8 @@ static int pirq_enable_irq(struct pci_dev *dev)
static void pirq_disable_irq(struct pci_dev *dev) static void pirq_disable_irq(struct pci_dev *dev)
{ {
if (io_apic_assign_pci_irqs && dev->irq_managed && dev->irq) { if (io_apic_assign_pci_irqs && pci_has_managed_irq(dev)) {
mp_unmap_irq(dev->irq); mp_unmap_irq(dev->irq);
dev->irq = 0; pci_reset_managed_irq(dev);
dev->irq_managed = 0;
} }
} }
...@@ -412,7 +412,7 @@ int acpi_pci_irq_enable(struct pci_dev *dev) ...@@ -412,7 +412,7 @@ int acpi_pci_irq_enable(struct pci_dev *dev)
return 0; return 0;
} }
if (dev->irq_managed && dev->irq > 0) if (pci_has_managed_irq(dev))
return 0; return 0;
entry = acpi_pci_irq_lookup(dev, pin); entry = acpi_pci_irq_lookup(dev, pin);
...@@ -457,8 +457,7 @@ int acpi_pci_irq_enable(struct pci_dev *dev) ...@@ -457,8 +457,7 @@ int acpi_pci_irq_enable(struct pci_dev *dev)
kfree(entry); kfree(entry);
return rc; return rc;
} }
dev->irq = rc; pci_set_managed_irq(dev, rc);
dev->irq_managed = 1;
if (link) if (link)
snprintf(link_desc, sizeof(link_desc), " -> Link[%s]", link); snprintf(link_desc, sizeof(link_desc), " -> Link[%s]", link);
...@@ -481,7 +480,7 @@ void acpi_pci_irq_disable(struct pci_dev *dev) ...@@ -481,7 +480,7 @@ void acpi_pci_irq_disable(struct pci_dev *dev)
u8 pin; u8 pin;
pin = dev->pin; pin = dev->pin;
if (!pin || !dev->irq_managed || dev->irq <= 0) if (!pin || !pci_has_managed_irq(dev))
return; return;
entry = acpi_pci_irq_lookup(dev, pin); entry = acpi_pci_irq_lookup(dev, pin);
...@@ -503,7 +502,6 @@ void acpi_pci_irq_disable(struct pci_dev *dev) ...@@ -503,7 +502,6 @@ void acpi_pci_irq_disable(struct pci_dev *dev)
dev_dbg(&dev->dev, "PCI INT %c disabled\n", pin_name(pin)); dev_dbg(&dev->dev, "PCI INT %c disabled\n", pin_name(pin));
if (gsi >= 0) { if (gsi >= 0) {
acpi_unregister_gsi(gsi); acpi_unregister_gsi(gsi);
dev->irq_managed = 0; pci_reset_managed_irq(dev);
dev->irq = 0;
} }
} }
...@@ -963,6 +963,23 @@ static inline int pci_is_managed(struct pci_dev *pdev) ...@@ -963,6 +963,23 @@ static inline int pci_is_managed(struct pci_dev *pdev)
return pdev->is_managed; return pdev->is_managed;
} }
static inline void pci_set_managed_irq(struct pci_dev *pdev, unsigned int irq)
{
pdev->irq = irq;
pdev->irq_managed = 1;
}
static inline void pci_reset_managed_irq(struct pci_dev *pdev)
{
pdev->irq = 0;
pdev->irq_managed = 0;
}
static inline bool pci_has_managed_irq(struct pci_dev *pdev)
{
return pdev->irq_managed && pdev->irq > 0;
}
void pci_disable_device(struct pci_dev *dev); void pci_disable_device(struct pci_dev *dev);
extern unsigned int pcibios_max_latency; extern unsigned int pcibios_max_latency;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment