Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp5945595ybi; Wed, 12 Jun 2019 11:09:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqy21ckMCpS0n4elnNJ/oCs+iXprL73S1MTxoAy+7E28foAHLc+BuE5WFUElAJLPvYOgDwrJ X-Received: by 2002:a63:610d:: with SMTP id v13mr25917901pgb.341.1560362960519; Wed, 12 Jun 2019 11:09:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560362960; cv=none; d=google.com; s=arc-20160816; b=O+8xALA/3EJJSKUo2nUdlK9gO70imLPb1Ck6adJ8jYtGxA8SQz7N+UuMgML+aCzV41 g35/6vP5L7w/i0OATkYvUWxet93Q7BxE+GVRVzrCKCn9dErIrObHskNK0/7Xm25zADb8 w5C4AD+xTfuKK7Sh6PE2X97LSkB9kowVRTUb1ZJ/s0Ds35vTYWBsqA30DQ7GDgCIGcnY WV6l51Vml/rnELxoYJAzCjabur5TdeiFQtrn03Oz+fHHwtCs4RjxfmHNTVbK8FrB3QvB aPJQ9RYhHNAzGXOGoWY0Y7njYlSJ8jWoLKisWA8zFIrwfyJDiFWUctuvZ0e1FlbKE3Ek 0DQw== 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=b24nbfbSMbzNGIl4HnYnotmAuaxJW7+X12IfC4jT4y0=; b=KFPUPJdqm0CNjJEQ1yNr/M8kqzVNNMsRA1QXZwX16Jg/4YFMOqJxwBhe2j8Xl3Rfgi sz3LNfV+g33sW7dMAVA3tx3T8UeSIKN9GV5B92eKIL/SyqlEkEQqgRQacFvssqmuhq5m FyZ8JEgd/drHeiR1/cfaVDsh3/bbSvaXPEjWHAHgXXj1o5vRZtx6X1rqXKatbz0V4okE hGpMRulL2gMVN7FwtBUjBcfkkYGH693cGgdUzydu7Ei6B+7jA84SR4PtEpxURAvhN9XK 5exmznf3kQVJqYevg3HURxhs6Su89tSv2LQlewORgetLwieQB2R9pNDn31QdWjNs+R6h KftA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=XzlPb9hN; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z3si303574plo.159.2019.06.12.11.09.04; Wed, 12 Jun 2019 11:09:20 -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; dkim=pass header.i=@kernel.org header.s=default header.b=XzlPb9hN; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2436606AbfFLRAX (ORCPT + 99 others); Wed, 12 Jun 2019 13:00:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:49092 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726529AbfFLRAX (ORCPT ); Wed, 12 Jun 2019 13:00:23 -0400 Received: from mail-qt1-f173.google.com (mail-qt1-f173.google.com [209.85.160.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 483C821744; Wed, 12 Jun 2019 17:00:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1560358821; bh=7aLU5Bqdlqn7abZ+7OODf6LyuDW/idcWFbauu3DZwuc=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=XzlPb9hN+5HIVFHLTsbbBjJh0oCS51YAarc73vQgyAqEMvCTRSY3Cc+I3HadF0U8n TmFCY0gdRA4dNN4aXftcOgHuFjB3pflK51gSyl3nxKLvR0RnpRjNji8ySWlnhKH6gV FiprotSDsesZ/mHQ2y71KyooIyFktigjimda/WPU= Received: by mail-qt1-f173.google.com with SMTP id x2so18369410qtr.0; Wed, 12 Jun 2019 10:00:21 -0700 (PDT) X-Gm-Message-State: APjAAAVkZAMDn3Knb8V4DNsPuPcYH2dRouv/SMUIIKLdq0cSaAJMMDRg PVE0w0GsDx+9jXsD7wNAymTcRFh+5QIo5OFndA== X-Received: by 2002:ac8:3908:: with SMTP id s8mr71080428qtb.224.1560358820525; Wed, 12 Jun 2019 10:00:20 -0700 (PDT) MIME-Version: 1.0 References: <20190612010011.90185-1-wangkefeng.wang@huawei.com> <0702fa2d-1952-e9fc-8e17-a93f3b90a958@gmail.com> In-Reply-To: <0702fa2d-1952-e9fc-8e17-a93f3b90a958@gmail.com> From: Rob Herring Date: Wed, 12 Jun 2019 11:00:08 -0600 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH next] of/fdt: Fix defined but not used compiler warning To: Frank Rowand Cc: Kefeng Wang , devicetree@vger.kernel.org, "linux-kernel@vger.kernel.org" , Stephen Boyd 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, Jun 12, 2019 at 10:45 AM Frank Rowand wrot= e: > > Hi Kefeng, > > If Rob agrees, I'd like to see one more change in this patch. > > Since the only caller of of_fdt_match() is of_flat_dt_match(), > can you move the body of of_fdt_match() into of_flat_dt_match() > and eliminate of_fdt_match()? That's fine as long as we think there's never any use for of_fdt_match after init? Fixup of nodes in an overlay for example. Rob > > (Noting that of_flat_dt_match() consists only of the call to > of_fdt_match().) > > -Frank > > > On 6/11/19 6:00 PM, Kefeng Wang wrote: > > When CONFIG_OF_EARLY_FLATTREE is disabled, there is a compiler warning, > > > > drivers/of/fdt.c:129:19: warning: =E2=80=98of_fdt_match=E2=80=99 define= d but not used [-Wunused-function] > > static int __init of_fdt_match(const void *blob, unsigned long node, > > > > Move of_fdt_match() and of_fdt_is_compatible() under CONFIG_OF_EARLY_FL= ATTREE > > to fix it. > > > > Cc: Stephen Boyd > > Cc: Rob Herring > > Cc: Frank Rowand > > Signed-off-by: Kefeng Wang > > --- > > drivers/of/fdt.c | 106 +++++++++++++++++++++++------------------------ > > 1 file changed, 53 insertions(+), 53 deletions(-) > > > > diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c > > index 3d36b5afd9bd..d6afd5b22940 100644 > > --- a/drivers/of/fdt.c > > +++ b/drivers/of/fdt.c > > @@ -78,38 +78,6 @@ void __init of_fdt_limit_memory(int limit) > > } > > } > > > > -/** > > - * of_fdt_is_compatible - Return true if given node from the given blo= b has > > - * compat in its compatible list > > - * @blob: A device tree blob > > - * @node: node to test > > - * @compat: compatible string to compare with compatible list. > > - * > > - * On match, returns a non-zero value with smaller values returned for= more > > - * specific compatible values. > > - */ > > -static int of_fdt_is_compatible(const void *blob, > > - unsigned long node, const char *compat) > > -{ > > - const char *cp; > > - int cplen; > > - unsigned long l, score =3D 0; > > - > > - cp =3D fdt_getprop(blob, node, "compatible", &cplen); > > - if (cp =3D=3D NULL) > > - return 0; > > - while (cplen > 0) { > > - score++; > > - if (of_compat_cmp(cp, compat, strlen(compat)) =3D=3D 0) > > - return score; > > - l =3D strlen(cp) + 1; > > - cp +=3D l; > > - cplen -=3D l; > > - } > > - > > - return 0; > > -} > > - > > static bool of_fdt_device_is_available(const void *blob, unsigned long= node) > > { > > const char *status =3D fdt_getprop(blob, node, "status", NULL); > > @@ -123,27 +91,6 @@ static bool of_fdt_device_is_available(const void *= blob, unsigned long node) > > return false; > > } > > > > -/** > > - * of_fdt_match - Return true if node matches a list of compatible val= ues > > - */ > > -static int __init of_fdt_match(const void *blob, unsigned long node,> = - const char *const *compat) > > -{ > > - unsigned int tmp, score =3D 0; > > - > > - if (!compat) > > - return 0; > > - > > - while (*compat) { > > - tmp =3D of_fdt_is_compatible(blob, node, *compat); > > - if (tmp && (score =3D=3D 0 || (tmp < score))) > > - score =3D tmp; > > - compat++; > > - } > > - > > - return score; > > -} > > - > > static void *unflatten_dt_alloc(void **mem, unsigned long size, > > unsigned long align) > > { > > @@ -764,6 +711,59 @@ const void *__init of_get_flat_dt_prop(unsigned lo= ng node, const char *name, > > return fdt_getprop(initial_boot_params, node, name, size); > > } > > > > +/** > > + * of_fdt_is_compatible - Return true if given node from the given blo= b has > > + * compat in its compatible list > > + * @blob: A device tree blob > > + * @node: node to test > > + * @compat: compatible string to compare with compatible list. > > + * > > + * On match, returns a non-zero value with smaller values returned for= more > > + * specific compatible values. > > + */ > > +static int of_fdt_is_compatible(const void *blob, > > + unsigned long node, const char *compat) > > +{ > > + const char *cp; > > + int cplen; > > + unsigned long l, score =3D 0; > > + > > + cp =3D fdt_getprop(blob, node, "compatible", &cplen); > > + if (cp =3D=3D NULL) > > + return 0; > > + while (cplen > 0) { > > + score++; > > + if (of_compat_cmp(cp, compat, strlen(compat)) =3D=3D 0) > > + return score; > > + l =3D strlen(cp) + 1; > > + cp +=3D l; > > + cplen -=3D l; > > + } > > + > > + return 0; > > +} > > + > > +/** > > + * of_fdt_match - Return true if node matches a list of compatible val= ues > > + */ > > +static int __init of_fdt_match(const void *blob, unsigned long node, > > + const char *const *compat) > > +{ > > + unsigned int tmp, score =3D 0; > > + > > + if (!compat) > > + return 0; > > + > > + while (*compat) { > > + tmp =3D of_fdt_is_compatible(blob, node, *compat); > > + if (tmp && (score =3D=3D 0 || (tmp < score))) > > + score =3D tmp; > > + compat++; > > + } > > + > > + return score; > > +} > > + > > /** > > * of_flat_dt_is_compatible - Return true if given node has compat in = compatible list > > * @node: node to test > > >