diff options
author | Jiang Liu <jiang.liu@linux.intel.com> | 2015-01-07 02:31:43 -0500 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2015-01-15 05:24:24 -0500 |
commit | e901176046e6729e002839d7296f27f17599ccb8 (patch) | |
tree | 5e2991a2bb5dbd4df05d19a423fe7d7a75e2e4b0 /drivers/iommu/irq_remapping.c | |
parent | 7fa1c842caca3b1d8a55a64033403cab8ca8583a (diff) |
iommu/irq_remapping: Normailize the way to detect whether IR is enabled
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>
Diffstat (limited to 'drivers/iommu/irq_remapping.c')
-rw-r--r-- | drivers/iommu/irq_remapping.c | 38 |
1 files changed, 14 insertions, 24 deletions
diff --git a/drivers/iommu/irq_remapping.c b/drivers/iommu/irq_remapping.c index 5585c4e17e39..390079ee1350 100644 --- a/drivers/iommu/irq_remapping.c +++ b/drivers/iommu/irq_remapping.c | |||
@@ -218,7 +218,7 @@ int __init irq_remapping_enable(void) | |||
218 | { | 218 | { |
219 | int ret; | 219 | int ret; |
220 | 220 | ||
221 | if (!remap_ops || !remap_ops->enable) | 221 | if (!remap_ops->enable) |
222 | return -ENODEV; | 222 | return -ENODEV; |
223 | 223 | ||
224 | ret = remap_ops->enable(); | 224 | ret = remap_ops->enable(); |
@@ -231,22 +231,16 @@ int __init irq_remapping_enable(void) | |||
231 | 231 | ||
232 | void irq_remapping_disable(void) | 232 | void irq_remapping_disable(void) |
233 | { | 233 | { |
234 | if (!irq_remapping_enabled || | 234 | if (irq_remapping_enabled && remap_ops->disable) |
235 | !remap_ops || | 235 | remap_ops->disable(); |
236 | !remap_ops->disable) | ||
237 | return; | ||
238 | |||
239 | remap_ops->disable(); | ||
240 | } | 236 | } |
241 | 237 | ||
242 | int irq_remapping_reenable(int mode) | 238 | int irq_remapping_reenable(int mode) |
243 | { | 239 | { |
244 | if (!irq_remapping_enabled || | 240 | if (irq_remapping_enabled && remap_ops->reenable) |
245 | !remap_ops || | 241 | return remap_ops->reenable(mode); |
246 | !remap_ops->reenable) | ||
247 | return 0; | ||
248 | 242 | ||
249 | return remap_ops->reenable(mode); | 243 | return 0; |
250 | } | 244 | } |
251 | 245 | ||
252 | int __init irq_remap_enable_fault_handling(void) | 246 | int __init irq_remap_enable_fault_handling(void) |
@@ -254,7 +248,7 @@ int __init irq_remap_enable_fault_handling(void) | |||
254 | if (!irq_remapping_enabled) | 248 | if (!irq_remapping_enabled) |
255 | return 0; | 249 | return 0; |
256 | 250 | ||
257 | if (!remap_ops || !remap_ops->enable_faulting) | 251 | if (!remap_ops->enable_faulting) |
258 | return -ENODEV; | 252 | return -ENODEV; |
259 | 253 | ||
260 | return remap_ops->enable_faulting(); | 254 | return remap_ops->enable_faulting(); |
@@ -265,7 +259,7 @@ int setup_ioapic_remapped_entry(int irq, | |||
265 | unsigned int destination, int vector, | 259 | unsigned int destination, int vector, |
266 | struct io_apic_irq_attr *attr) | 260 | struct io_apic_irq_attr *attr) |
267 | { | 261 | { |
268 | if (!remap_ops || !remap_ops->setup_ioapic_entry) | 262 | if (!remap_ops->setup_ioapic_entry) |
269 | return -ENODEV; | 263 | return -ENODEV; |
270 | 264 | ||
271 | return remap_ops->setup_ioapic_entry(irq, entry, destination, | 265 | return remap_ops->setup_ioapic_entry(irq, entry, destination, |
@@ -275,8 +269,7 @@ int setup_ioapic_remapped_entry(int irq, | |||
275 | static int set_remapped_irq_affinity(struct irq_data *data, | 269 | static int set_remapped_irq_affinity(struct irq_data *data, |
276 | const struct cpumask *mask, bool force) | 270 | const struct cpumask *mask, bool force) |
277 | { | 271 | { |
278 | if (!config_enabled(CONFIG_SMP) || !remap_ops || | 272 | if (!config_enabled(CONFIG_SMP) || !remap_ops->set_affinity) |
279 | !remap_ops->set_affinity) | ||
280 | return 0; | 273 | return 0; |
281 | 274 | ||
282 | return remap_ops->set_affinity(data, mask, force); | 275 | return remap_ops->set_affinity(data, mask, force); |
@@ -286,10 +279,7 @@ void free_remapped_irq(int irq) | |||
286 | { | 279 | { |
287 | struct irq_cfg *cfg = irq_cfg(irq); | 280 | struct irq_cfg *cfg = irq_cfg(irq); |
288 | 281 | ||
289 | if (!remap_ops || !remap_ops->free_irq) | 282 | if (irq_remapped(cfg) && remap_ops->free_irq) |
290 | return; | ||
291 | |||
292 | if (irq_remapped(cfg)) | ||
293 | remap_ops->free_irq(irq); | 283 | remap_ops->free_irq(irq); |
294 | } | 284 | } |
295 | 285 | ||
@@ -301,13 +291,13 @@ void compose_remapped_msi_msg(struct pci_dev *pdev, | |||
301 | 291 | ||
302 | if (!irq_remapped(cfg)) | 292 | if (!irq_remapped(cfg)) |
303 | native_compose_msi_msg(pdev, irq, dest, msg, hpet_id); | 293 | native_compose_msi_msg(pdev, irq, dest, msg, hpet_id); |
304 | else if (remap_ops && remap_ops->compose_msi_msg) | 294 | else if (remap_ops->compose_msi_msg) |
305 | remap_ops->compose_msi_msg(pdev, irq, dest, msg, hpet_id); | 295 | remap_ops->compose_msi_msg(pdev, irq, dest, msg, hpet_id); |
306 | } | 296 | } |
307 | 297 | ||
308 | static int msi_alloc_remapped_irq(struct pci_dev *pdev, int irq, int nvec) | 298 | static int msi_alloc_remapped_irq(struct pci_dev *pdev, int irq, int nvec) |
309 | { | 299 | { |
310 | if (!remap_ops || !remap_ops->msi_alloc_irq) | 300 | if (!remap_ops->msi_alloc_irq) |
311 | return -ENODEV; | 301 | return -ENODEV; |
312 | 302 | ||
313 | return remap_ops->msi_alloc_irq(pdev, irq, nvec); | 303 | 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) | |||
316 | static int msi_setup_remapped_irq(struct pci_dev *pdev, unsigned int irq, | 306 | static int msi_setup_remapped_irq(struct pci_dev *pdev, unsigned int irq, |
317 | int index, int sub_handle) | 307 | int index, int sub_handle) |
318 | { | 308 | { |
319 | if (!remap_ops || !remap_ops->msi_setup_irq) | 309 | if (!remap_ops->msi_setup_irq) |
320 | return -ENODEV; | 310 | return -ENODEV; |
321 | 311 | ||
322 | return remap_ops->msi_setup_irq(pdev, irq, index, sub_handle); | 312 | 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) | |||
326 | { | 316 | { |
327 | int ret; | 317 | int ret; |
328 | 318 | ||
329 | if (!remap_ops || !remap_ops->alloc_hpet_msi) | 319 | if (!remap_ops->alloc_hpet_msi) |
330 | return -ENODEV; | 320 | return -ENODEV; |
331 | 321 | ||
332 | ret = remap_ops->alloc_hpet_msi(irq, id); | 322 | ret = remap_ops->alloc_hpet_msi(irq, id); |