From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) (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 5372042BEA0 for ; Tue, 21 Jul 2026 06:54:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.181 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784616884; cv=none; b=b+8uDx4oxt3B/HJ/5I42NYFVkztbwlsawmrhd+uxSovxXGgv3ez+2lFb1YZr7Drd8kCC4mEuk2vt3a3kFatx0ftgJtU5IZrqkEHMTSyZswPjLrgh4XExCPNsEb1fTuayrFfaPa+fZNydwWFEBO2JKwZOXCLyQCzzGz0sczdiY5k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784616884; c=relaxed/simple; bh=rN8bGYfPxlquy6cQeK5GYz3ym6oKo/FOx8yU0FBCzV8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YwUCn90bpgEG5aTX1/5BF07llnCsetg8A5hRYyOY8XQLPSQWh8g9RC9PEFjG/VOHXi0/SMkldqwv+kfVvefqyO3cPKa5WRCfcWKeaU+SqBaqkrfQVThMyvnFmIDmagQT2zJPQXMJ2JVKfqVGunV+bTfhOnPywfnpozX0craSAQs= 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=O37Eedr4; arc=none smtp.client-ip=209.85.214.181 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="O37Eedr4" Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-2ce87c7e3bbso123653115ad.1 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=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=yZPli2S6cZzTtPxNu5kCcB+M+KQUeHMnkMABY4ADLcw=; b=O37Eedr40TOL1RWQ6QWyigzYQhZ5h6H0pxJg+gceK3/HoVfforjFkq8OceLGsaRKOe ScSbEH3/CJ1lqVjsritmG2lJvjtMZcvz1Sgejb90xiWUOFph/b6goc3ePmMBftzHJUcu VgFCsVs2w6O42y1a0Q42h7rQUFQIMfpFbWs1w= 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=Z8HMNXKuw1sRizQ5WAQNgZ1WO4UNZqFuVCJNwwVKICyf370PNS++NFgr7m+tRdTfO8 wqbVNtFu9vgkomo3psnAoKcVyhX1eJN7zGc7lqePpXidJ0PhX3xJG6BbH5xld4iRhUxF U8WS5c3LpJiS44d0+AVLj1pukss7CFMUL95GlM5oTeMOO+0Bl/DksFvIy/WX+qTvN2RG tCp2PD3SKiv1Uv7+mNMZuIz7EFuuNQ93tdADsnYT/DvOw0SXoZXvt4ngWVCOPXCs6Gvb VzKBkJ5ByWdwuZxA1wyhVXX0PUt0Fpq2PCaEzl6+oJGBe4XToPCxHu6cgIjUsXLljqAb xdRA== X-Forwarded-Encrypted: i=1; AHgh+RqAPNxJbbp7O78HGJ8F50ETgJuXNLTxKKcXFZSUlC5BrvBuHsOg9nQgSBZpvRoK7p1O+wB5wuthH9w=@vger.kernel.org X-Gm-Message-State: AOJu0YxaIs8I3Ei5flbW0J+Ix95A5LX1ui1FTIkOW66NWr/80kUhB5sA N2ghQWWe6WG3wOtoTx0yDlNO1+zy65aZEqfaZoflJV3sCFEVPY5OMTaLQ52E/bxKjQ== X-Gm-Gg: AR+sD11omKL8UMVYr8qzSjsn2wtoj8462Rzh/m+cTtMx7oRJv9Oal8ceWulpujMf0Rz 9AnSVznyyPSJ5qAb1d+G3hQtFCYfXC789fi1ee1+hvCFUhhaJV3wdQa/pXnC13Hl24KXN9vn4QG cltETsa8v0wu5LJrWBHpLiVon5yT8P+5ZpnbD1e4XI0xN7ntQbSFLkk4VnPIM0NIc2YpwsHMaGL 6s0rmPRXMhM6H/HzCzMpJ2xH25Z0jS3mNZzXGNJ68/iKX5bZ29mHrhzgfw2Lm5r/i/kXZ35OrEQ 6wR6NRDHnBKqyiTpXO4LYnu5lkRYYtAYc2xKVoa3YqDznJUAxQN+yGhrZZGxLdRKVynO82APb+5 rNbaV+9/yDABl1kDEr03+K9kVlPJBWo0AlF7xu9QAgx9XLcxYDbkGSraHY662YvU/9hQbAqp9HK CE+4tnMd31T+kK2GLGqNZsFhMiGvcgtkbuQe9vJ4d2X4SrNSQMGIeQkE6PgSQ= 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> Precedence: bulk X-Mailing-List: linux-usb@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 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