Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp2043669ybj; Wed, 6 May 2020 09:35:47 -0700 (PDT) X-Google-Smtp-Source: APiQypL/ZlgeGpSCMtZ8ZrqXghjh3YjRoQSMftJO0KYhd2eqHjXxewBpl+cqxFGS5UkjNDHIl5Ph X-Received: by 2002:a17:906:37d0:: with SMTP id o16mr7755913ejc.368.1588782947720; Wed, 06 May 2020 09:35:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588782947; cv=none; d=google.com; s=arc-20160816; b=qGfuqRopkL0MvweDwbEaTxSGjM5BGpGi73OypwVh3SybMVItjJTknqXg/rpf/2kmvH 7NP3cmDO87mwD3V/BDkmJfTCXtP2Itg8Ndh0CDYTMfVllZzAKBrDWu90O1SV65UPCRNo c1L5q4yfD0HOBuPbSZkr90c/sG1QMotX6dlUD4ikSK62u10ZuFwPra+PlXQBGRTCbaYW PX2xJVwjMfgrIXsStjApaw2+wc8kATyXjvZGbhHE1wRIJ9TFtPug0PupxiKQL1H76suU ErxDOZig0Fayrx9mjnuvxm/lYT9eRHZ2Abc5ANeoN5nRtezJNv0PsTTibHQ8SerA58pw pZhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=Y5qtMHomnLIwdTHoA0zzmwpPm538uNAG4qMQT/2KWFc=; b=PLfHiMGX10LFSTKyj7bCkw26HPGdA4K2TxMvXKrgyR143kUCpjz1UKpp5BzohjNQQh tIubEK3WGe+STfQj1TGeVfk3x7tkSRcBR+Mby4X/0GKuSSQ7VN3eMbm9IsCaDNAeswQ+ N9ZPG30uztoD5YUp9W7D+Uw53m9iOItX8QnTe/KqK2k5a9iZ0dLmfNE5qucpDeybbGt2 URnKj+CYdzMyZ5hYOWtdJv56f4edykVQWfqQKer14iTFQbOWJgWRY1YXQ14WZjdvyBsO 8wWfnpxxpD5jJ2Yt/noFYpZBhn8C0FJb8FhhTjn9cO/D32gsKUVB6Cnzc58sUCer7qps MZ4Q== 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 l23si1463302ejc.135.2020.05.06.09.35.24; Wed, 06 May 2020 09:35:47 -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 S1730442AbgEFQco (ORCPT + 99 others); Wed, 6 May 2020 12:32:44 -0400 Received: from asavdk4.altibox.net ([109.247.116.15]:58596 "EHLO asavdk4.altibox.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730295AbgEFQco (ORCPT ); Wed, 6 May 2020 12:32:44 -0400 Received: from ravnborg.org (unknown [158.248.194.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by asavdk4.altibox.net (Postfix) with ESMTPS id B68C980500; Wed, 6 May 2020 18:32:38 +0200 (CEST) Date: Wed, 6 May 2020 18:32:37 +0200 From: Sam Ravnborg To: Dmitry Osipenko , Rob Herring Cc: Thierry Reding , Laurent Pinchart , Rob Herring , Frank Rowand , linux-tegra@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Subject: Re: [PATCH v5 1/6] of_graph: add of_graph_get_local_port() Message-ID: <20200506163237.GA19296@ravnborg.org> References: <20200418170703.1583-1-digetx@gmail.com> <20200418170703.1583-2-digetx@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200418170703.1583-2-digetx@gmail.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-CMAE-Score: 0 X-CMAE-Analysis: v=2.3 cv=MOBOZvRl c=1 sm=1 tr=0 a=UWs3HLbX/2nnQ3s7vZ42gw==:117 a=UWs3HLbX/2nnQ3s7vZ42gw==:17 a=kj9zAlcOel0A:10 a=pGLkceISAAAA:8 a=7gkXJVJtAAAA:8 a=e5mUnYsNAAAA:8 a=cgQggk8NgEdHG04IN60A:9 a=CjuIK1q_8ugA:10 a=E9Po1WZjFZOl8hwRPBS3:22 a=Vxmtnl_E_bksehYqCbjh:22 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Dmitry On Sat, Apr 18, 2020 at 08:06:58PM +0300, Dmitry Osipenko wrote: > In some case, like a DRM display code for example, it's useful to silently > check whether port node exists at all in a device-tree before proceeding > with parsing the graph. > > This patch adds of_graph_get_local_port() which returns pointer to a local > port node, or NULL if graph isn't specified in a device-tree for a given > device node. > > Signed-off-by: Dmitry Osipenko Nice little helper function. Reviewed-by: Sam Ravnborg Rob - OK to commit to drm-misc-next? Sam > --- > drivers/of/property.c | 32 +++++++++++++++++++++++--------- > include/linux/of_graph.h | 7 +++++++ > 2 files changed, 30 insertions(+), 9 deletions(-) > > diff --git a/drivers/of/property.c b/drivers/of/property.c > index 252e4f600155..5dbeccaabb86 100644 > --- a/drivers/of/property.c > +++ b/drivers/of/property.c > @@ -608,15 +608,7 @@ struct device_node *of_graph_get_next_endpoint(const struct device_node *parent, > * parent port node. > */ > if (!prev) { > - struct device_node *node; > - > - node = of_get_child_by_name(parent, "ports"); > - if (node) > - parent = node; > - > - port = of_get_child_by_name(parent, "port"); > - of_node_put(node); > - > + port = of_graph_get_local_port(parent); > if (!port) { > pr_err("graph: no port node found in %pOF\n", parent); > return NULL; > @@ -765,6 +757,28 @@ struct device_node *of_graph_get_remote_port(const struct device_node *node) > } > EXPORT_SYMBOL(of_graph_get_remote_port); > > +/** > + * of_graph_get_local_port() - get local port node > + * @node: pointer to a local endpoint device_node > + * > + * Return: First local port node associated with local endpoint node linked > + * to @node. Use of_node_put() on it when done. > + */ > +struct device_node *of_graph_get_local_port(const struct device_node *node) > +{ > + struct device_node *ports, *port; > + > + ports = of_get_child_by_name(node, "ports"); > + if (ports) > + node = ports; > + > + port = of_get_child_by_name(node, "port"); > + of_node_put(ports); > + > + return port; > +} > +EXPORT_SYMBOL(of_graph_get_local_port); > + > int of_graph_get_endpoint_count(const struct device_node *np) > { > struct device_node *endpoint; > diff --git a/include/linux/of_graph.h b/include/linux/of_graph.h > index 01038a6aade0..1fdeb72c7765 100644 > --- a/include/linux/of_graph.h > +++ b/include/linux/of_graph.h > @@ -54,6 +54,7 @@ struct device_node *of_graph_get_remote_port_parent( > struct device_node *of_graph_get_remote_port(const struct device_node *node); > struct device_node *of_graph_get_remote_node(const struct device_node *node, > u32 port, u32 endpoint); > +struct device_node *of_graph_get_local_port(const struct device_node *node); > #else > > static inline int of_graph_parse_endpoint(const struct device_node *node, > @@ -116,6 +117,12 @@ static inline struct device_node *of_graph_get_remote_node( > return NULL; > } > > +static inline struct device_node *of_graph_get_local_port( > + const struct device_node *node) > +{ > + return NULL; > +} > + > #endif /* CONFIG_OF */ > > #endif /* __LINUX_OF_GRAPH_H */ > -- > 2.26.0 > > _______________________________________________ > dri-devel mailing list > dri-devel@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/dri-devel