iommu/irq_remapping: Normailize the way to detect whether IR is enabled
authorJiang Liu <jiang.liu@linux.intel.com>
Wed, 7 Jan 2015 07:31:43 +0000 (15:31 +0800)
committerThomas Gleixner <tglx@linutronix.de>
Thu, 15 Jan 2015 10:24:24 +0000 (11:24 +0100)
Refine code by normailizing the way to detect whether IR is enabled.

Signed-off-by: Jiang Liu <jiang.liu@linux.intel.com>
Tested-by: Joerg Roedel <joro@8bytes.org>
Cc: Tony Luck <tony.luck@intel.com>
Cc: iommu@lists.linux-foundation.org
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Yinghai Lu <yinghai@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>
Link: http://lkml.kernel.org/r/1420615903-28253-17-git-send-email-jiang.liu@linux.intel.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
drivers/iommu/irq_remapping.c

index 5585c4e17e39ecaf80a384599082f7009dd0637a..390079ee13507747388f635bf67c1c44dfb6c068 100644 (file)
@@ -218,7 +218,7 @@ int __init irq_remapping_enable(void)
 {
        int ret;
 
-       if (!remap_ops || !remap_ops->enable)
+       if (!remap_ops->enable)
                return -ENODEV;
 
        ret = remap_ops->enable();
@@ -231,22 +231,16 @@ int __init irq_remapping_enable(void)
 
 void irq_remapping_disable(void)
 {
-       if (!irq_remapping_enabled ||
-           !remap_ops ||
-           !remap_ops->disable)
-               return;
-
-       remap_ops->disable();
+       if (irq_remapping_enabled && remap_ops->disable)
+               remap_ops->disable();
 }
 
 int irq_remapping_reenable(int mode)
 {
-       if (!irq_remapping_enabled ||
-           !remap_ops ||
-           !remap_ops->reenable)
-               return 0;
+       if (irq_remapping_enabled && remap_ops->reenable)
+               return remap_ops->reenable(mode);
 
-       return remap_ops->reenable(mode);
+       return 0;
 }
 
 int __init irq_remap_enable_fault_handling(void)
@@ -254,7 +248,7 @@ int __init irq_remap_enable_fault_handling(void)
        if (!irq_remapping_enabled)
                return 0;
 
-       if (!remap_ops || !remap_ops->enable_faulting)
+       if (!remap_ops->enable_faulting)
                return -ENODEV;
 
        return remap_ops->enable_faulting();
@@ -265,7 +259,7 @@ int setup_ioapic_remapped_entry(int irq,
                                unsigned int destination, int vector,
                                struct io_apic_irq_attr *attr)
 {
-       if (!remap_ops || !remap_ops->setup_ioapic_entry)
+       if (!remap_ops->setup_ioapic_entry)
                return -ENODEV;
 
        return remap_ops->setup_ioapic_entry(irq, entry, destination,
@@ -275,8 +269,7 @@ int setup_ioapic_remapped_entry(int irq,
 static int set_remapped_irq_affinity(struct irq_data *data,
                                     const struct cpumask *mask, bool force)
 {
-       if (!config_enabled(CONFIG_SMP) || !remap_ops ||
-           !remap_ops->set_affinity)
+       if (!config_enabled(CONFIG_SMP) || !remap_ops->set_affinity)
                return 0;
 
        return remap_ops->set_affinity(data, mask, force);
@@ -286,10 +279,7 @@ void free_remapped_irq(int irq)
 {
        struct irq_cfg *cfg = irq_cfg(irq);
 
-       if (!remap_ops || !remap_ops->free_irq)
-               return;
-
-       if (irq_remapped(cfg))
+       if (irq_remapped(cfg) && remap_ops->free_irq)
                remap_ops->free_irq(irq);
 }
 
@@ -301,13 +291,13 @@ void compose_remapped_msi_msg(struct pci_dev *pdev,
 
        if (!irq_remapped(cfg))
                native_compose_msi_msg(pdev, irq, dest, msg, hpet_id);
-       else if (remap_ops && remap_ops->compose_msi_msg)
+       else if (remap_ops->compose_msi_msg)
                remap_ops->compose_msi_msg(pdev, irq, dest, msg, hpet_id);
 }
 
 static int msi_alloc_remapped_irq(struct pci_dev *pdev, int irq, int nvec)
 {
-       if (!remap_ops || !remap_ops->msi_alloc_irq)
+       if (!remap_ops->msi_alloc_irq)
                return -ENODEV;
 
        return remap_ops->msi_alloc_irq(pdev, irq, nvec);
@@ -316,7 +306,7 @@ static int msi_alloc_remapped_irq(struct pci_dev *pdev, int irq, int nvec)
 static int msi_setup_remapped_irq(struct pci_dev *pdev, unsigned int irq,
                                  int index, int sub_handle)
 {
-       if (!remap_ops || !remap_ops->msi_setup_irq)
+       if (!remap_ops->msi_setup_irq)
                return -ENODEV;
 
        return remap_ops->msi_setup_irq(pdev, irq, index, sub_handle);
@@ -326,7 +316,7 @@ int setup_hpet_msi_remapped(unsigned int irq, unsigned int id)
 {
        int ret;
 
-       if (!remap_ops || !remap_ops->alloc_hpet_msi)
+       if (!remap_ops->alloc_hpet_msi)
                return -ENODEV;
 
        ret = remap_ops->alloc_hpet_msi(irq, id);