summaryrefslogtreecommitdiffstats
path: root/drivers/iommu/dmar.c
diff options
context:
space:
mode:
authorJiang Liu <jiang.liu@linux.intel.com>2014-02-19 14:07:32 +0800
committerJoerg Roedel <joro@8bytes.org>2014-03-04 17:51:04 +0100
commitb683b230a244c3b2b3f6f3292e59d4a63298528b (patch)
treea63de166724a05b0a5fff0f23ab2dd83ec65d0b7 /drivers/iommu/dmar.c
parentb5f82ddf22725146d926c56ea4cb80df9b34b6b9 (diff)
downloadop-kernel-dev-b683b230a244c3b2b3f6f3292e59d4a63298528b.zip
op-kernel-dev-b683b230a244c3b2b3f6f3292e59d4a63298528b.tar.gz
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.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/drivers/iommu/dmar.c b/drivers/iommu/dmar.c
index 58dde75..4ae6df2 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,
void dmar_free_dev_scope(struct pci_dev ***devices, int *cnt)
{
+ int i;
+ struct pci_dev *tmp_dev;
+
if (*devices && *cnt) {
- while (--*cnt >= 0)
- pci_dev_put((*devices)[*cnt]);
+ for_each_active_dev_scope(*devices, *cnt, i, tmp_dev)
+ pci_dev_put(tmp_dev);
kfree(*devices);
*devices = NULL;
*cnt = 0;
@@ -402,10 +405,11 @@ static int dmar_pci_device_match(struct pci_dev *devices[], int cnt,
struct pci_dev *dev)
{
int index;
+ struct pci_dev *tmp;
while (dev) {
- for (index = 0; index < cnt; index++)
- if (dev == devices[index])
+ for_each_active_dev_scope(devices, cnt, index, tmp)
+ if (dev == tmp)
return 1;
/* Check our parent */
@@ -452,7 +456,7 @@ int __init dmar_dev_scope_init(void)
if (list_empty(&dmar_drhd_units))
goto fail;
- list_for_each_entry(drhd, &dmar_drhd_units, list) {
+ for_each_drhd_unit(drhd) {
ret = dmar_parse_dev(drhd);
if (ret)
goto fail;
OpenPOWER on IntegriCloud