Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp325537imm; Thu, 31 May 2018 00:45:45 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJIQmY3P4EZgcfxr9qQ96m8UZ5Pxqfcei4pYCnAe0jh/rfApDeNwBb5Fci1T7kviIdjvScf X-Received: by 2002:a62:9bc9:: with SMTP id e70-v6mr2491301pfk.15.1527752745745; Thu, 31 May 2018 00:45:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527752745; cv=none; d=google.com; s=arc-20160816; b=pXGBKvoLGs7guxO0uLyWakUR5rVFN946wowENoqRYF2Coyxb6eecyaAMowtxNED2Gf pjINL+oOn6XlWZsaJtUXp0B4Z4YVfyLmndt1PBxHjX7tb2bnwR7fZUUxNVBX5RkcX5BE pRBFgC3IxnsFGeRMo11HNu/5xfV2dlAERqHHd1v7z8XQ8r8eB51ltqeIpabOZsEptXkX f6dq06nFqVsOF0abReSxE9YCnjBfFX7ZF2tyYolUWaitLmAlAbwLxV+sAon08XWog/wM ETKNIriUG15LjFjF3eQ/fU1f4JTuXY2GUa+ueUITqZEiiAwHtUaMT9BfFnUsiCLEMPwG Yumw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=vpj/N7+K8RKMF8WCyAlhmKNh1tT1kxMO8WHtYgNUaT0=; b=dmDpHe+ZhZ27+rCqcpCOZryutEUoEdYRxDgPT7fRAuVOvQYIYUzVeS+30WqU5KMIEl vNN7n8zKfx1gYtYJbmBoDFRUDBuRki9Glo+u8ROhmN9a5xAH2MgKiUoVyaZvNhstnqUS /v73M6Ey2muOdbxtsCFFABqw9orErRV9pD7vrnPVepRdSkv4zcCwS2luW08fOJKMFOu+ vPa8DZB4+D4vNL1Mx0R0YIrcyIM5MBs6UAyXzCswZSkGrjc2o5KAc41tDZZylaa+090B 5Pvvhv3vxwo75fDAA2qxgx3Z41S82TabTALImHEsjUcP/ZnS9NnctOybJ7j0XJwtpzvp L7pQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f9-v6si34567450plo.568.2018.05.31.00.45.31; Thu, 31 May 2018 00:45:45 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754092AbeEaHns (ORCPT + 99 others); Thu, 31 May 2018 03:43:48 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:48942 "EHLO huawei.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1754037AbeEaHnm (ORCPT ); Thu, 31 May 2018 03:43:42 -0400 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id F3D9C422843BF; Thu, 31 May 2018 15:43:37 +0800 (CST) Received: from localhost (10.177.23.164) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.382.0; Thu, 31 May 2018 15:43:31 +0800 From: Zhen Lei To: Robin Murphy , Will Deacon , Matthias Brugger , Rob Clark , Joerg Roedel , linux-mediatek , linux-arm-msm , linux-arm-kernel , iommu , linux-kernel CC: Zhen Lei , Hanjun Guo , Libin , Guozhu Li , "Xinwei Hu" Subject: [PATCH 1/7] iommu/dma: fix trival coding style mistake Date: Thu, 31 May 2018 15:42:43 +0800 Message-ID: <1527752569-18020-2-git-send-email-thunder.leizhen@huawei.com> X-Mailer: git-send-email 1.9.5.msysgit.0 In-Reply-To: <1527752569-18020-1-git-send-email-thunder.leizhen@huawei.com> References: <1527752569-18020-1-git-send-email-thunder.leizhen@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.177.23.164] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The static function iova_reserve_iommu_regions is only called by function iommu_dma_init_domain, and the 'if (!dev)' check in iommu_dma_init_domain affect it only, so we can safely move the check into it. I think it looks more natural. In addition, the local variable 'ret' is only assigned in the branch of 'if (region->type == IOMMU_RESV_MSI)', so the 'if (ret)' should also only take effect in the branch, add a brace to enclose it. No functional changes. Signed-off-by: Zhen Lei --- drivers/iommu/dma-iommu.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c index ddcbbdb..4e885f7 100644 --- a/drivers/iommu/dma-iommu.c +++ b/drivers/iommu/dma-iommu.c @@ -231,6 +231,9 @@ static int iova_reserve_iommu_regions(struct device *dev, LIST_HEAD(resv_regions); int ret = 0; + if (!dev) + return 0; + if (dev_is_pci(dev)) iova_reserve_pci_windows(to_pci_dev(dev), iovad); @@ -246,11 +249,12 @@ static int iova_reserve_iommu_regions(struct device *dev, hi = iova_pfn(iovad, region->start + region->length - 1); reserve_iova(iovad, lo, hi); - if (region->type == IOMMU_RESV_MSI) + if (region->type == IOMMU_RESV_MSI) { ret = cookie_init_hw_msi_region(cookie, region->start, region->start + region->length); - if (ret) - break; + if (ret) + break; + } } iommu_put_resv_regions(dev, &resv_regions); @@ -308,8 +312,6 @@ int iommu_dma_init_domain(struct iommu_domain *domain, dma_addr_t base, } init_iova_domain(iovad, 1UL << order, base_pfn); - if (!dev) - return 0; return iova_reserve_iommu_regions(dev, domain); } -- 1.8.3