diff options
author | Jiang Liu <jiang.liu@linux.intel.com> | 2014-02-19 01:07:32 -0500 |
---|---|---|
committer | Joerg Roedel <joro@8bytes.org> | 2014-03-04 11:51:04 -0500 |
commit | b683b230a244c3b2b3f6f3292e59d4a63298528b (patch) | |
tree | a63de166724a05b0a5fff0f23ab2dd83ec65d0b7 /drivers/iommu/dmar.c | |
parent | b5f82ddf22725146d926c56ea4cb80df9b34b6b9 (diff) |
iommu/vt-d: Introduce macro for_each_dev_scope() to walk device scope entries
Introduce for_each_dev_scope()/for_each_active_dev_scope() to walk
{active} device scope entries. This will help following RCU lock
related patches.
Signed-off-by: Jiang Liu <jiang.liu@linux.intel.com>
Signed-off-by: Joerg Roedel <joro@8bytes.org>
Diffstat (limited to 'drivers/iommu/dmar.c')
-rw-r--r-- | drivers/iommu/dmar.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/drivers/iommu/dmar.c b/drivers/iommu/dmar.c index 58dde75c5229..4ae6df27ad5d 100644 --- a/drivers/iommu/dmar.c +++ b/drivers/iommu/dmar.c | |||
@@ -170,9 +170,12 @@ int __init dmar_parse_dev_scope(void *start, void *end, int *cnt, | |||
170 | 170 | ||
171 | void dmar_free_dev_scope(struct pci_dev ***devices, int *cnt) | 171 | void dmar_free_dev_scope(struct pci_dev ***devices, int *cnt) |
172 | { | 172 | { |
173 | int i; | ||
174 | struct pci_dev *tmp_dev; | ||
175 | |||
173 | if (*devices && *cnt) { | 176 | if (*devices && *cnt) { |
174 | while (--*cnt >= 0) | 177 | for_each_active_dev_scope(*devices, *cnt, i, tmp_dev) |
175 | pci_dev_put((*devices)[*cnt]); | 178 | pci_dev_put(tmp_dev); |
176 | kfree(*devices); | 179 | kfree(*devices); |
177 | *devices = NULL; | 180 | *devices = NULL; |
178 | *cnt = 0; | 181 | *cnt = 0; |
@@ -402,10 +405,11 @@ static int dmar_pci_device_match(struct pci_dev *devices[], int cnt, | |||
402 | struct pci_dev *dev) | 405 | struct pci_dev *dev) |
403 | { | 406 | { |
404 | int index; | 407 | int index; |
408 | struct pci_dev *tmp; | ||
405 | 409 | ||
406 | while (dev) { | 410 | while (dev) { |
407 | for (index = 0; index < cnt; index++) | 411 | for_each_active_dev_scope(devices, cnt, index, tmp) |
408 | if (dev == devices[index]) | 412 | if (dev == tmp) |
409 | return 1; | 413 | return 1; |
410 | 414 | ||
411 | /* Check our parent */ | 415 | /* Check our parent */ |
@@ -452,7 +456,7 @@ int __init dmar_dev_scope_init(void) | |||
452 | if (list_empty(&dmar_drhd_units)) | 456 | if (list_empty(&dmar_drhd_units)) |
453 | goto fail; | 457 | goto fail; |
454 | 458 | ||
455 | list_for_each_entry(drhd, &dmar_drhd_units, list) { | 459 | for_each_drhd_unit(drhd) { |
456 | ret = dmar_parse_dev(drhd); | 460 | ret = dmar_parse_dev(drhd); |
457 | if (ret) | 461 | if (ret) |
458 | goto fail; | 462 | goto fail; |