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 61E1EC4452B for ; Tue, 21 Jul 2026 06:54:50 +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=NvQNf3BqfKVtTGXxdpusC/9tqA S5V18XMwxs6ctsI2sTtSJxfDRoPHLnm33xyfTLKL+KrUUlcgmNudg8LA3OZ4wDi2Ja5pbwN2wqG1T XEbCUr+zE3yNhWXE1B7An6v3/+TnLkNwDR00D6i4bDfAMlyW+HD6ZUsEfQV/azRjHrQ4ac+FZ4fsQ LqMTARyXF8gASDtQyprW0yk74WH6l2EpoWSUGNgqpZIvG5F2ifdAJwYwOrTpzhtT/yZqMVXZrpqID ygAAYxCG2FUoqA6iEHAmgBd0y1B8Um2aVpVwIomuKbQwFKPdegwQYb7YxGeKeUXCojIlU4P9h7wXV Q2l2LtjQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1wm4NN-00000008a04-1H1B; Tue, 21 Jul 2026 06:54:49 +0000 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1wm4NL-00000008Zxe-0o6e for linux-mediatek@lists.infradead.org; Tue, 21 Jul 2026 06:54:48 +0000 Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-2cf52d15d88so25288445ad.2 for ; Mon, 20 Jul 2026 23:54:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1784616886; x=1785221686; 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=V3OHLBMIjDUW6V5utTl8+tpLQAo4yEPqDKuukdYG4VHTJLCmwcSLhKOyyPTHpgEph9 +p9TASE9vex/m1CzMYwIqM3Byy9trxskUXxiWdFgAqYqoEdofq5QKAwVtgjv+2LNt40a TtWIFPpz517o+C55ZTHgc9wxT0HxCU54Tr5Io= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784616886; x=1785221686; 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=mzkGv1nyPQM4FnyRzLVlvEqs0IrsuTUgODV+/NOIFLGYgBD50L2IRHBN+n/NQqNRoH B+Z0JBzTf6ePqB4pZ0V8IYgLmlgfnmhQpPEjWepX0MsVAvJfkL/bGpPEvpDalVuqepkO cVFD3gHbvFqoGLUEjOHGp5e3b/yyYg/wD2eZX4QqYNflHRnUVlqbHMHPdDZQZx+Z6cHW BII8g78FvFrgxhrfdAeLHFDAJ7JTU42tH/QXXXCBCmznSurB6SHs3RaNm2jxU9aM6y6j pmpmCVab02O6DO6HQHPu5NcRy4QlFwXWg9Rfg8xlgKiPJztapL2C7f1QitxBybrTpdwH S0XA== X-Forwarded-Encrypted: i=1; AHgh+Ro0Yfj0q3vGPNWozPBKJnlrjXUj7seMQaJC2ov0G/ctoHKeCtOPDEGCY95/vHNwod9OznZ/MhL2fx/p1Y75Vw==@lists.infradead.org X-Gm-Message-State: AOJu0Yw18/RMOmCvBjvL+COvGSh1iedRZetJYE5YOTiT0JuUT8CBiW4/ 0uT3cN6MXRH5rTWl/tyyaKdO1dDKEO0SfuIuJjey9KMR3nBho4MXw+OcqV6zS10BcQ== X-Gm-Gg: AR+sD1381MUGp9QXnNnVTofM1I6Hinnia3lrmVpzLTvv+ZgQmT/LnVAya4tQf8iB0MF JUMOVKFVPcSp/fMf79+Lh7IalBgpyms2q+v7zn3WAlfuB9+UKdw2Q9HaFO+tD2LHsjEJswu8dgc kicy9T/fIRt8B3Hf538fxvH1ZTxid56rsacBhJFU7GDI2EuW7X3sSVKFiW/E0+HuUckGi61aBYg GjEV97vseWhoI2jnXLLT8vDA/g1aTrfXNBuBQkmFnjr3NeKX6tYkSubRI7XgTCHWfH90cJB5Kox FiRI9RdTixtiUkvZ+gAX+SE/GmUtYGa1dvTh9luQVSfN1FpQ63rOjajdzDFuNz28ZsbaQ+UNJU0 AYiujX0piE4MO/qj2HsCrdl62Gi7xp9Vvx39doHL94wS3q8eMdOGbzI1PknO1HFQf5wKSGfmebV +pp+VJsfVJMVxYoqdO9X4cQvEU2TMuWTPqsKPooIr+fdCfP7iTIyjheMYJZTY= X-Received: by 2002:a17:902:c412:b0:2cc:86a9:ebfb with SMTP id d9443c01a7336-2cf349b839amr193173875ad.33.1784616886249; Mon, 20 Jul 2026 23:54:46 -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.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jul 2026 23:54:45 -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 02/16] device property: Add fwnode_graph_get_next_port_endpoint() Date: Tue, 21 Jul 2026 14:53:57 +0800 Message-ID: <20260721065413.2306137-3-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_235447_268789_4C212B14 X-CRM114-Status: GOOD ( 18.41 ) 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 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