Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2114323imu; Wed, 21 Nov 2018 06:56:34 -0800 (PST) X-Google-Smtp-Source: AFSGD/WCALFlEvltmxaii6d1uLPat6B0bIAW9I7qaAJ8HvsF/2qwF73Iml8n8nRevZuu5qT4ClAa X-Received: by 2002:a63:134f:: with SMTP id 15mr6243114pgt.19.1542812194797; Wed, 21 Nov 2018 06:56:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542812194; cv=none; d=google.com; s=arc-20160816; b=GuB0n5CBG3IOOdqjKVfLJ/eX4pqyVhFnvZ2ROffAWbG8OSKomjEpD/nwa3f7JBWWN8 TzYiy6XMspi3ykhm4cjcan/eRUrwiaXHl6s2oHWIe7QTvAaUxuuTxUHl71J5VKBqGVQJ XuD/vlkluQMIaSkpc7FpcskGWzomnIOR8mNLetEb1gu1/CJJ85dmnmnwCWQtUoUfqfHm Er8eD8prDUQ8/FpeBZv8QqS5K92HXR+HOfAuZ4S4bH7TE0dGbVz3WXK/xLKYGMGyQeVP MvzultMTcG5yUNj/yhUGbjs57pytPnlzUvKUECLIxVNKH+kuwCH6R1TcJc1D/gqsmXG1 XWUQ== 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:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=jOLPfuDHHk1eKDm7ckP55CmtgPqN4J9JQcL1km5Owic=; b=j0fjxDjOVadWD5u5MJX/aLd8khO5piMvhONUsuhXBf/Q2zg+zU5GSUdu6ntlhpU/6R +upAHXX9J11mlaXpX6VfCIvJKDX/KbHGrbBEbkwxTeWfAvfjmI2VwQuMgSoL9UQLnlwx zH5cWtbKFNmF5vM8dzTk1qn8Erhq2V97+v6Aymp8GBRwry85LiTv5HX131oH0jxDgs/Q pWY+ZDkfAN3xZIdDuhWzIWx6erP7ewm/PxyHjoYOcUaN5dLC3eir22QT7oUX16eaUaE6 SkO2yAXYOwRzWYIiEeRYX27pza6AMyBz3YUEOhPIS/Aa5TYlGrWpeHpeI16HU6wVi0wz l7Yw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=KL6jo+Bj; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c12si11312997pgh.257.2018.11.21.06.56.14; Wed, 21 Nov 2018 06:56:34 -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=@gmail.com header.s=20161025 header.b=KL6jo+Bj; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730517AbeKVBWt (ORCPT + 99 others); Wed, 21 Nov 2018 20:22:49 -0500 Received: from mail-it1-f196.google.com ([209.85.166.196]:55939 "EHLO mail-it1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726064AbeKVBWs (ORCPT ); Wed, 21 Nov 2018 20:22:48 -0500 Received: by mail-it1-f196.google.com with SMTP id o19so9133039itg.5; Wed, 21 Nov 2018 06:48:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=jOLPfuDHHk1eKDm7ckP55CmtgPqN4J9JQcL1km5Owic=; b=KL6jo+BjlBH/MPyM9b7azICE+YwAk5jJWaM2urnSRJ/rAhVABF5kzz8fkMToyYoZFu YN47QZuaggW7QfbocvMR8dtvU7rrBMC7nWZZx6fnJQZ+XK/pcMrsDt1QEI3m2kOfNx1L SHB8PUyM7llJChuwATo4J8tHHwf18bZAWrINnkUTnCQvnCOC18ZaE21qpuZiYxADVGs5 UScgC1do60gyYf5O0Fx8Dg5lcofVW3O1YD8SDpWLYpkYG3V0Sne+8pqSWtmf+eHB8poB trgy76u8m5tByB7o/se04dDcQb2NAJgtp89iKHT50qq0rMJe2kMSbCU41DSiNEU4xZq1 vm7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=jOLPfuDHHk1eKDm7ckP55CmtgPqN4J9JQcL1km5Owic=; b=PgF0FoK7JNK+xdy76B3oEVJXM+RzOyIsh78ldGi/YiMLVcWkE5z8SJype50z6FhDfO FprQrVxRniz6zP3rd2hNo+cBab7NN/ReYnctty9LEbUZF0Ih44sZDHmtbhOC3UMG++t1 wfxUJKmwbGaUgEmSsnWbafrP6HGEus+9PTNYjMDUCibuUwV1fNOcKFh5OT0DWuZjH+u5 p8tJcFDtDupDBlnVuZdZBoj4J12YNg2DEvTV5BaMKbOffS2V3zmhM2I2STK29NH+xEoG 43vH5frtp4odPN48/9N9PRlGFx/2kFL4HAjgYwIQIden6qm3Nro5sZ9gZOJNwYymULfL bfVA== X-Gm-Message-State: AA+aEWaUCNnKOV6Vkq+AKVgBLtG+y6Dh7MoJFsywz3UWGvF+G/YnQbIH +BK2dMbwNGI/H6vcaMjMmcMwiSlX8Qj+2cJFUSA= X-Received: by 2002:a02:5184:: with SMTP id s126mr1455132jaa.12.1542811685064; Wed, 21 Nov 2018 06:48:05 -0800 (PST) MIME-Version: 1.0 References: <20181121141204.22819-1-tiny.windzz@gmail.com> <2d534bbb-7b75-8521-bf88-36b52c918d19@nvidia.com> <20181121144320.GA6446@ulmo> In-Reply-To: <20181121144320.GA6446@ulmo> From: Frank Lee Date: Wed, 21 Nov 2018 22:47:42 +0800 Message-ID: Subject: Re: [PATCH] soc/tegra: refactor soc_is_tegra() To: Thierry Reding Cc: jonathanh@nvidia.com, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 refacto= r > > > 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_ma= tch[] =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 I like both, how aboout you? Yours=EF=BC=8C Yangtao