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 29AF13B14DA for ; Wed, 10 Jun 2026 08:41:24 +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=1781080885; cv=none; b=STfQAtFH8LYa03NiGThpGWUsGVkQcYd8bN5Feq06SMOOtroVGV/fzolS+vWEzjYIJvSzdJ0bGB5Q2B/3BP+/46mMdznUXq+OxC5dDKSaXhAv9u9tifVX10D1Ot5rorAwSwhhdlwXWhIhi2a/5O8cqYJiFGTUrh3DvPnR8pmvrD0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781080885; c=relaxed/simple; bh=DzZj1fIJIKJKGnQbn8uPuOz0dFp4PhGSgOkWpDGy4sE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=l0nzYj5Wf+LqDkkbvGDSD3Wwa+M8hnW5E0ydYhpvrjW4tlAdLTDPl/k4SCW6+rqltlyAfmdfzSp5YUoVvOopbgXa6Pwd+4M7ZDU3jxP6QEU6HakNH1DQZAF/BRvXuD2R6sDw+nTbfRt3SzUH/wLoxFbrDGgRb16wqQOKo4PGX/g= 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=lSS5MGF/; 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="lSS5MGF/" Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-2bf1f074a12so66329765ad.0 for ; Wed, 10 Jun 2026 01:41:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1781080883; x=1781685683; 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=FRsKkRuXXrcRjbvRngvMO9bdz13WA7D5wKB/6fXyEG0=; b=lSS5MGF/yeef+r+Jc1KoAYuYYIrl5M7mG84EXuWybuu36dzej+lYnrc+Dn/WXSyzfM 0K/uYQbMwKFYPFQV7Zkrs6agmfzcKI0fgNT5lVOwVwiznAbXbfczUcuzRX/TM5LoneHt vl5eQoNQCDq5JWIFYbpb2fogm/9j7l394sY/M= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781080883; x=1781685683; 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=FRsKkRuXXrcRjbvRngvMO9bdz13WA7D5wKB/6fXyEG0=; b=Cq8Jz/DJspzPanZhYVvODLQJsb+gMFMf5w9O9fNstO99RNqTsU/QZF1S7Ly9O8qV/+ wNlZB+8VOFMh8eQiaEQgQUHUNedWdHRQY97IdUTqPpuZsz/43fDCbTIQqFAGJ68aKI4I gTSJpZD/ORW+KkKOaha7870sqkczBUe0DaXk+M/AJNydP4xVEt5uqKD++tk7ioZxNhl1 7Y2iRJ8TfZupQLYz3I/2k434znrkslPqMgCu1Ia5VXMvNgYHFYPNus6mwAK07U7p/DnL +1eGnDyJCaJOSjOYtU/WVDp9yxBPI7TokL7NTb+lIa3CZzvCaBu4co3b2j0LEHUp3JLd 2Fww== X-Forwarded-Encrypted: i=1; AFNElJ/tD2XsxRAcIy9hEvpKtQFTyqwsIB3nH9zbskKtg3JhjmD5yQfgGVG0NDp3ar5WaMtHvpGiPYUHGVpG1Lg=@vger.kernel.org X-Gm-Message-State: AOJu0YwLqOGAAJGZH8XhHkTBhc+poRinFUiR9JcnqCoprely+Ji7NeqW qBxVbokxdzJvcwkpfFru6QHg9eGbXDth/DUlpiEtahU5wPejp0hf7yggU1wJ0OfP9w== X-Gm-Gg: Acq92OFpxQaAfLXdT0vmU+n8Tdxc4cslR0suYjvP93ZICasUlCAICOOnLtDeMiOWLLd V7BKnj9zArv6WcrUU+HMcsE/Rq/hRDHm0MJkxv2+bkdoMEpF4HsU0G74crwp3aVMQ7W+rjGmPy2 IllU+X99RYgELwa/dNGA6jE69dGmR5dgLUSCoIGnE4Imvy9lMOlT3D6VhI4/RGyH/rDdLt64EFZ 72m3HkCscf2ehpCmmXVfFSvw7azHfTZVu6ybqdrlKwkzBBNtjRDAxFFqSdA7hgWaJ+lyRomCa9+ ocf0CgtFB0kySuUi4wpyBfTH9/U/uut4gmBnZsvJzmI2ZTrop9m9n+aEZ1vxHqGiNk5LJtD+DhS RaTl3bzBcVm5ggDrVpB+CXak7eFbLfwJiz7m2yonIEdhAAWCnzO2ucLD9oRUXtpFCAXp15a9rpO k7KvfAboyp7i76VXpHRa4P8dX1pYWaGXWnq8QZBQVF32MA9M6qHSYTtIHU7azMk+5F/yMa8eknY YXxPKC24ScpVqaRSQ== X-Received: by 2002:a17:903:3b8b:b0:2bf:114b:924 with SMTP id d9443c01a7336-2c1e85ca6b6mr285765545ad.34.1781080883374; Wed, 10 Jun 2026 01:41:23 -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.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jun 2026 01:41:23 -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 01/16] device property: Add fwnode_graph_get_port_by_id() Date: Wed, 10 Jun 2026 16:40:35 +0800 Message-ID: <20260610084053.2059858-2-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 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. Signed-off-by: Chen-Yu Tsai --- 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..a2afd854a604 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 + * + * Return: A 'port' firmware node pointer with refcount incremented. + * + * The caller is responsible for calling fwnode_handle_put() on the returned + * fwnode pointer. + */ +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 e30ef23a9af3..11f3b54c7de0 100644 --- a/include/linux/property.h +++ b/include/linux/property.h @@ -499,6 +499,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.54.0.1099.g489fc7bff1-goog