From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751896AbdIFFuv (ORCPT ); Wed, 6 Sep 2017 01:50:51 -0400 Received: from mail-pg0-f68.google.com ([74.125.83.68]:37094 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751646AbdIFFus (ORCPT ); Wed, 6 Sep 2017 01:50:48 -0400 X-Google-Smtp-Source: ADKCNb7J+F6oi3T8r2bBqLSVLF+7rTEQguxNRb59ay67SSC9qfxK3Xwdtf2htAMbjzW1dHBjnUXI+A== From: Pushkar Jambhlekar To: Hiroshi Doyu , Joerg Roedel , Thierry Reding , Jonathan Hunter Cc: iommu@lists.linux-foundation.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org, Pushkar Jambhlekar Subject: [PATCH] drivers/iommu/tegra: Optimize mutex_unlock function call Date: Wed, 6 Sep 2017 11:20:37 +0530 Message-Id: <1504677037-3224-1-git-send-email-pushkar.iit@gmail.com> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Code can be optimized more by making single exit point of function and calling mutex_unlock at the end Signed-off-by: Pushkar Jambhlekar --- drivers/iommu/tegra-smmu.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/iommu/tegra-smmu.c b/drivers/iommu/tegra-smmu.c index 3b6449e..da38833 100644 --- a/drivers/iommu/tegra-smmu.c +++ b/drivers/iommu/tegra-smmu.c @@ -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) -- 2.7.4