Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp792042rwl; Fri, 31 Mar 2023 02:23:17 -0700 (PDT) X-Google-Smtp-Source: AKy350Z3/X0aR9qAaWpuuLJm9I/8Nk89N4/cK5PGhjY6kP66AdIVl3+0mAXBBjGx5ykXU1oKUHa7 X-Received: by 2002:a17:906:d3:b0:947:bff2:1c2b with SMTP id 19-20020a17090600d300b00947bff21c2bmr640035eji.1.1680254597377; Fri, 31 Mar 2023 02:23:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680254597; cv=none; d=google.com; s=arc-20160816; b=f9mww/6i4PvlpBvewSESW1Q3w0UyTaVCdZKZxcJXKAGD+bxYmHGh0+pFUIXqYM7FGa +YzUoTlaqv1m4S9EufL/kjuOSJupFPv9puIFnE4hQrSCEahkIeYhV9AcDFZDsV9MC6tE dHyOmSVy4YQRlH7Rdo7vGZ2RzgG5BiuN4CTELCFZgBe7uxIon+gxo0FI83tBRzUMGG5x MxdKPGK4RolvdOtNF1IQbqtl2+nMG20Z8hArELVp6eDDQk2HHMspswAzFarEhdGXBFm9 VpmfNkIbH2o95UAOLpWTM1K03KZ5/TtAXC4ZPrX7zuxJCcJnVfN5iDN5bzr9hbvt9b36 zq+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=tIMJE3+dfsZuEjePkz0Wtpnf70h/+RWLQj9/gW4AUjg=; b=ZnSJTiOVidAoru0adpd91M7hEhpWy3jNbCEeTpDPq9NSQVJyBoMptc0ttMHYCdfv0l OnuzJKfdTwqRS9FO6o8NOxgdp4w8q9EV45NUsLNKAW2I/b0InXy3HHt3jfP+3tKN/f1a jbHo3ovXdliIkPbgO/IdWnodaIceqQ8n+KbRQbwlUgOScHe4bh015n6vv7hPZAIj97Kx arrXUELDc1vSdceQsWyZPQ4A3zgU/P0C/d0nBW3m9iGH4RcaA3v9lh38k9g1umY0lfP7 RtC3V7Bh6XEcajUMeBD4J6sgJl2N05UPiraHmpKVBebD+TNnRMjKYm3wnNQUiZHuHpkP 3uUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=f6TZGuc2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gf23-20020a170906e21700b00925f618e1e6si219440ejb.174.2023.03.31.02.22.53; Fri, 31 Mar 2023 02:23:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=f6TZGuc2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231858AbjCaJMF (ORCPT + 99 others); Fri, 31 Mar 2023 05:12:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230336AbjCaJMD (ORCPT ); Fri, 31 Mar 2023 05:12:03 -0400 Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D1A7B758 for ; Fri, 31 Mar 2023 02:12:02 -0700 (PDT) Received: by mail-pj1-x102f.google.com with SMTP id mp3-20020a17090b190300b0023fcc8ce113so24747987pjb.4 for ; Fri, 31 Mar 2023 02:12:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1680253922; 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=tIMJE3+dfsZuEjePkz0Wtpnf70h/+RWLQj9/gW4AUjg=; b=f6TZGuc2T50Dq07l1gNxPP0O7ZlppNgkbuVkyNX5gSiwXb0iTsn7PtY/6vt86ERuKc ja0qYPsMZkSzhxgE0CW/LXxFcY1WiVHMlGqErt8ZcQ1boSgcH64zn887opoTy/ver+FI SBFd1tHsszo65lY9MDlGO/jq+Cj2l4ukGF32c= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680253922; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tIMJE3+dfsZuEjePkz0Wtpnf70h/+RWLQj9/gW4AUjg=; b=4dfB4DxB3p1xP3jD4edqHidbaAuiNelcKMCXC3JlahZHAgoT9VqUez9PiSm8d8EC0J 6tlCxfq3Iko3DUdCun7MF1PBTxU3c1PQVBS0xRmUlXBLwhGIcvux+PdA7pFQAbOZlZR7 uwpJE50UmeneYQLyDpRtgal9UrxviEXsanA8YabSQFPNJWVFANpQeClllQdzCS6HInjw KmkW/1IDYgldoHQYZCnqAxTs87dsnBg7PmTaqWZKPBV5x8H8f3xM57xHdNUAOOTVTPZO njLzl/u0yrIp0+yAjRDM6Xlb0MC9fhZ0lHjDGax7CbDUcO0TwfuyK1UsHQI1eThrj+pZ PjDQ== X-Gm-Message-State: AAQBX9dY4lHXD6BqYn1WVVPqa5kCUJHLZqEe9zx2703HW5ocoXIfY1wD /kUJMrrruFG0GRUx/FcTFFx4bw== X-Received: by 2002:a05:6a20:989e:b0:da:c41e:4ddb with SMTP id jk30-20020a056a20989e00b000dac41e4ddbmr9396655pzb.7.1680253921885; Fri, 31 Mar 2023 02:12:01 -0700 (PDT) Received: from treapking.tpe.corp.google.com ([2401:fa00:1:10:ae9d:db7a:8a71:d458]) by smtp.gmail.com with ESMTPSA id n6-20020a62e506000000b006227c3d5e29sm1360905pff.16.2023.03.31.02.11.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Mar 2023 02:12:01 -0700 (PDT) From: Pin-yen Lin To: Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Andy Shevchenko , Daniel Scally , Heikki Krogerus , Sakari Ailus , Greg Kroah-Hartman , "Rafael J . Wysocki" , Prashant Malani , Benson Leung , Guenter Roeck Cc: Xin Ji , Marek Vasut , Hsin-Yi Wang , Thomas Zimmermann , AngeloGioacchino Del Regno , Lyude Paul , devicetree@vger.kernel.org, Stephen Boyd , dri-devel@lists.freedesktop.org, linux-acpi@vger.kernel.org, chrome-platform@lists.linux.dev, =?UTF-8?q?N=C3=ADcolas=20F=20=2E=20R=20=2E=20A=20=2E=20Prado?= , Javier Martinez Canillas , Pin-yen Lin , linux-kernel@vger.kernel.org Subject: [PATCH v15 01/10] device property: Add remote endpoint to devcon matcher Date: Fri, 31 Mar 2023 17:11:36 +0800 Message-Id: <20230331091145.737305-2-treapking@chromium.org> X-Mailer: git-send-email 2.40.0.348.gf938b09366-goog In-Reply-To: <20230331091145.737305-1-treapking@chromium.org> References: <20230331091145.737305-1-treapking@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Prashant Malani When searching the device graph for device matches, check the remote-endpoint itself for a match. Some drivers register devices for individual endpoints. This allows the matcher code to evaluate those for a match too, instead of only looking at the remote parent devices. This is required when a device supports two mode switches in its endpoints, so we can't simply register the mode switch with the parent node. Signed-off-by: Prashant Malani Signed-off-by: Pin-yen Lin Reviewed-by: Andy Shevchenko Reviewed-by: Sakari Ailus Reviewed-by: Heikki Krogerus --- (no changes since v14) Changes in v14: - Collect review tags Changes in v13: - Update the kernel doc of fwnode_connection_find_match Changes in v12: - Check the availability of the device node in fwnode_graph_devcon_matches - Ensured valid access to "matches" in fwnode_graph_devcon_matches - Updated the documentation in fwnode_connection_find_match(es) - Dropped collected tags due to the new changes Changes in v11: - Added missing fwnode_handle_put in drivers/base/property.c Changes in v10: - Collected Reviewed-by and Tested-by tags Changes in v6: - New in v6 drivers/base/property.c | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/drivers/base/property.c b/drivers/base/property.c index 083a95791d3b..4426ac2b16ca 100644 --- a/drivers/base/property.c +++ b/drivers/base/property.c @@ -1243,6 +1243,23 @@ static unsigned int fwnode_graph_devcon_matches(const struct fwnode_handle *fwno continue; } + ret = match(node, con_id, data); + fwnode_handle_put(node); + if (ret) { + if (matches) + matches[count] = ret; + count++; + + if (matches && count >= matches_len) + break; + } + + /* + * Some drivers may register devices for endpoints. Check + * the remote-endpoints for matches in addition to the remote + * port parent. + */ + node = fwnode_graph_get_remote_endpoint(ep); ret = match(node, con_id, data); fwnode_handle_put(node); if (ret) { @@ -1293,8 +1310,11 @@ static unsigned int fwnode_devcon_matches(const struct fwnode_handle *fwnode, * @match: Function to check and convert the connection description * * Find a connection with unique identifier @con_id between @fwnode and another - * device node. @match will be used to convert the connection description to - * data the caller is expecting to be returned. + * device node. For fwnode graph connections, the graph endpoints are also + * checked. @match will be used to convert the connection description to data + * the caller is expecting to be returned. + * + * Return: The pointer to the matched node, or NULL on error. */ void *fwnode_connection_find_match(const struct fwnode_handle *fwnode, const char *con_id, void *data, @@ -1325,9 +1345,10 @@ EXPORT_SYMBOL_GPL(fwnode_connection_find_match); * @matches_len: Length of @matches * * Find up to @matches_len connections with unique identifier @con_id between - * @fwnode and other device nodes. @match will be used to convert the - * connection description to data the caller is expecting to be returned - * through the @matches array. + * @fwnode and other device nodes. For fwnode graph connections, the graph + * endpoints are also checked. @match will be used to convert the connection + * description to data the caller is expecting to be returned through the + * @matches array. * If @matches is NULL @matches_len is ignored and the total number of resolved * matches is returned. * -- 2.40.0.348.gf938b09366-goog