From patchwork Thu May 31 07:42:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhen Lei X-Patchwork-Id: 137332 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp6277921lji; Thu, 31 May 2018 00:43:45 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJg3jCD2r69wQr8nckz0Mlbyzzcy7MfBwHxlatwzScvwmXxYMGcycCO7xcY2TNxQTgdccHz X-Received: by 2002:a17:902:6105:: with SMTP id t5-v6mr5935058plj.138.1527752625845; Thu, 31 May 2018 00:43:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527752625; cv=none; d=google.com; s=arc-20160816; b=qXOTmLBllDlBwbp7YCPFpfKUOSXe0SQdyGYn7QsxPj77RYqFgp9mVDENb6eQ1vEqvx tIgvSfwXZIw0BepooiOP5oK8ZgqqJ3g9pqWIBAgJD6FLGJLmVcNYkcvZlMJoYaVbD6Q+ Jbzhkq0WoSYRUWCsRKVjfMt9kLXky+Lvkk37YinliAfJY2HHlxQNogd4N5exCoPep+Uc KPFcU35xjqlavi5gPHg8bylOuIw7Cvbr8bKYM6XeWkx4IyZD1vSLmZsRgUAO0Mo3t+My iUkYi67dGReggtCZsocwRMxuNgQtq3Vq2a0YGZ07jEY4Se0Yz6eHo88yNT61tOdRgqg1 JKdQ== 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=DhIJxDvVYqgWRfF+5N7sVy+QXj/OINQFPHHAsLxNLQA=; b=NfQgleHhflGzp6u9N1GtFoxgc8m/nKsCPyqfJMPaa1O1vofH+u5HmL6TaOcwBITCi7 JY8NiiGIIxnlhyckMzwv8EbXG+grVbXysLeT0XfBu1ploTHS9Vj0LRlZSeI83evXFNei waXRA2EXimtIWrkG/TQPKwfVG0uKvWLikA+D5B+pKTbpbi/u1RH9mBNUkfVB0+VSf/VK J2ZyIe/Kl+OA6r+SiEjCkUO/3hLdQLPxQCHQJVS2TKetE1zvAeWW73uZ6srBxWpbq4pI sMTFgE8eej8/Gqq4uyLN8wUkLd+nc+iT20UHHQ+jCXHPcXkUzCdxQmUtifjBwV75TlAR +IjQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-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 j11-v6si11664355pgn.129.2018.05.31.00.43.45; Thu, 31 May 2018 00:43:45 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-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-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753934AbeEaHno (ORCPT + 13 others); Thu, 31 May 2018 03:43:44 -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 X-Originating-IP: [10.177.23.164] X-CFilter-Loop: Reflected Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@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(-) -- 1.8.3 -- To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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); }