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 10564C531FA for ; Fri, 24 Jul 2026 08:44:28 +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=15QCCMJqDJvxC4OlYXPloXq3cJq1LSRVcuMMIDjVYjA=; b=LeDR5QOKKKLqwb84twRYwkhTCW VIHwOPgse+hHRYz2GkdlVIa5tAWDTKKAFTYnxyS5eczidGWrDsm0BBS4fa2cKVMPjPKDLhQoBgPty ooBCtzGX3dNHeH8GElw66OWISRkvtWTv5skbu6ec0J450eSimRrSqIzphUzs57T2dHmN25FvhFTUs AEEbKoh0DHNMUy7YJuKcgHkUYRTQ7xvmKBP8JDXSrDGucrTq6c3S/TRwln8yaRe3yYfBJ7MkUZj16 qcZq4idV7xeRbNY1qhVthpR9smqhnwQ3sAm//+nVoC49My20pJynzVqGXP7B1RdokCQhAn3ks2mic 0LcPbSiw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1wnBW1-0000000FqXk-0sSh; Fri, 24 Jul 2026 08:44:21 +0000 Received: from mail-pj1-x1035.google.com ([2607:f8b0:4864:20::1035]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1wnBVu-0000000FqTB-1xZR for linux-arm-kernel@lists.infradead.org; Fri, 24 Jul 2026 08:44:15 +0000 Received: by mail-pj1-x1035.google.com with SMTP id 98e67ed59e1d1-38dfe910e9dso132731a91.3 for ; Fri, 24 Jul 2026 01:44:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1784882653; x=1785487453; 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=15QCCMJqDJvxC4OlYXPloXq3cJq1LSRVcuMMIDjVYjA=; b=Zid+CLGVIIkqA4NWHWSi3W5oXMYdTNL8PQO2q1Y5yiihScNeAoLS8Qr/0mpa8D2hxW z2ygp/TnCu5EPnUmEqdv2uo20eP+0tTHgg2KxTR/afqchGOQlCMk1oToQZ7J1Xb8mmvC D2wgiqeaPf4vvrVlK63JD6lQ0R3EZTRbDdFGU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784882653; x=1785487453; 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=15QCCMJqDJvxC4OlYXPloXq3cJq1LSRVcuMMIDjVYjA=; b=r6JiEkXw2vFW8KdApnddyZnkR10UC0tGFImq3j8/sFE9ru0Susarf5u6nrNsIn0TIp JH8yiezl3pHpApniPmKf1axAJO636m2EoKRrXZwlum0bNgmxIXDOu1gZKHJfDHpgIEwB EbphWAxKEnzoxUmlzfdiVNaMHvGnDTFzUM3Z/LOIuV8do4sXj+7qYxIeL+KUgy/L8kDL fNwesIkR45TcHt091WNXr2tlELBg+ga9BhzuhyV/ki0CjaQ5gL1pQv83ULuYu6+ldFlQ /tmtYNI/IKEoyufmYPr3pU/gZz7qJe9YpilOC6CM9mVsN4Azybu6mGR6KF+BXj1kqIo2 itGA== X-Forwarded-Encrypted: i=1; AHgh+RoJOHLuJJS3ddcWJFFFmUpcrkScN0VmxmK+4sNf+VhBVYNv5qcLKE0JBJgDh2zaeJGOBrPlzT7jLS1P5VrDVMSo@lists.infradead.org X-Gm-Message-State: AOJu0Ywbdx7CPDdqanSZOHI2emJ693EvX0kmDRgnHKlHD87pcnoBmrHT xxy704spKg94on85Cc+IvZVt50j1gOayUvsrla7XIGPqW7qmzCkIYfEBWAUivSKUow== X-Gm-Gg: AR+sD13QkJppzRbNxJggOzbprn8bBtTWr+bgxnfY7B2OePKCYyndgb1aE3I0nRgD9w7 4amfkMJH5bsz1AaNpYG6lDnQ3kw+X0vLlt5TTTa3+E83KJMemdGNqNf0Y1397zy82AlYKGzspGo 74/AhN1UlyPnfoGfvxvUFio4lyykYmsaJNkjOmQ4SDIPPj8azSjW6Rq6xR9qN9aFOJppa2HDA9w 5EPGA7wQxzLf3NKKigTjUIS1Mv11rrrmfbKblzuAYEqQx0OB5Sns8EfWSiukWekF1SYqWlszUZJ H5WvLrtd4pv/RSpOq/1ofyPlnjz9fVlmS7T0tbuaAOiMj6aVXAaNcbj7i79/9DWC3Ib9kxQ/Jxv D1IgfxREB3X/SBOZDv52YrEq/zE75iAnUGmpMcIJY4hu3WGwqggOWRpiRQ2J6SauS/vwPeboLcv UhvfbkFnoBvVOrCMGE6TDr3qnGuuCuNWA2CJvJZhQy1bWT8I3shdfLqTxu8vE= X-Received: by 2002:a17:90b:56cf:b0:369:a359:b181 with SMTP id 98e67ed59e1d1-38ec6610d34mr6642066a91.23.1784882653597; Fri, 24 Jul 2026 01:44:13 -0700 (PDT) Received: from wenstp920.tpe.corp.google.com ([2a00:79e0:201d:8:f131:86cc:5858:7325]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-38f089ac6d8sm434546a91.2.2026.07.24.01.44.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Jul 2026 01:44:12 -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: Wei Deng , 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 v7 02/16] device property: Add fwnode_graph_get_next_port_endpoint() Date: Fri, 24 Jul 2026 16:43:11 +0800 Message-ID: <20260724084328.3943997-3-wenst@chromium.org> X-Mailer: git-send-email 2.55.0.229.g6434b31f56-goog In-Reply-To: <20260724084328.3943997-1-wenst@chromium.org> References: <20260724084328.3943997-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-20260724_014414_523613_A4A78095 X-CRM114-Status: GOOD ( 18.88 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Due to design constraints of the power sequencing API, the consumer must first be sure that the other side is actually a provider, or it will continually get -EPROBE_DEFER when requesting the power sequencing descriptor. In the upcoming USB power sequencing integration, the USB hub driver first needs to check whether a graph connection exists, and whether the other side of the connection is a supported connector type. The USB port is tied to a "port" firmware node, and this new helper will be used to get the endpoint under the known "port" firmware node. Sashiko points out that the |prev| reference put is not done if |port| is NULL. However it seems that the fwnode_*() and of_*() API design implicitly makes the functions no-ops if the passed in node is NULL. So this new addition follows the same pattern. Cc: Sakari Ailus Reviewed-by: Andy Shevchenko Reviewed-by: Bartosz Golaszewski Signed-off-by: Chen-Yu Tsai --- Changes since v2: - Dropped unused |ep| variable - Rewrote as do {} while() - Dropped WARN() use --- drivers/base/property.c | 25 +++++++++++++++++++++++++ include/linux/property.h | 2 ++ 2 files changed, 27 insertions(+) diff --git a/drivers/base/property.c b/drivers/base/property.c index 950defc0c55a..5d3993bd8fc4 100644 --- a/drivers/base/property.c +++ b/drivers/base/property.c @@ -1099,6 +1099,31 @@ int fwnode_irq_get_byname(const struct fwnode_handle *fwnode, const char *name) } EXPORT_SYMBOL(fwnode_irq_get_byname); +/** + * fwnode_graph_get_next_port_endpoint - Get next endpoint firmware node in port + * @port: Pointer to the target port firmware node + * @prev: Previous endpoint node or %NULL to get the first + * + * The caller is responsible for calling fwnode_handle_put() on the returned + * fwnode pointer. Note that this function also puts a reference to @prev + * unconditionally. + * + * Return: an endpoint firmware node pointer or %NULL if no more endpoints + * are available. + */ +struct fwnode_handle *fwnode_graph_get_next_port_endpoint(const struct fwnode_handle *port, + struct fwnode_handle *prev) +{ + do { + prev = fwnode_get_next_child_node(port, prev); + if (fwnode_name_eq(prev, "endpoint")) + break; + } while (prev); + + return prev; +} +EXPORT_SYMBOL_GPL(fwnode_graph_get_next_port_endpoint); + /** * fwnode_graph_get_next_endpoint - Get next endpoint firmware node * @fwnode: Pointer to the parent firmware node diff --git a/include/linux/property.h b/include/linux/property.h index 01ea010cb2f9..9a784a856773 100644 --- a/include/linux/property.h +++ b/include/linux/property.h @@ -507,6 +507,8 @@ 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_port_endpoint( + const struct fwnode_handle *port, struct fwnode_handle *prev); 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