From patchwork Tue Dec 7 05:47:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 1798 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-pg1-f198.google.com (mail-pg1-f198.google.com [209.85.215.198]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 386753F03E for ; Tue, 7 Dec 2021 06:49:09 +0100 (CET) Received: by mail-pg1-f198.google.com with SMTP id d2-20020a656202000000b00325603f7d0bsf8135122pgv.12 for ; Mon, 06 Dec 2021 21:49:09 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1638856147; cv=pass; d=google.com; s=arc-20160816; b=CG6L/VIEonvjmZ2vKI9JkTah7+HJ6itDJkjr7ZuPxPPuiUVYH/cGmdjifYkfnkxM8P 3Z9Ic4Fgok0WRGVuNrB/LS8XS1LrEhwblX3rqFBldCY169gozJC6b+jIKgsnT2iBwbFT rjqzc9IAR/sS84ELB84DPhfuiLCHEXSskMJQuC1QoIG3WnCMmGO8XR2QzV3YdRAEvPrJ qc457qt0rekATnHXjYT/kVUgZfMmgEMu27fSWPlIjDQ5IhCd/bH9wtKos2mMjrN/RiVy 5+o7bTk+AGGiTfigPX3D1a2HcRS3hEkCWAJe2hfbDSTbaWnApqODagO/sYQ1A5m7pE4u fh/Q== 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:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=sJyaXjhtc024cDlLpwHz32TcBanL2kvK8O50ZN+f26k=; b=hFt/DMlpxNLygJwQoPuGzYAQvVtNwIa4LNt0qyGoy78D61vEzNEVzG91SU/InuaqH8 Gr2+owhprOJXYzpSnqwtlP9/onpc0TXLzNFW4GvuQzMUtqRjkU9wbv2G5FRk0MDSZEA0 +erQi8PJy4sPvCKAni1/XIFEtLF2UYJbkCdJVjokHBzBvaOUR+OeL1Q+HcKWI5kidcGx gINgwypJOHwCi2v3GZ1aCX0xlWYKTFx0kBKdmLvSPwD/NmfvuivwztOg3henJzDA2jE5 xuXWrMy/p9yqoJbPZPf1oFZjIKpwqmDcibOzwW8YckxFc2WRCBrWPN4bC2yNFyUabM81 +Z4Q== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=drb8lSpo; 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:in-reply-to:references :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=TG3E7taBjSyw6gAGGkDA80JGPvKZ8iip1rGf0tNX9AGwsXYUeNhQ1GSm6ciiCRbR7j FsyvuZEoaU4VHJ9jZ29zNA/0JRPQ8Pzu6CfYR3mKGzR8umPj5lhoF2vskkxuzjknlUkp BAiabKrbFSFg/LUHOB7c7RpV5rclBEZlySuxE= 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:in-reply-to :references: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=QQgOwajUH5wXksTLOHdM6Ssf3weY7XjlSeNQSVi09no32bh4Q+mmeVfOTfntj2tcKH ZI+OOu/9B1JwA/U7q/as1uz0vXEngwqRoQT0CwLjbX7i8RP34Xg9aoJZYtQWyCi2ZJCO 0FbWtIcVWo7ABRL6v73JlkKWx30Lyt6EX1B2vf6Zy3AYKtsCXZ/NY+C0AScqp2L1T3AS vrVbt8UT9xVLYISbP4xeAuv8MT6NZhq0jnWVUbHATX+828T8F9CDyU0VJh5YAFBo/u8N G0Sponq9EsnGGZzEs4F6TxtqRzh673ESQ/bIZg2Ccs53Jfh2Pbe+VSBWYRLuBsm9+5nE HKug== X-Gm-Message-State: AOAM530loePAynrrWUinyEm+jfNdJ6X4JiT0k5goX++KZcAWxGG3ccyY a84hEmRk6W0UDWl5kW16ndt6sTdl X-Google-Smtp-Source: ABdhPJwvzvxawdr6ExBw2wtHGMXuIO3n7m3lZBI5q3G13zqQ92FC/F7KpzakgFEH9eEvgyIrPGCfRA== X-Received: by 2002:a17:90b:3142:: with SMTP id ip2mr4035839pjb.207.1638856147766; Mon, 06 Dec 2021 21:49:07 -0800 (PST) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:903:1c2:: with SMTP id e2ls9527703plh.9.gmail; Mon, 06 Dec 2021 21:49:07 -0800 (PST) X-Received: by 2002:a17:90b:2252:: with SMTP id hk18mr4101275pjb.218.1638856147087; Mon, 06 Dec 2021 21:49:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1638856147; cv=none; d=google.com; s=arc-20160816; b=kTnTQxXOnt6l9VXbr2DM2HCoTwCrhtoZmLY7kspnXoSJ0RqEKF4IXznIXipEvV7P+g apTEB/n47TczJo4y/6cn7UGNV2GACrTaHWfVYPbbX4WWUDMHzmFRgi0Thlu9fUNeMaYT 8GVSalfzM84NlorET1N5G3SwLssbuJTstcY+FTZwH2rFW63KA6MTscUsdIgvwBvn5al1 q6s/UV7WGCM+A4+txw03zTLRm+gQQxptZozGE+6a2/HIBvzC8pRTZ9HcnjsgFTBZIZzm DXxbnZHsUcUrCXN7clPz8Gg6huQQ1OX0XokgApRK0ymIQ85A0JgZ1PUym30LgQ1+Wbkh f0Lg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=1KDzFg9UJvJcv5oD+yqgslacyH8b6y34UOPGPd05YOk=; b=EeKO8+tYPcFAZJ4W0iot1Mb2ByoiE+8VFQslv7y5KJJ1M1mv7Q10YyE4vLTwY3YjDS BWSjCaUZAIhw3vcLgNtShgPw7IgJDMmGSZbsAbqzqJsvas/Cwoo8dJPLQ2NCv2NQhO2C sIBK3GCHM/dAALJcQtTVj7x0mcyPDykB2SswHK1BBi4duT5GMW6cUP101j/KHOXw57GQ UONpY3Qe5sH5mKiFc3UjWcyJbuaHRV1XHfYpnGaktcCyr/RwZQJbawZ8NiIZgblfdIwf FCpfXTVGcLjzDLPa7J2DCqWEyo0fn8rUkiRoK5A85emnhX8QxNLqOnHPHrndM7GMJqcR 9aSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=drb8lSpo; 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 k19sor8336654pls.44.2021.12.06.21.49.07 for (Google Transport Security); Mon, 06 Dec 2021 21:49:07 -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:18d:b0:142:8ab:d11f with SMTP id z13-20020a170903018d00b0014208abd11fmr49391383plg.47.1638856146790; Mon, 06 Dec 2021 21:49:06 -0800 (PST) Received: from localhost.localdomain ([2405:201:c00a:a0a9:ac1e:ca0f:5f0a:c85a]) by smtp.gmail.com with ESMTPSA id f7sm14496352pfv.89.2021.12.06.21.48.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Dec 2021 21:49:06 -0800 (PST) From: Jagan Teki To: Rob Herring , Frank Rowand , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Laurent Pinchart , Robert Foss , Neil Armstrong , Andrzej Hajda Cc: dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-amarula@amarulasolutions.com, Jagan Teki Subject: [PATCH 1/2] of: Add helper to lookup non port child node Date: Tue, 7 Dec 2021 11:17:46 +0530 Message-Id: <20211207054747.461029-2-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211207054747.461029-1-jagan@amarulasolutions.com> References: <20211207054747.461029-1-jagan@amarulasolutions.com> 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=drb8lSpo; 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) {