Skip to content

Commit

Permalink
iommu/irq_remapping: Normailize the way to detect whether IR is enabled
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Jiang Liu authored and Thomas Gleixner committed Jan 15, 2015
1 parent 7fa1c84 commit e901176
Showing 1 changed file with 14 additions and 24 deletions.
38 changes: 14 additions & 24 deletions drivers/iommu/irq_remapping.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -231,30 +231,24 @@ 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)
{
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();
Expand All @@ -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,
Expand All @@ -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);
Expand All @@ -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);
}

Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit e901176

Please sign in to comment.