From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1222C406279 for ; Thu, 9 Jul 2026 09:57:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.179 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783591065; cv=none; b=nVtYC9zC//9deQ7Uqtep+XbJi2IZ4+G9ArhhLr1OAtK9gyur2Rsuwy6BpR8qjFEMFUQ6WN3f43A6a0E8LLt6aAAPFVrPGm/YZODg5Zn9YJFuD9UGqH09ynKvhAJm/AWGoYIsq/xzZQpdq29IYalOtCJMwfhS753nSFMVIw2aX+g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783591065; c=relaxed/simple; bh=4DJIO6YuC356lqlH329zbmGaURuVWRrLiiMzUuEp/p0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=swAXomxfp+UzlTgN0rXgnjmOB/6zYE4QGk3QTHWYlPJYsUHk+SszrDSNgg/+Cd7QSDfJS0OL5jrjxfNEQVsjOWFqxaXBP8MhRYzZwKrHhgSTjbNFbTBm+zz6bIlUeM5zqMN8zq/Xsz6YN+jy4f6JqHSICdbUKkTd2Tu3W9gPh7I= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=VpKb4dF2; arc=none smtp.client-ip=209.85.214.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="VpKb4dF2" Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-2cc84e77e78so5065245ad.2 for ; Thu, 09 Jul 2026 02:57:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1783591063; x=1784195863; darn=vger.kernel.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=xZ53TpctVBGf+9janmV3YEfLWaus5++lNyVuWbfltaU=; b=VpKb4dF2OYREU2Hx9QoLP97g5mKbnBggXT2OWukVfXdk1/SZvYRh5fLCxkYBgpBOyA RSuiEiLkXSoueOxR2U0Ggnq9VUVXc+icvoA+JP+oU+JFoXNpFXjSJyiKTaR73UfINlV0 v1APqjhI5j94k6EjFZ4Na1CPy7LwtNEnH5FOI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783591063; x=1784195863; 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=xZ53TpctVBGf+9janmV3YEfLWaus5++lNyVuWbfltaU=; b=PSogx+yMeoevBXIFRclp4qe+wm9rRzMZ6NBpf1YgkLvSwEPYTTX+bzLHO3lib4usFY fsjup+pDyrmPJn4G8cM2XysyDPn+F/DJlg/eM49ilGRGB/DeZfBfX5/rPKXa7RhQKMDL J+hv/XD9PQ3IuKfxI43L9i/EngkJc9wF2XBoFG3x+l4epEErxt+LayPvFbMaazICmx4V QffOpw418R863em9ZVXf61XyGcvF+pyBGk+1Ea4RNg3dpR024ZJxVkTFR2UiyGHd4jSg iWToHtovN1nZZaZptPUoXBu1jwynqcKlVm8PJ7nk8Qc/RO0ETraIEbjIjaMNrqnpfTg1 uKnQ== X-Forwarded-Encrypted: i=1; AHgh+RrfIYPDTZ6rzREzo/mG+5oveWN2q4S2BrSsfdcLuGADUQ0fVIs+2ILluBTmB7oGVfWYgIUKUbPng27hBVw=@vger.kernel.org X-Gm-Message-State: AOJu0YyD7WOeyshJMgZGYxg056p+amKKr/F9oer/AIA65xNriYxHjx/W NO6lN9GFwOm+nJtdGk8xIEsS/yiCua1P/Bsw932FJ8YZZyip/otS+GtzxAoyBgspYQ== X-Gm-Gg: AfdE7clA5JkHCROa4KmPJ8sXK1PKYg3ez+LfNT+YetcU82Jibk3ddo3Pk+DyVfiXzEh v0mEUfkhzYVZ+udZ4Es8HpmXwDNIeXuFjnazap7GlemsPZYupxMZ7pXragl4I3aqcDeijfKl3xb FKY+0CguDQ/MxXxAwSuaV8svohrB/L7qVxdlG16Jxrl/BaIyEtgI+BCYAhfPrU11rwq3C1xLr6c DpZtE9wxnHzQX/2tZKUCEjuuSEA3oRSRTQJslawxInRWv9y9lUq5ekz16Zbwc0vRLgzDffgUOfu slhBL4PfemAbxGGR076Xv5BXE5OVv3+ZoE2YsAb5l7OViHvhJ83UZs0HhKlHVoRR5FPLEOk7aXa uvhcdfxZHB0kBFhsZmfnTtt3yiynf2igrLcrOZNfeJrJevyciPAGSq68kwVxIfmc3k9/si0eHfT rrbEjM5oXGDBK6Uxw3HfXaKapO1+KZUxGDgxZrTK7eVoUawTpjKBguOdG0d51LIVVS0osq5g== X-Received: by 2002:a17:902:f68f:b0:2ca:c411:78a with SMTP id d9443c01a7336-2ccea371ddamr71754425ad.3.1783591063427; Thu, 09 Jul 2026 02:57:43 -0700 (PDT) Received: from wenstp920.tpe.corp.google.com ([2a00:79e0:201d:8:bd09:6ddb:180a:69c5]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2ccc9d5bd2fsm41082155ad.78.2026.07.09.02.57.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jul 2026 02:57:42 -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 v4 01/14] device property: Add fwnode_graph_get_port_by_id() Date: Thu, 9 Jul 2026 17:57:06 +0800 Message-ID: <20260709095726.704448-2-wenst@chromium.org> X-Mailer: git-send-email 2.55.0.795.g602f6c329a-goog In-Reply-To: <20260709095726.704448-1-wenst@chromium.org> References: <20260709095726.704448-1-wenst@chromium.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 v2: - Moved "Return:" kernel-doc section to the end. (Andy) Changes since v1: - New patch --- drivers/base/property.c | 22 ++++++++++++++++++++++ include/linux/property.h | 1 + 2 files changed, 23 insertions(+) diff --git a/drivers/base/property.c b/drivers/base/property.c index 9387bb83eb54..3e3e19ef66a9 100644 --- a/drivers/base/property.c +++ b/drivers/base/property.c @@ -1346,6 +1346,28 @@ 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 + * + * The caller is responsible for calling fwnode_handle_put() on the returned + * fwnode pointer. + * + * Return: A 'port' firmware node pointer with refcount incremented. + */ +struct fwnode_handle *fwnode_graph_get_port_by_id(struct fwnode_handle *fwnode, u32 id) +{ + struct fwnode_handle *ep; + + ep = fwnode_graph_get_endpoint_by_id(fwnode, id, 0, 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..e04901c0bd8f 100644 --- a/include/linux/property.h +++ b/include/linux/property.h @@ -505,6 +505,7 @@ 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); struct fwnode_handle *fwnode_graph_get_next_endpoint( const struct fwnode_handle *fwnode, struct fwnode_handle *prev); struct fwnode_handle * -- 2.55.0.795.g602f6c329a-goog