Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp3461098imm; Mon, 4 Jun 2018 04:06:55 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJ4gnJuxI2sAD8PYDYspwp8XWzQMVpX/AlDLNOCJwQZh6T+wdBcv22uVzowyHlYSkVY5HWr X-Received: by 2002:a62:f551:: with SMTP id n78-v6mr21036943pfh.200.1528110415465; Mon, 04 Jun 2018 04:06:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528110415; cv=none; d=google.com; s=arc-20160816; b=ZLrjzy4vR0S7rbLDaA5a9M1NVgYSRcEO+XMUslOzhtzDqn8mtzYt/IiBTJzm3yrWR9 is9R8OKvZ0br7uIjcZHhzf/uCWmkytfLN4fmDLzShGZXeQtVfty5oEOt5hBF609esxbv RTv5yzVVJ4t67pX+gqg7AFLE1UFR0lUxrh+hD7dqa9V1VzwYpTM8RNIJYI92/n5pKxxk BMv3n3hkHXo4uu8i+AFXJdUlGUZX4M1Fec9by86XtY72MMx20OfyviRK9+zenri53U6E 8T6aAUxQDISFUiqAF0GfJv9kRbfXKTeOBWCTBxktC0Ulps36xMVsNUu76dM0DRSc+XDY eIwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:cc:references:to :subject:arc-authentication-results; bh=Bz2SQRVn9sGQUpuYSMACdhQJZ7VlGugOzxeXk/1WjyY=; b=lNgW5ZX/qaKVOY0bAyfCtNN9IqHsjoENifOcYOocTuDtwAWBdgsvounUKqep4PxpGM iv5FAa1wuoJ2Y+AfPbAQahvvq0T/oueOEfsBccnLg6pg9TU+sBcaHng0RrEUCLVq1cpX cYCk9zLn2wLZ+tPXoNV9ioKIPEVLPrRIJHyxw3LgI3cvR9dFphIRiaBWB+54808ykzTe ISj1Vr2x2JrD83+de2MiDJLBzbhL/O/BSCeLuzVa9sMm8UxrJiG0agDz6kyWnoUbd6pm 91YRcRgJK2NH9RbV6wp0XT4jGnJEWkB3rT5CroorXMwVF3Qre8/eyrJEuhsuoszgzp9/ 8qSQ== 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 t4-v6si46522425plb.313.2018.06.04.04.06.40; Mon, 04 Jun 2018 04:06:55 -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 S1752537AbeFDLGP (ORCPT + 99 others); Mon, 4 Jun 2018 07:06:15 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:8631 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752062AbeFDLGN (ORCPT ); Mon, 4 Jun 2018 07:06:13 -0400 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id D8355F1644B26; Mon, 4 Jun 2018 19:05:59 +0800 (CST) Received: from [127.0.0.1] (10.177.23.164) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.382.0; Mon, 4 Jun 2018 19:05:51 +0800 Subject: Re: [PATCH 1/7] iommu/dma: fix trival coding style mistake To: Robin Murphy , Will Deacon , Matthias Brugger , Rob Clark , Joerg Roedel , linux-mediatek , linux-arm-msm , linux-arm-kernel , iommu , linux-kernel References: <1527752569-18020-1-git-send-email-thunder.leizhen@huawei.com> <1527752569-18020-2-git-send-email-thunder.leizhen@huawei.com> CC: Hanjun Guo , Libin , "Guozhu Li" , Xinwei Hu From: "Leizhen (ThunderTown)" Message-ID: <5B151CFA.10808@huawei.com> Date: Mon, 4 Jun 2018 19:05:30 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit 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 On 2018/5/31 21:03, Robin Murphy wrote: > On 31/05/18 08:42, Zhen Lei wrote: >> 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. > > As before, I disagree - the logic of iommu_dma_init_domain() is "we expect to have a valid device, but stop here if we don't", and moving the check just needlessly obfuscates that. It is not a coincidence that the arguments of both functions are in effective order of importance. OK > >> 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. > > 'ret' is clearly also assigned at its declaration, to cover the (very likely) case where we don't enter the loop at all. Thus testing it in the loop is harmless, and cluttering that up with extra tabs and braces is just noise. OK, I will drop this patch in v2 > > Robin. > >> 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); >> } >> > > . > -- Thanks! BestRegards