From patchwork Tue Dec 7 05:34:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 1796 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-pg1-f197.google.com (mail-pg1-f197.google.com [209.85.215.197]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id E242D3F9DF for ; Tue, 7 Dec 2021 06:35:02 +0100 (CET) Received: by mail-pg1-f197.google.com with SMTP id d2-20020a656202000000b00325603f7d0bsf8119349pgv.12 for ; Mon, 06 Dec 2021 21:35:02 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1638855300; cv=pass; d=google.com; s=arc-20160816; b=QNVvIGRYzpHLrcvi+34pkKc6fgUw8h3D45iLKZ3bV61GmgNWJFEXW57ObL5cWRoBZM KdTPFQdP8VodQ72yG5E7TdL4AMwjMafF8PxxerDk4S5BhyQdmPuIdGRRGxG1JEBsQIYo g4bHdTRQZ5yCraWFI2yhMx1Ko4ooX0E2o9w3PoRBahq3TcSchrVQZnFN3IRLvQKaVDEn e4DbMwpAjBCMAdq0ceU8xAXRmO0FqVvYLGWvPNYMsAZRs5W76iIUa2u4nuAwVqlZvuN+ tK0sd+aP7BbCRMBmPQ4xV94lkIfTowN+oN3YDlAZIR36I/2/l3PF0BfYR1lC7PcCTrWF TLng== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:mime-version:message-id:date:subject:cc:to :from:dkim-signature; bh=sJyaXjhtc024cDlLpwHz32TcBanL2kvK8O50ZN+f26k=; b=XnAuwg0jI1a+pGcNZRbrH/jFKkty+tTT+yCWOZpvcktPgxazt7H0YKzLfidMhdx/cH 6dpIVA/NWq4xpw5c6i5W6/IN13ED/QRdrn29g5IfAfKPPpZIIYjXsQAwPQ9xjWu6Lqwu NYeC40my8oOCJ8Xj7dANxZeXfLaqaPYQl/WJpIE5Z2t0qGCXPG3QDeP1Lwx2jGqBV18K w7nR5nbflCCGyw0JQTcKpiPG7mefoItwqqbOxaPIouq3k+t+rec2E4fhiMFJpCJ2LHfq QCOne8UY6gAiex40mTEQYoWTyXKCUorrV2QsDZKRgQOES6Wo55LmPwYKtndKHx950xmt rVxg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=FH+ewFry; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:cc:subject:date:message-id:mime-version:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=sJyaXjhtc024cDlLpwHz32TcBanL2kvK8O50ZN+f26k=; b=j2KuCEMCi8waZmQPBETd62dHrFeZx+83jfjFROo3TIDKJIv2M6noGmv5KN9yAeS3sI YsrlMP4jos4yotQk2TZVxQqbmZwfLBJLIfVO8fRgdO2ZIydCvgr6teup1a0owpHymglN 8ycrZFR+ktiJ2qS3vIZnjcRt61GO7xW9pMMMs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :x-original-sender:x-original-authentication-results:precedence :mailing-list:list-id:x-spam-checked-in-group:list-post:list-help :list-archive:list-unsubscribe; bh=sJyaXjhtc024cDlLpwHz32TcBanL2kvK8O50ZN+f26k=; b=HPSfQmebD/qtYE8QvPQCKKQaS0//LNMlDL84XE0AhvrNXAP7gfVn56EOchY5mnTzsU Hwwq21cLD3ZcfcPNlaQoMaxXKJVpqYHyxq+4IcwSYD4vy95XBvM3Rj7JDbU0HPiSRWqb mR1mLdQJhyc+yJWlvDJLodABKwHFVNZsNs0l/4i1Ot0umrwiqwVnK+Q+Hl/slEhwuKQT fB1Wk2+e4ToOH5/iSYwgwAI2gYzF8cbZC98SAyVL1e4A3Ja0Zz+6xeO8sHssrHQ3nJg8 SqlMI7fHZg2CzeIF73kimUM1Vwn2SmQD61llBm1fhCw0MYQfsjI5D8fpccf4mLRTX0Vn MEpg== X-Gm-Message-State: AOAM5323X7ohLX1gwPpIbb8IHhTRfRy+UGqm6tiEexmK4nVMF6GZH0ZN NsuTXuTGIlEMuZRVlPF4P57Oi82H X-Google-Smtp-Source: ABdhPJyAePXR5jNoAWkrygUHBixU0kDkiqn9A452RcbE5DOfnmhEtAOIFAp9kc295dKVd96dEb8Qqg== X-Received: by 2002:a05:6a00:22c8:b0:4af:437c:5f4c with SMTP id f8-20020a056a0022c800b004af437c5f4cmr6342442pfj.71.1638855299777; Mon, 06 Dec 2021 21:34:59 -0800 (PST) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:6a00:138d:: with SMTP id t13ls7359660pfg.10.gmail; Mon, 06 Dec 2021 21:34:59 -0800 (PST) X-Received: by 2002:a63:213:: with SMTP id 19mr21733966pgc.499.1638855299068; Mon, 06 Dec 2021 21:34:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1638855299; cv=none; d=google.com; s=arc-20160816; b=Xb0LphPmETuOBm/xZpmzxCNUxEY9xSEY2C1BTZTanWr0vEAcYboSMAwxlmkF740cxh Rwb6c/Nd/aI0NsScZQXq3sG2phDQhKUmb4vwVQW4TERUlBna1bC0LB594F7PczLNtwXL xIVyvMuzPKKRBtFUYsfqYM7xZ2AKEqgLXnpU4MKsDyYx8NQtbukgQmTWA74ymC3jPAFx p5jLFQi1Q/DNASmZ03gYPE5PItXVHuxvDyCKQKJ+mJupc8Yc1joHYQfYppC3VaX416eZ xtAoNB2YdS0T9wdnGHw9p3zI+wN+weO/5yEWtp2GsmjZLun4zcHYlKpCpyN1ZxzAdq95 8BUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:dkim-signature; bh=1KDzFg9UJvJcv5oD+yqgslacyH8b6y34UOPGPd05YOk=; b=S86n9Pn5Rh61rjXyQoJm01qQjsWBQN4mmHZT+GH3ntKkvjeBh/Z20c7CQr3qSxtOmw FX8j3VGBLo3UQ+CWEYC7DxwuJ08CWW/ccu9k3HZCkNNuGZgFdqfEo9tkvKCI87oCHzsV KH3idzqnigndehu86mYU107HNkOY5P/QoPKMDCvxoRZ3K+ggVjGTX8VhmiUANEACksFI DLMtnf7JbvUBVExjDhy+InvY0b7tWO//VUdn//cLuzWzoaDAzTeg8dEmHa30HaffmHSm Bcfqo4QwQgT4RZv2DUCtWAXEyRRebDwbFQS46xgyVy/wS66E9kq6VEosIan7eeNJMeuY lUHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=FH+ewFry; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id z5sor8316559plk.53.2021.12.06.21.34.57 for (Google Transport Security); Mon, 06 Dec 2021 21:34:57 -0800 (PST) Received-SPF: pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Received: by 2002:a17:903:2344:b0:142:25b4:76c1 with SMTP id c4-20020a170903234400b0014225b476c1mr49371668plh.43.1638855296388; Mon, 06 Dec 2021 21:34:56 -0800 (PST) Received: from localhost.localdomain ([2405:201:c00a:a0a9:ac1e:ca0f:5f0a:c85a]) by smtp.gmail.com with ESMTPSA id i2sm14699374pfg.90.2021.12.06.21.34.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Dec 2021 21:34:55 -0800 (PST) From: Jagan Teki To: linux-amarula@amarulasolutions.com Cc: Jagan Teki Subject: [PATCH 1/2] of: Add helper to lookup non port child node Date: Tue, 7 Dec 2021 11:04:44 +0530 Message-Id: <20211207053445.460387-1-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Original-Sender: jagan@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=FH+ewFry; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Add of_get_non_port_child() helper that can be used to lookup non port child nodes. Some OF graphs don't require 'ports' to represent the next output instead, it simply adds a child node on a given parent node. This helper lookup that child node, however that child node is not a 'port' on given parent as 'port' based nodes are looked up via of_graph_get_remote_node(). Example OF graph representation of DSI host, which doesn't have 'ports'. dsi { #address-cells = <1>; #size-cells = <0>; port { dsi_in_tcon0: endpoint { remote-endpoint = ; }; panel@0 { reg = <0>; }; }; Signed-off-by: Jagan Teki --- drivers/of/base.c | 29 +++++++++++++++++++++++++++++ include/linux/of.h | 6 ++++++ 2 files changed, 35 insertions(+) diff --git a/drivers/of/base.c b/drivers/of/base.c index 61de453b885c..31bbf885b0f8 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -854,6 +854,35 @@ struct device_node *of_get_compatible_child(const struct device_node *parent, } EXPORT_SYMBOL(of_get_compatible_child); +/** + * of_get_non_port_child - Find the non port child node for a given parent + * @node: parent node + * + * This function looks for child node which is not port child for given parent. + * + * Return: A node pointer if found, with refcount incremented, use + * of_node_put() on it when done. + * Returns NULL if node is not found. + */ +struct device_node *of_get_non_port_child(const struct device_node *parent) +{ + struct device_node *child; + + for_each_child_of_node(parent, child) { + if (of_node_name_eq(child, "port")) + continue; + + if (!of_device_is_available(child)) { + of_node_put(child); + continue; + } + break; + } + + return child; +} +EXPORT_SYMBOL(of_get_non_port_child); + /** * of_get_child_by_name - Find the child node by name for a given parent * @node: parent node diff --git a/include/linux/of.h b/include/linux/of.h index ff143a027abc..3e699becef82 100644 --- a/include/linux/of.h +++ b/include/linux/of.h @@ -290,6 +290,7 @@ extern struct device_node *of_get_next_child(const struct device_node *node, extern struct device_node *of_get_next_available_child( const struct device_node *node, struct device_node *prev); +extern struct device_node *of_get_non_port_child(const struct device_node *parent); extern struct device_node *of_get_compatible_child(const struct device_node *parent, const char *compatible); extern struct device_node *of_get_child_by_name(const struct device_node *node, @@ -678,6 +679,11 @@ static inline bool of_have_populated_dt(void) return false; } +static inline struct device_node *of_get_non_port_child(const struct device_node *parent) +{ + return NULL; +} + static inline struct device_node *of_get_compatible_child(const struct device_node *parent, const char *compatible) {