From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f175.google.com (mail-pf1-f175.google.com [209.85.210.175]) (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 52DAA3D7D75 for ; Wed, 15 Jul 2026 08:54:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.175 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784105664; cv=none; b=sEO9k67I3bAIlKqGIyCyoOTEbOCIOlBJihUNQ6iV2zcCUmmXkTn9IS4TTsWyTuZH7Ye2uef+2gA+ABSEy1pp8TBoXTSPJwfjn7OQx6DBcl/2iZCokK+GwFluXwc//fImh7CJ+jjerOUyolV7kr7cgRCz+LdoWtXxcUTlYWdriuw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784105664; c=relaxed/simple; bh=sHMrDgD936gJSs9bJLfV9Xhglpv5Agcq8aSC2pp7OfY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MHOAsa3WL8kAgsjPdyxv3/VQPetPk/ElX95ejTA3/OVYT9B0QbLug6NN3yQwM7TgKH+uRTHczLBCwmdCcXjCw5cXyRsTNmeimIOhU0VFxhlx8K6Q551oVMxTdk0bdkdjWBtxu09KU6xvxwgj9WI+cgTjWukgiGL1yjQUXBCmUY4= 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=ParLHhyM; arc=none smtp.client-ip=209.85.210.175 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="ParLHhyM" Received: by mail-pf1-f175.google.com with SMTP id d2e1a72fcca58-84862b0d5f8so1704012b3a.3 for ; Wed, 15 Jul 2026 01:54:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1784105662; x=1784710462; 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=1XAlo36/cvqlWCfJP/st8V9NvEK1f/LvSK5OHVxavmM=; b=ParLHhyMLjNtZyB47iyTQu6bup3gTadNnJF4K/RdC43t9WZqyYxs41M01cpNtDEuDZ gKWxPz2jeK7D5s91p4R71J5TPrecM4fjNCnl2sHMivWga/g1OP3YR35F7cyuz/1v2/RQ EXKC+264rTh6Z1T/5knxodQ6pq8aZTSwK8jCw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784105662; x=1784710462; 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=1XAlo36/cvqlWCfJP/st8V9NvEK1f/LvSK5OHVxavmM=; b=IKd0zKswNPcxSynuGCSKGNbXI1+4UJP/fqlU0dHyKVrTXtDo+6Mg5n06/HFqR8Qqfx nIgL6kBTnQZQARaDM0MlCEht1UbvAPkD4DwaWQb5X+5JIR5I1YWyv6yPuSOrJqJF4xpq fQVZmIva6ocg7vVQEKq8exkWj/2eq0v+yIHFpLZR0KVQxBphRpzyXyEuDj9LHbpk9LiA pRn2Lf5SNvTalKU+LaylTn3Qxb4iN6lj21uJE1AL6BEFOX3eiDWr7pS806isadi58iM6 oSUKjPmKi3YwKI/EcEQNZeJUuPf4VNk2ezEDLEzwaA1EmTMx8R8G0mbxiV12vD0YDkww vlFQ== X-Forwarded-Encrypted: i=1; AHgh+RrC/Sxt88K8l2W/ES8MKK7WSuo8+cGgyxk2MO4t97joG352VJAJS96x+fUk5oxp9I7x+ISer65zWli6PAA=@vger.kernel.org X-Gm-Message-State: AOJu0YxLgoJJCvfDkAMY/S6aNP8x2OKbvj97LrNHlTM469sLn2q6xlLS KTPYYAueqHDUlr+PUV3JmfMeqS3THROasJYZzc06Nrh3ZBsYuDUIVsEQkvO9pHvg3g== X-Gm-Gg: AfdE7cnXWf/BbG8c20/WptuJrFLoe9c/PX21MQqxqjoQzXLmOvCfmvUzUhriz/2g7pr UUfVcBGLwP2ep1Aec+BYF1/jZlXLVKY9+O94MwBgMdAARMA33cdo/6AgYXWJW19TdFlTV4OpsfZ LVQo9g23z+nRQZaf6DNxU7VDlxBQXzQaSNxwPcJkckVUrbKXuX6PI4I8b+gh/BlT/e4IUzm6Ezi tXs8PzV5YTnAX0hBynI0S2m+V4nvwTZ3OtbKpsLWu+hS04WKH2DhprfwHDFJSo7/sm6L8O2paLG xwLLQXkIW/Pk3cSryKqmkXTxXXVORIJDnTcGQFw4vmG6WJTZb7VWTAA97RT4IadTKWCwO+1PI6y 2QDyLTi9ClpTLRvuS23I1/rsuc+x/r86UFTch46Va5k4FnYdmU0l4qrksUjd0DH5Fi4Q2jKsUza LUArzI4shQ12aGe19qwMAC7l9fnyoJH7BKVwuyilVdUekkpXFigbUGjB8OJYBKy1E/QSzssA== X-Received: by 2002:a05:6a00:21d2:b0:845:c6fc:2821 with SMTP id d2e1a72fcca58-84889604f51mr14884898b3a.22.1784105661732; Wed, 15 Jul 2026 01:54:21 -0700 (PDT) Received: from wenstp920.tpe.corp.google.com ([2a00:79e0:201d:8:47d7:4aa5:a6f8:2279]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-84a4f819117sm2757491b3a.59.2026.07.15.01.54.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jul 2026 01:54:21 -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 v5 01/16] device property: Add fwnode_graph_get_port_by_id() Date: Wed, 15 Jul 2026 16:53:31 +0800 Message-ID: <20260715085348.3457359-2-wenst@chromium.org> X-Mailer: git-send-email 2.55.0.141.g00534a21ce-goog In-Reply-To: <20260715085348.3457359-1-wenst@chromium.org> References: <20260715085348.3457359-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. Reviewed-by: Bartosz Golaszewski Reviewed-by: Andy Shevchenko Signed-off-by: Chen-Yu Tsai --- 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 | 3 +++ 2 files changed, 32 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..480ba8646bcc 100644 --- a/include/linux/property.h +++ b/include/linux/property.h @@ -505,6 +505,9 @@ 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_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.795.g602f6c329a-goog