From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) (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 96C833B42F0 for ; Wed, 10 Jun 2026 08:41:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.180 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781080890; cv=none; b=FsbWs2PRoYwG/p7eIirZm4/zmogFZsD/Pw4L3j8Ey3dPRxsiXBpDxzMywa0grtHerhh1ThNLHfafi4UT1pUgJ1+fuxtqNvHh5yMpWMHp0lCFuo9bUNJtxKmEw2kgulMHPy8iasiJkXNbU4Scka676Gs3e6acj4nwtXOqG91H7ls= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781080890; c=relaxed/simple; bh=kGHE6+HJMR5imhLKMaKrAxWZPafgyUmm3WFusAEShNk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mhPENNXuypjansd7zAuTMoeut/kBPrnz0S9xyV2PM1RzeWdrdbMYvPsAbSssq8wFnuj+tOCo6nR2s04KFNFnEV9DnqRkjcrXU0e2tl/W21nB2XfVHTibXzWisokvBdre1VXxtkztk2+Jr9L2Iq9eNFN9z3KLyNtlIm25+1ukcC0= 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=UeNZamHz; arc=none smtp.client-ip=209.85.214.180 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="UeNZamHz" Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-2bf114b0cf9so59287055ad.2 for ; Wed, 10 Jun 2026 01:41:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1781080888; x=1781685688; 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; bh=e6pTgkTdjphaP4G6StNKBNkGmsxmuRCJqaledSqIiFY=; b=UeNZamHzBpxIDD55A/EpwJn4VeIt196/YcqEaOqVYM09w3muTzoBxBOKqKvPp6POCC eNVk6BBUujs6WDSOg0wl1x19Pft9XwIwjGDZYxXqQhJaGS2hZnLtnhMnmXuQvCmj0G+R 4LHFquxEOnD4063odNEqmxWl+8B3g3n3036cM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781080888; x=1781685688; 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; bh=e6pTgkTdjphaP4G6StNKBNkGmsxmuRCJqaledSqIiFY=; b=blU6PJNZwIkwjmMhE7zHJh+BThAHBWAg5Ghl84RpinVfW7RUrMYofCppK2W/kHx7xg U1zlE+BrMmlfn72UhfFOQb/HANrQJB9V4t9iNzaY8KBx2ggBtqi4GVe9n4xKwl8yXC47 vWSw523DFQJ2V4uNoPXMk51hAOb8K0lgWN1d8PO51QzUoH/tMU48+4hcWK3kEjZjcIiA mtIiPX4N+Qf/HOXOptpR7Hr7KCsZa3FweahHuIfPtsLK3tIZgoZAKRhNZxHMFCPdbDJk L9b9IwTVQFYI6z4RZsgzin9eIoKOXcjiIJYAb6HAzr3HCMcQ+kJ0+EwlDI5bMjxYvsIx +TfA== X-Forwarded-Encrypted: i=1; AFNElJ+oAl1Zk5DDkXQhdYQ9lLvB/cBj+ujJGILr8p3x6w6TJcC7niphSjxrWDdc73zpbcN6Ee/F+8zxb/6erXQ=@vger.kernel.org X-Gm-Message-State: AOJu0YzIdHvUNbfGtBEzXwS7TmwGQyfKH/nfPserZUGrzlPsExIqqH2R EsQTjGSroTYpRmqKlwUYXhwfZsmEbiF43lEKvax0Osc6oHQ42Lypb77rLJhfA3GISA== X-Gm-Gg: Acq92OGtpPXdjkHIidEttbdM/Wo3pZQDWhEGBKPWLOjaBFhD9Tjx1wWCXlrxuLmuzkx EF7zqC6Kp5VbesXIKMAjaTDR7c+ZSJdPR1x1INokW9pEgR7B2FGy/5RC5zRYjZJyssM3mBc5Y/E 7IGJXmW9pY+3y9rv1+hTtna+L7Qg1gdXe+HTrVM1g+D7ux/IQ0mrwDyp1MB06RqvbEcmxGChyQV SO9UimQeeTpzmMUwfNTWwdN6znEMDC5djA6gufZt9FMDNyhO+VQLhue5qF0x68Ti+EvTAjzMWOe JMIOgj3YCHfp+/Ve1it0dohidVmu1BHqyFhKKrdUnInmrk7JNAzIBuVGfj0eHnFVtap/126RecZ o62OplCZdn9AhDwjeql7LjMivkRlaWQFChEGJ6AJnLr/Vfh3kcpTddYM7FwoRB3jrj4uwWaH0h+ NgEItoJ6fbx75Ha5sSka3dO1LS7pSwuQtzyWhTJgDi+9p+YJ/H1x3WWASr5spyqozBbs3rwyIxW yvN3ANYw6ML4jdSYQ== X-Received: by 2002:a17:902:ce8f:b0:2c0:cb0e:ac42 with SMTP id d9443c01a7336-2c1e80f9d2bmr271193835ad.3.1781080887890; Wed, 10 Jun 2026 01:41:27 -0700 (PDT) Received: from wenstp920.tpe.corp.google.com ([2a00:79e0:201d:8:3870:6325:16c:d35c]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2c164f890b2sm239223725ad.26.2026.06.10.01.41.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jun 2026 01:41:27 -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: Alan Stern , 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 Subject: [PATCH v2 02/16] device property: Add fwnode_graph_get_next_port_endpoint() Date: Wed, 10 Jun 2026 16:40:36 +0800 Message-ID: <20260610084053.2059858-3-wenst@chromium.org> X-Mailer: git-send-email 2.54.0.1099.g489fc7bff1-goog In-Reply-To: <20260610084053.2059858-1-wenst@chromium.org> References: <20260610084053.2059858-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 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. Signed-off-by: Chen-Yu Tsai --- drivers/base/property.c | 33 +++++++++++++++++++++++++++++++++ include/linux/property.h | 2 ++ 2 files changed, 35 insertions(+) diff --git a/drivers/base/property.c b/drivers/base/property.c index a2afd854a604..cf14f9b0a3e0 100644 --- a/drivers/base/property.c +++ b/drivers/base/property.c @@ -1099,6 +1099,39 @@ 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) +{ + struct fwnode_handle *ep; + + while (1) { + prev = fwnode_get_next_child_node(port, prev); + if (!prev) + break; + + if (WARN(!fwnode_name_eq(prev, "endpoint"), + "non endpoint node is used (%pfw)", prev)) + continue; + + break; + } + + 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 11f3b54c7de0..2e744c6f251d 100644 --- a/include/linux/property.h +++ b/include/linux/property.h @@ -500,6 +500,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); +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.54.0.1099.g489fc7bff1-goog