aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci/intel-iommu.c
diff options
context:
space:
mode:
authorAkinobu Mita <akinobu.mita@gmail.com>2010-03-11 17:04:08 -0500
committerDavid Woodhouse <David.Woodhouse@intel.com>2010-04-09 10:24:11 -0400
commita45946abb8991e17c39326854ed1314d20742ca6 (patch)
treebc2021db50ed2ea722773116196b07050924d295 /drivers/pci/intel-iommu.c
parent87d8a69709d971913e6cc7210450fcb8be963667 (diff)
intel-iommu: use for_each_set_bit()
Replace open-coded loop with for_each_set_bit(). Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Diffstat (limited to 'drivers/pci/intel-iommu.c')
-rw-r--r--drivers/pci/intel-iommu.c33
1 files changed, 7 insertions, 26 deletions
diff --git a/drivers/pci/intel-iommu.c b/drivers/pci/intel-iommu.c
index 417312528dd..a0ac7197ffd 100644
--- a/drivers/pci/intel-iommu.c
+++ b/drivers/pci/intel-iommu.c
@@ -491,13 +491,11 @@ static void domain_update_iommu_coherency(struct dmar_domain *domain)
491 491
492 domain->iommu_coherency = 1; 492 domain->iommu_coherency = 1;
493 493
494 i = find_first_bit(&domain->iommu_bmp, g_num_of_iommus); 494 for_each_set_bit(i, &domain->iommu_bmp, g_num_of_iommus) {
495 for (; i < g_num_of_iommus; ) {
496 if (!ecap_coherent(g_iommus[i]->ecap)) { 495 if (!ecap_coherent(g_iommus[i]->ecap)) {
497 domain->iommu_coherency = 0; 496 domain->iommu_coherency = 0;
498 break; 497 break;
499 } 498 }
500 i = find_next_bit(&domain->iommu_bmp, g_num_of_iommus, i+1);
501 } 499 }
502} 500}
503 501
@@ -507,13 +505,11 @@ static void domain_update_iommu_snooping(struct dmar_domain *domain)
507 505
508 domain->iommu_snooping = 1; 506 domain->iommu_snooping = 1;
509 507
510 i = find_first_bit(&domain->iommu_bmp, g_num_of_iommus); 508 for_each_set_bit(i, &domain->iommu_bmp, g_num_of_iommus) {
511 for (; i < g_num_of_iommus; ) {
512 if (!ecap_sc_support(g_iommus[i]->ecap)) { 509 if (!ecap_sc_support(g_iommus[i]->ecap)) {
513 domain->iommu_snooping = 0; 510 domain->iommu_snooping = 0;
514 break; 511 break;
515 } 512 }
516 i = find_next_bit(&domain->iommu_bmp, g_num_of_iommus, i+1);
517 } 513 }
518} 514}
519 515
@@ -1194,8 +1190,7 @@ void free_dmar_iommu(struct intel_iommu *iommu)
1194 unsigned long flags; 1190 unsigned long flags;
1195 1191
1196 if ((iommu->domains) && (iommu->domain_ids)) { 1192 if ((iommu->domains) && (iommu->domain_ids)) {
1197 i = find_first_bit(iommu->domain_ids, cap_ndoms(iommu->cap)); 1193 for_each_set_bit(i, iommu->domain_ids, cap_ndoms(iommu->cap)) {
1198 for (; i < cap_ndoms(iommu->cap); ) {
1199 domain = iommu->domains[i]; 1194 domain = iommu->domains[i];
1200 clear_bit(i, iommu->domain_ids); 1195 clear_bit(i, iommu->domain_ids);
1201 1196
@@ -1207,9 +1202,6 @@ void free_dmar_iommu(struct intel_iommu *iommu)
1207 domain_exit(domain); 1202 domain_exit(domain);
1208 } 1203 }
1209 spin_unlock_irqrestore(&domain->iommu_lock, flags); 1204 spin_unlock_irqrestore(&domain->iommu_lock, flags);
1210
1211 i = find_next_bit(iommu->domain_ids,
1212 cap_ndoms(iommu->cap), i+1);
1213 } 1205 }
1214 } 1206 }
1215 1207
@@ -1292,14 +1284,11 @@ static void iommu_detach_domain(struct dmar_domain *domain,
1292 1284
1293 spin_lock_irqsave(&iommu->lock, flags); 1285 spin_lock_irqsave(&iommu->lock, flags);
1294 ndomains = cap_ndoms(iommu->cap); 1286 ndomains = cap_ndoms(iommu->cap);
1295 num = find_first_bit(iommu->domain_ids, ndomains); 1287 for_each_set_bit(num, iommu->domain_ids, ndomains) {
1296 for (; num < ndomains; ) {
1297 if (iommu->domains[num] == domain) { 1288 if (iommu->domains[num] == domain) {
1298 found = 1; 1289 found = 1;
1299 break; 1290 break;
1300 } 1291 }
1301 num = find_next_bit(iommu->domain_ids,
1302 cap_ndoms(iommu->cap), num+1);
1303 } 1292 }
1304 1293
1305 if (found) { 1294 if (found) {
@@ -1485,15 +1474,12 @@ static int domain_context_mapping_one(struct dmar_domain *domain, int segment,
1485 1474
1486 /* find an available domain id for this device in iommu */ 1475 /* find an available domain id for this device in iommu */
1487 ndomains = cap_ndoms(iommu->cap); 1476 ndomains = cap_ndoms(iommu->cap);
1488 num = find_first_bit(iommu->domain_ids, ndomains); 1477 for_each_set_bit(num, iommu->domain_ids, ndomains) {
1489 for (; num < ndomains; ) {
1490 if (iommu->domains[num] == domain) { 1478 if (iommu->domains[num] == domain) {
1491 id = num; 1479 id = num;
1492 found = 1; 1480 found = 1;
1493 break; 1481 break;
1494 } 1482 }
1495 num = find_next_bit(iommu->domain_ids,
1496 cap_ndoms(iommu->cap), num+1);
1497 } 1483 }
1498 1484
1499 if (found == 0) { 1485 if (found == 0) {
@@ -3441,12 +3427,9 @@ static int vm_domain_min_agaw(struct dmar_domain *domain)
3441 int i; 3427 int i;
3442 int min_agaw = domain->agaw; 3428 int min_agaw = domain->agaw;
3443 3429
3444 i = find_first_bit(&domain->iommu_bmp, g_num_of_iommus); 3430 for_each_set_bit(i, &domain->iommu_bmp, g_num_of_iommus) {
3445 for (; i < g_num_of_iommus; ) {
3446 if (min_agaw > g_iommus[i]->agaw) 3431 if (min_agaw > g_iommus[i]->agaw)
3447 min_agaw = g_iommus[i]->agaw; 3432 min_agaw = g_iommus[i]->agaw;
3448
3449 i = find_next_bit(&domain->iommu_bmp, g_num_of_iommus, i+1);
3450 } 3433 }
3451 3434
3452 return min_agaw; 3435 return min_agaw;
@@ -3512,8 +3495,7 @@ static void iommu_free_vm_domain(struct dmar_domain *domain)
3512 iommu = drhd->iommu; 3495 iommu = drhd->iommu;
3513 3496
3514 ndomains = cap_ndoms(iommu->cap); 3497 ndomains = cap_ndoms(iommu->cap);
3515 i = find_first_bit(iommu->domain_ids, ndomains); 3498 for_each_set_bit(i, iommu->domain_ids, ndomains) {
3516 for (; i < ndomains; ) {
3517 if (iommu->domains[i] == domain) { 3499 if (iommu->domains[i] == domain) {
3518 spin_lock_irqsave(&iommu->lock, flags); 3500 spin_lock_irqsave(&iommu->lock, flags);
3519 clear_bit(i, iommu->domain_ids); 3501 clear_bit(i, iommu->domain_ids);
@@ -3521,7 +3503,6 @@ static void iommu_free_vm_domain(struct dmar_domain *domain)
3521 spin_unlock_irqrestore(&iommu->lock, flags); 3503 spin_unlock_irqrestore(&iommu->lock, flags);
3522 break; 3504 break;
3523 } 3505 }
3524 i = find_next_bit(iommu->domain_ids, ndomains, i+1);
3525 } 3506 }
3526 } 3507 }
3527} 3508}