提交 2f119c78 编写于 作者: Q Quentin Lambert 提交者: Joerg Roedel

iommu/vt-d: Convert non-returned local variable to boolean when relevant

This patch was produced using Coccinelle. A simplified version of the
semantic patch is:

@r exists@
identifier f;
local idexpression u8 x;
identifier xname;
@@

f(...) {
...when any
(
  x@xname = 1;
|
  x@xname = 0;
)
...when any
}

@bad exists@
identifier r.f;
local idexpression u8 r.x
expression e1 != {0, 1}, e2;
@@

f(...) {
...when any
(
  x = e1;
|
  x + e2
)
...when any
}

@depends on !bad@
identifier r.f;
local idexpression u8 r.x;
identifier r.xname;
@@

f(...) {
...
++ bool xname;
- int xname;
<...
(
  x =
- 1
+ true
|
  x =
- -1
+ false
)
...>

}
Signed-off-by: NQuentin Lambert <lambert.quentin@gmail.com>
Signed-off-by: NJoerg Roedel <jroedel@suse.de>
上级 c517d838
...@@ -595,12 +595,13 @@ static void domain_update_iommu_coherency(struct dmar_domain *domain) ...@@ -595,12 +595,13 @@ static void domain_update_iommu_coherency(struct dmar_domain *domain)
{ {
struct dmar_drhd_unit *drhd; struct dmar_drhd_unit *drhd;
struct intel_iommu *iommu; struct intel_iommu *iommu;
int i, found = 0; bool found = false;
int i;
domain->iommu_coherency = 1; domain->iommu_coherency = 1;
for_each_set_bit(i, domain->iommu_bmp, g_num_of_iommus) { for_each_set_bit(i, domain->iommu_bmp, g_num_of_iommus) {
found = 1; found = true;
if (!ecap_coherent(g_iommus[i]->ecap)) { if (!ecap_coherent(g_iommus[i]->ecap)) {
domain->iommu_coherency = 0; domain->iommu_coherency = 0;
break; break;
...@@ -1267,7 +1268,7 @@ static struct device_domain_info * ...@@ -1267,7 +1268,7 @@ static struct device_domain_info *
iommu_support_dev_iotlb (struct dmar_domain *domain, struct intel_iommu *iommu, iommu_support_dev_iotlb (struct dmar_domain *domain, struct intel_iommu *iommu,
u8 bus, u8 devfn) u8 bus, u8 devfn)
{ {
int found = 0; bool found = false;
unsigned long flags; unsigned long flags;
struct device_domain_info *info; struct device_domain_info *info;
struct pci_dev *pdev; struct pci_dev *pdev;
...@@ -1282,7 +1283,7 @@ iommu_support_dev_iotlb (struct dmar_domain *domain, struct intel_iommu *iommu, ...@@ -1282,7 +1283,7 @@ iommu_support_dev_iotlb (struct dmar_domain *domain, struct intel_iommu *iommu,
list_for_each_entry(info, &domain->devices, link) list_for_each_entry(info, &domain->devices, link)
if (info->iommu == iommu && info->bus == bus && if (info->iommu == iommu && info->bus == bus &&
info->devfn == devfn) { info->devfn == devfn) {
found = 1; found = true;
break; break;
} }
spin_unlock_irqrestore(&device_domain_lock, flags); spin_unlock_irqrestore(&device_domain_lock, flags);
...@@ -4270,7 +4271,7 @@ static void domain_remove_one_dev_info(struct dmar_domain *domain, ...@@ -4270,7 +4271,7 @@ static void domain_remove_one_dev_info(struct dmar_domain *domain,
struct device_domain_info *info, *tmp; struct device_domain_info *info, *tmp;
struct intel_iommu *iommu; struct intel_iommu *iommu;
unsigned long flags; unsigned long flags;
int found = 0; bool found = false;
u8 bus, devfn; u8 bus, devfn;
iommu = device_to_iommu(dev, &bus, &devfn); iommu = device_to_iommu(dev, &bus, &devfn);
...@@ -4302,7 +4303,7 @@ static void domain_remove_one_dev_info(struct dmar_domain *domain, ...@@ -4302,7 +4303,7 @@ static void domain_remove_one_dev_info(struct dmar_domain *domain,
* update iommu count and coherency * update iommu count and coherency
*/ */
if (info->iommu == iommu) if (info->iommu == iommu)
found = 1; found = true;
} }
spin_unlock_irqrestore(&device_domain_lock, flags); spin_unlock_irqrestore(&device_domain_lock, flags);
......
...@@ -631,7 +631,7 @@ static int __init intel_enable_irq_remapping(void) ...@@ -631,7 +631,7 @@ static int __init intel_enable_irq_remapping(void)
{ {
struct dmar_drhd_unit *drhd; struct dmar_drhd_unit *drhd;
struct intel_iommu *iommu; struct intel_iommu *iommu;
int setup = 0; bool setup = false;
int eim = 0; int eim = 0;
if (x2apic_supported()) { if (x2apic_supported()) {
...@@ -697,7 +697,7 @@ static int __init intel_enable_irq_remapping(void) ...@@ -697,7 +697,7 @@ static int __init intel_enable_irq_remapping(void)
*/ */
for_each_iommu(iommu, drhd) { for_each_iommu(iommu, drhd) {
iommu_set_irq_remapping(iommu, eim); iommu_set_irq_remapping(iommu, eim);
setup = 1; setup = true;
} }
if (!setup) if (!setup)
...@@ -856,7 +856,7 @@ static int __init parse_ioapics_under_ir(void) ...@@ -856,7 +856,7 @@ static int __init parse_ioapics_under_ir(void)
{ {
struct dmar_drhd_unit *drhd; struct dmar_drhd_unit *drhd;
struct intel_iommu *iommu; struct intel_iommu *iommu;
int ir_supported = 0; bool ir_supported = false;
int ioapic_idx; int ioapic_idx;
for_each_iommu(iommu, drhd) for_each_iommu(iommu, drhd)
...@@ -864,7 +864,7 @@ static int __init parse_ioapics_under_ir(void) ...@@ -864,7 +864,7 @@ static int __init parse_ioapics_under_ir(void)
if (ir_parse_ioapic_hpet_scope(drhd->hdr, iommu)) if (ir_parse_ioapic_hpet_scope(drhd->hdr, iommu))
return -1; return -1;
ir_supported = 1; ir_supported = true;
} }
if (!ir_supported) if (!ir_supported)
...@@ -917,7 +917,7 @@ static void disable_irq_remapping(void) ...@@ -917,7 +917,7 @@ static void disable_irq_remapping(void)
static int reenable_irq_remapping(int eim) static int reenable_irq_remapping(int eim)
{ {
struct dmar_drhd_unit *drhd; struct dmar_drhd_unit *drhd;
int setup = 0; bool setup = false;
struct intel_iommu *iommu = NULL; struct intel_iommu *iommu = NULL;
for_each_iommu(iommu, drhd) for_each_iommu(iommu, drhd)
...@@ -933,7 +933,7 @@ static int reenable_irq_remapping(int eim) ...@@ -933,7 +933,7 @@ static int reenable_irq_remapping(int eim)
/* Set up interrupt remapping for iommu.*/ /* Set up interrupt remapping for iommu.*/
iommu_set_irq_remapping(iommu, eim); iommu_set_irq_remapping(iommu, eim);
setup = 1; setup = true;
} }
if (!setup) if (!setup)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册