Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2114470imu; Wed, 21 Nov 2018 06:56:42 -0800 (PST) X-Google-Smtp-Source: AFSGD/XkI+Hq7bU7Q/NsXIKj9KFy0b/0L08hdxsmxCSwj05pfDvdHkFFt3Fx1G+JuCUSOZ56sw6J X-Received: by 2002:a63:eb0e:: with SMTP id t14mr6319937pgh.445.1542812202653; Wed, 21 Nov 2018 06:56:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542812202; cv=none; d=google.com; s=arc-20160816; b=Tr5ulf2ET6/mhdMT652rYuNqxTOj9MOqlcgc5iiXp+3I1/R8RBJz0Urwbe8R3Pd6Wc 5qDiF/5+tgDKJb4mD23aeyje7347s6c3Q/JdWFnNh0r4ZZGrgS0imGmJAMtWlPRLvdKg apY2pbf1k8BLIvKTMdXroa+9Am2aCPRmBx2+YnnGJ2V3fTHMl1rUAFj2/TYiZcqb0uwJ 2hkR+ggpA9FoHHpoMZKC6WEbg/g1MOglF8DBcksK5BtKrBCOZe8ebivVINia7Mp9peZ5 WLfRpFXbwLGbbj7sYiqNYbz0T3x/YEaS3rcpntWVI+AIK8M1n6McY+1afFPJQ9gW1KrS wupQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:dkim-signature:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=6VazzTqeSfEs2AaT9Hu5nIkDrWgi+ldjY7k9jEGWMFU=; b=OgncXuKIdYDMU2wRmKG6r99XGyX0s4QWn4woZgZCa30JGXCXQsWkuh5oEDCWp8ldLb /sP/V1ws1DH92+RpsPVHhiB3XYvDPL2mPOaoZ5O9/RbSvGeDfTG7xU5wxKpr2MXEti6y MBvm7sUR+20H3lWrOPVeFDJiNE30A4fDsCZR2F/W8FgLbGRSW27ttlhz+3SbvCEOSmup DgrLDTkTCvyk4LGoHwkNe3pgjiCRE+ZT6JtVmIu7lSoYMKFaNwcfU+XzBbBpGkPGMqpj cp7pHpt1pDtSUKbaCsrkTaDTg5RsAKzm1cKfC87rTBmFQge+eebp0g4iohiuZIE06xgE g8og== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=dPrZRBWs; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c190-v6si16752775pfa.0.2018.11.21.06.56.22; Wed, 21 Nov 2018 06:56:42 -0800 (PST) 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; dkim=pass header.i=@nvidia.com header.s=n1 header.b=dPrZRBWs; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730949AbeKVBZm (ORCPT + 99 others); Wed, 21 Nov 2018 20:25:42 -0500 Received: from hqemgate16.nvidia.com ([216.228.121.65]:16401 "EHLO hqemgate16.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728298AbeKVBZl (ORCPT ); Wed, 21 Nov 2018 20:25:41 -0500 Received: from hqpgpgate101.nvidia.com (Not Verified[216.228.121.13]) by hqemgate16.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Wed, 21 Nov 2018 06:51:06 -0800 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate101.nvidia.com (PGP Universal service); Wed, 21 Nov 2018 06:50:57 -0800 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Wed, 21 Nov 2018 06:50:57 -0800 Received: from [10.21.132.148] (172.20.13.39) by HQMAIL101.nvidia.com (172.20.187.10) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Wed, 21 Nov 2018 14:50:56 +0000 Subject: Re: [PATCH] soc/tegra: refactor soc_is_tegra() To: Frank Lee , Thierry Reding CC: , References: <20181121141204.22819-1-tiny.windzz@gmail.com> <2d534bbb-7b75-8521-bf88-36b52c918d19@nvidia.com> <20181121144320.GA6446@ulmo> From: Jon Hunter Message-ID: Date: Wed, 21 Nov 2018 14:50:54 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: X-Originating-IP: [172.20.13.39] X-ClientProxiedBy: HQMAIL103.nvidia.com (172.20.187.11) To HQMAIL101.nvidia.com (172.20.187.10) Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1542811866; bh=6VazzTqeSfEs2AaT9Hu5nIkDrWgi+ldjY7k9jEGWMFU=; h=X-PGP-Universal:Subject:To:CC:References:From:Message-ID:Date: User-Agent:MIME-Version:In-Reply-To:X-Originating-IP: X-ClientProxiedBy:Content-Type:Content-Language: Content-Transfer-Encoding; b=dPrZRBWsX4OUbFbX0xJb/Yq6/bbTncZEpz3/QsZWiK3s75vnquiVbWz+xPev1cEv5 mJbS/a4blq7mJ6EIgbBqzcQHIiKlWR3bndOmAU+/3QATwHrHBl9Giq9TFEnZwvAO5u sPK2wg0E2OoSCCrekGZqTzBYHLaj9uvFrbNfg74f/gFuiEzx+8AJWRjFYZWkPJB0tT UhAIm+mZhUq6Rd3PvDj8Ya+YT7x6TZnKVZyq+31JaE3uRJJ9DWEcEqKqrVV1N1DDZm Zg0TonE94V8HOJISt77tus0n6UnWjQqxQzdrs4CDc8baOb3cTJCbFcBDYBQi9yH48y +lxSc2SmtaFiA== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 21/11/2018 14:47, Frank Lee wrote: > On Wed, Nov 21, 2018 at 10:43 PM Thierry Reding > wrote: >> >> On Wed, Nov 21, 2018 at 02:34:57PM +0000, Jon Hunter wrote: >>> >>> On 21/11/2018 14:12, Yangtao Li wrote: >>>> of_find_node_by_path() acquires a reference to the node returned by >>>> it and that reference needs to be dropped by its caller.soc_is_tegra() >>>> doesn't do that, so fix it.Call of_machine_is_compatible() to refactor >>>> soc_is_tegra() whcih automatically manages the reference count. >>>> >>>> Signed-off-by: Yangtao Li >>>> --- >>>> drivers/soc/tegra/common.c | 12 +++++++----- >>>> 1 file changed, 7 insertions(+), 5 deletions(-) >>>> >>>> diff --git a/drivers/soc/tegra/common.c b/drivers/soc/tegra/common.c >>>> index cd8f41351add..0b40700b672a 100644 >>>> --- a/drivers/soc/tegra/common.c >>>> +++ b/drivers/soc/tegra/common.c >>>> @@ -22,11 +22,13 @@ static const struct of_device_id tegra_machine_mat= ch[] =3D { >>>> >>>> bool soc_is_tegra(void) >>>> { >>>> - struct device_node *root; >>>> + struct of_device_id *match =3D tegra_machine_match; >>>> >>>> - root =3D of_find_node_by_path("/"); >>>> - if (!root) >>>> - return false; >>>> + while(match->compatible){ >>>> + if(of_machine_is_compatible(match->compatible)) >>>> + return true; >>>> + match++; >>>> + } >>>> >>>> - return of_match_node(tegra_machine_match, root) !=3D NULL; >>>> + return false; >>>> } >>> >>> Ugh ... sorry, I thought that of_machine_is_compatible() looped through >>> the matches. OK, let's stick with your initial fix. >> >> Actually I prefer this one. Even if it is slightly more verbose, I think >> it's much clearer what's actually going on. Also this hides all of the >> OF node reference counting in a core function, so it's worth the extra >> line, in my opinion. >> >> Thierry > Hi Jon=EF=BC=9A >=20 > I like both, how aboout you? Yes fine with me too. However, looks like there is some formatting that needs to be fixed up above. Please make sure you run checkpatch.pl on your patches. Otherwise ... Acked-by: Jon Hunter Thierry, pick up this version if you prefer. Cheers Jon --=20 nvpublic