Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp147885pxa; Tue, 18 Aug 2020 19:11:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJymu8wZ3WwXerfzSI+7R+SETSqY0xs5hlXyGwGYk7algPJatn8yLBmpq44UwrFYFGwGHPFP X-Received: by 2002:a17:906:138b:: with SMTP id f11mr22348153ejc.310.1597803070703; Tue, 18 Aug 2020 19:11:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597803070; cv=none; d=google.com; s=arc-20160816; b=EQpAxuGld96Qi8FRGyAHeYlv6fRk8kCkJX+P/2i1icQ/U3nGenp2baspuLpBx8OP1Z HITNKjvGIdBx6AwKSXhZYLOGDA25dfLd3Ct09ifrGEA2EhnKpIeEGQIJMzkzpYpCqDaJ 5vZXylf/UcqZRlCs/Z+EdGEZGi2nBV892aDCb1yyVGfqOMTHtoix7WvYqja2wV27rogQ n7+wNYUkNggGuc0O4OlaZ3qHh8v/Q2k3X4Ze6YyAKp7txFv04/VYGHdKg54d4gD3RQJa cSQUNuYfos9vZ1DcVyyw8HAmNey5pKBQSPY3mNlqY7PrPCz3H+1/2Rt0Xwxb4uNlqls7 U4Hg== 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:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=2ufPygghtlAHv/okW+h2EXhUykUyMYMCwDjH8jeMarE=; b=a66uChK/ogUiSevF2Z3mr4dl+vkju7RKVlxglCiVsfddyThoMlLKhHxd+Db8TDWyCO kbeVsgHpHXS3P9YZCATGFnEX/nGsSikBrcGjIi/gLfpcRnHBjaKQyzCpMDwbrxEZ+vfq stOX6nI7EFgUYhyrfW0UKnYt5WOx5MgGHUsgOxxa/0IeQrQKicHU6EGcLTnvSaA0eL2S RlKWO09OOAzWYVivjOhnWWHy1i4PVXlbuFlWRtdC+pJ/sTsEb72eTNz44EBXbmpObANO 6+V/LzZRuaxH2qofEoIQ3Ors1vFfGl+IRPLrNJxeWYDsJu5TZJmZVTHI4WpmJ91D067M CiZQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s18si14137292eja.619.2020.08.18.19.10.47; Tue, 18 Aug 2020 19:11:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727047AbgHSCFu (ORCPT + 99 others); Tue, 18 Aug 2020 22:05:50 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:53804 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726772AbgHSCFq (ORCPT ); Tue, 18 Aug 2020 22:05:46 -0400 Received: from DGGEMS402-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id A1E71CAB0D9349564C39; Wed, 19 Aug 2020 10:05:44 +0800 (CST) Received: from DESKTOP-C3MD9UG.china.huawei.com (10.174.177.253) by DGGEMS402-HUB.china.huawei.com (10.3.19.202) with Microsoft SMTP Server id 14.3.487.0; Wed, 19 Aug 2020 10:05:34 +0800 From: Zhen Lei To: Oliver O'Halloran , Dan Williams , Vishal Verma , "Dave Jiang" , Ira Weiny , Markus Elfring , linux-nvdimm , linux-kernel CC: Zhen Lei Subject: [PATCH v2 3/4] libnvdimm/bus: simplify walk_to_nvdimm_bus() Date: Wed, 19 Aug 2020 10:05:02 +0800 Message-ID: <20200819020503.3079-4-thunder.leizhen@huawei.com> X-Mailer: git-send-email 2.26.0.windows.1 In-Reply-To: <20200819020503.3079-1-thunder.leizhen@huawei.com> References: <20200819020503.3079-1-thunder.leizhen@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.174.177.253] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org I first want to move dev_WARN_ONCE() after "if (dev)" branch, but further I find the "if (dev)" can only be true when is_nvdimm_bus(dev) successed. No functional change. In fact, the compiler can optimize it correctly. I run "size drivers/nvdimm/bus.o" and find nothing has changed. So it's just source code level optimization, make us can read it faster. Signed-off-by: Zhen Lei --- drivers/nvdimm/bus.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/nvdimm/bus.c b/drivers/nvdimm/bus.c index 955265656b96c73..1d89114cb6ab93e 100644 --- a/drivers/nvdimm/bus.c +++ b/drivers/nvdimm/bus.c @@ -316,10 +316,9 @@ struct nvdimm_bus *walk_to_nvdimm_bus(struct device *nd_dev) for (dev = nd_dev; dev; dev = dev->parent) if (is_nvdimm_bus(dev)) - break; - dev_WARN_ONCE(nd_dev, !dev, "invalid dev, not on nd bus\n"); - if (dev) - return to_nvdimm_bus(dev); + return to_nvdimm_bus(dev); + + dev_WARN_ONCE(nd_dev, 1, "invalid dev, not on nd bus\n"); return NULL; } -- 1.8.3