Skip to contentSkip to conversation

drivers/iommu/tegra: Optimize mutex_unlock function call

PATCH New Pushkar Jambhlekar 1 participant 1 message Sep 6, 2017

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drivers/iommu/tegra: Optimize mutex_unlock function call

Code can be optimized more by making single exit point of function and calling mutex_unlock at the end

---
 drivers/iommu/tegra-smmu.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/iommu/tegra-smmu.c +5 -3
index 3b6449e..da38833 100644
@@ -232,20 +232,22 @@ static inline void smmu_flush(struct tegra_smmu *smmu)
 static int tegra_smmu_alloc_asid(struct tegra_smmu *smmu, unsigned int *idp)
 {
 	unsigned long id;
+	int ret = 0;
 
 	mutex_lock(&smmu->lock);
 
 	id = find_first_zero_bit(smmu->asids, smmu->soc->num_asids);
 	if (id >= smmu->soc->num_asids) {
-		mutex_unlock(&smmu->lock);
-		return -ENOSPC;
+		ret = -ENOSPC;
+		goto Exit;
 	}
 
 	set_bit(id, smmu->asids);
 	*idp = id;
 
+Exit:
 	mutex_unlock(&smmu->lock);
-	return 0;
+	return ret;
 }
 
 static void tegra_smmu_free_asid(struct tegra_smmu *smmu, unsigned int id)
Signature · 1 line
2.7.4