From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 60424C44529 for ; Tue, 21 Jul 2026 06:54:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=yZPli2S6cZzTtPxNu5kCcB+M+KQUeHMnkMABY4ADLcw=; b=O6K37KqfeTEORvZlt2wZlQRMcv hvamaorAVpLIJ11bMg8sMwvnuejVYVuCawSrW8atFm91TFhaSUkSuTWsUo43RxAPQEOir0ZVUQfNA ZXWMT5dyRNxfbYL8vhVuJ8iJ8J7iOOvkGgO9qrs01xYomKGNTOEKOmfXmimEERdvm9vwUsrrxpLPM MjgnfJ4BPcab4OMBFZ7o/U6lb8m24/UOgIpT3SH+1M1j+VNwso1GtzHd708upN5MyJoGLmartJ4Mi MWjS1YAoCBcdFpKqvJVN386aliHtX/xg+EqAwwr4X+0fuVtTCWk5wClC1cmdV7lVlSK1QvK2bLE4l QZE51b9A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1wm4NL-00000008Zy5-0Xoz; Tue, 21 Jul 2026 06:54:47 +0000 Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1wm4NG-00000008Zut-1y6C for linux-mediatek@lists.infradead.org; Tue, 21 Jul 2026 06:54:44 +0000 Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-2cf50c6f235so29438565ad.0 for ; Mon, 20 Jul 2026 23:54:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1784616881; x=1785221681; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=yZPli2S6cZzTtPxNu5kCcB+M+KQUeHMnkMABY4ADLcw=; b=bATjwOCelUvlEtDH/uHfHCO8KEekFq5LoXRDyTbXjxa8PlVZ8Q31SFtGtTJsxXHajo 1onD0UBSte6bgjzUY/9D7t3FV9xeJo5wFzc9D0/K5uo2Eqn41OWXzHKabLWHv/36+pbL dsIBpVQMm9T4Cf8qX+ECbiU6rReNodPCdUbY4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784616881; x=1785221681; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=yZPli2S6cZzTtPxNu5kCcB+M+KQUeHMnkMABY4ADLcw=; b=Wf2kRrqmSB5vKyzlfOumIsgVvRU3YNKpshV9sRLTQpdijxIjj0/stZaiVGN5e132mV /DmYjgkxwiXt/+wrJ2bxV0TAmwG3nq5p66aJRBywTg0CIPiOKdHYiezzofRtRPSWiILp kJ6iYsGLdKIjDybES4JmHaYYd/WWGGpMCYelUml+ELkh0JnULe2g3NPB6yPYEJkQaXGF wG1TWk11BwNNEMpTpwABfNpnc5WI5vyJLdT8Bx/nQPmeuMhZs67/0B1vepkKxfPr8H08 JwdJx0xlZ3amcgagcyPVRkXgUUsfM0Wn1HbALkUrY4aBjHWuq0/LsQMXUWpI0AuJFZhQ iN2Q== X-Forwarded-Encrypted: i=1; AHgh+RraaAOC/gFn9sLMLk3mTD+te3w+cP6ajqaUQwhDFWdqlI6NSB13FIp8lSSqGzNZKtYOmNrWnXU7mPKZTCgmIg==@lists.infradead.org X-Gm-Message-State: AOJu0YxBTYQhdmMTvP59PDZiTwjOrzmVFEjY3r7Je2tEGICnvx87Kaan HFYL2oZRfh8b3MQk4MY2gLR/GmJuKuIDOAZrpbNxasjNqvT8RWTP2QW4lDUZUMshfw== X-Gm-Gg: AR+sD13o+54n1IROBuecU4vclimoaMQbWdR5nVrKiEtEj01BDZUcozl1rRHBR6hMcRw OAts6bW9b1SgMc6keLKTwwzkMfX+WowG2FhveQ0zmpTAZiEZ82pB5gYteREY14RD1wf/VnYtEvl PzF9az06M2ex2hSWWjFiDan0u50HLSRB1DRArcDQkXlXYwmMXNx8lBO1EQpkiwbjtjtgI6G+BUa cwskdphNbC95oUxRr2hQlU0v2kcTKf7uZ5SKPUTm1nlaT+TQ40NR7nSNfra0q555pYgY+LoiYse zGSp4fTS3TimcflyH6FQKQQSv/qzT0sz370WQxhXSpnHegi+rPDYtDlTawA+7jLWUHvdhzZoXNM yRxDQuhbKDK3Xf4c8BDA5k6SbM5E1Xm6wmlU2iTvbhTvQkzYuyPZnljsYrOf8v8Kka8goxG1qS+ q5Pc+dOl4mocNPdaq8QN0na7pW0iyYQcaPjqx5ejgVXihjYw/OVHR24OdCLX4= X-Received: by 2002:a17:902:ce8a:b0:2cc:61e8:5fba with SMTP id d9443c01a7336-2cf349a2153mr182756085ad.32.1784616881554; Mon, 20 Jul 2026 23:54:41 -0700 (PDT) Received: from wenstp920.tpe.corp.google.com ([2a00:79e0:201d:8:3916:f048:32c3:931f]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2cf3448ee77sm69716005ad.4.2026.07.20.23.54.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jul 2026 23:54:41 -0700 (PDT) From: Chen-Yu Tsai To: Bartosz Golaszewski , Greg Kroah-Hartman , Andy Shevchenko , Daniel Scally , Heikki Krogerus , Sakari Ailus , "Rafael J. Wysocki" , Danilo Krummrich , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno Cc: Chen-Yu Tsai , linux-acpi@vger.kernel.org, driver-core@lists.linux.dev, linux-pm@vger.kernel.org, linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Manivannan Sadhasivam , Alan Stern , Bartosz Golaszewski Subject: [PATCH v6 01/16] device property: Add fwnode_graph_get_port_by_id() Date: Tue, 21 Jul 2026 14:53:56 +0800 Message-ID: <20260721065413.2306137-2-wenst@chromium.org> X-Mailer: git-send-email 2.55.0.229.g6434b31f56-goog In-Reply-To: <20260721065413.2306137-1-wenst@chromium.org> References: <20260721065413.2306137-1-wenst@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260720_235442_525566_334CFEC7 X-CRM114-Status: GOOD ( 14.95 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org In some cases the driver needs a reference to the port firmware node. Once such case is the upcoming USB power sequencing integration. The USB hub port is tied to the corresponding port firmware node if it exists. Provide a helper for this. Reviewed-by: Bartosz Golaszewski Reviewed-by: Andy Shevchenko Signed-off-by: Chen-Yu Tsai --- Changes since v5: - Dropped left-over declaration in header (Sashiko) Changes since v4: - Added flags parameter so users can specify whether incomplete ports are returned or not (Sashiko) Changes since v2: - Moved "Return:" kernel-doc section to the end. (Andy) Changes since v1: - New patch --- drivers/base/property.c | 29 +++++++++++++++++++++++++++++ include/linux/property.h | 2 ++ 2 files changed, 31 insertions(+) diff --git a/drivers/base/property.c b/drivers/base/property.c index 9387bb83eb54..950defc0c55a 100644 --- a/drivers/base/property.c +++ b/drivers/base/property.c @@ -1346,6 +1346,35 @@ int fwnode_graph_parse_endpoint(const struct fwnode_handle *fwnode, } EXPORT_SYMBOL(fwnode_graph_parse_endpoint); +/** + * fwnode_graph_get_port_by_id - get the port matching a given id + * @fwnode: parent fwnode_handle containing the graph + * @id: id of the port + * @flags: fwnode lookup flags + * + * The caller is responsible for calling fwnode_handle_put() on the returned + * fwnode pointer. + * + * Does not return ports that belong to disabled devices or endpoints that + * are unconnected, unless FWNODE_GRAPH_DEVICE_DISABLED is passed in @flags. + * + * Return: A 'port' firmware node pointer with refcount incremented. + */ +struct fwnode_handle *fwnode_graph_get_port_by_id(struct fwnode_handle *fwnode, + u32 id, + unsigned long flags) +{ + struct fwnode_handle *ep; + + ep = fwnode_graph_get_endpoint_by_id(fwnode, id, 0, + flags | FWNODE_GRAPH_ENDPOINT_NEXT); + if (!ep) + return NULL; + + return fwnode_get_next_parent(ep); +} +EXPORT_SYMBOL_GPL(fwnode_graph_get_port_by_id); + const void *device_get_match_data(const struct device *dev) { return fwnode_call_ptr_op(dev_fwnode(dev), device_get_match_data, dev); diff --git a/include/linux/property.h b/include/linux/property.h index 14c304db4664..01ea010cb2f9 100644 --- a/include/linux/property.h +++ b/include/linux/property.h @@ -505,6 +505,8 @@ int fwnode_get_phy_mode(const struct fwnode_handle *fwnode); void __iomem *fwnode_iomap(struct fwnode_handle *fwnode, int index); +struct fwnode_handle *fwnode_graph_get_port_by_id(struct fwnode_handle *fwnode, u32 id, + unsigned long flags); struct fwnode_handle *fwnode_graph_get_next_endpoint( const struct fwnode_handle *fwnode, struct fwnode_handle *prev); struct fwnode_handle * -- 2.55.0.229.g6434b31f56-goog